Open bloudraak opened 2 years ago
Hi @bloudraak thanks for reaching out. The HCL configuration language while similar to Terraform's does have a different syntax and does not currently support the ability for things like aliases. TBH we have some work to do before we can get to this point. Terraform's HCL usage has matured nicely over the years.
That said, I do wonder if you had a chance to look at Packer's source reference syntax, which may help in this case.
Taking your examples from above I've provided a few options for sharing the source block configuration.
I have an azure-arm source with somewhat "complicated" networking setup due to VPNs and such. I want to have this source defined in one file and then "include" it somehow into different builds. So far the only way I found how to reuse this is have all the stuff in one file, name the builds and then use packer build -only worker-big
or packer build -only worker-small
and so on to run different named builds.
Since each of our images is quite different, we keep them in different directories with all the provisioning bash scripts there. But I can't find a way of including a file from outside the "build" directory into the template. I think that's what's being asked by OP as well.
But I can't find a way of including a file from outside the "build" directory into the template.
Might a symlink work?
Community Note
Description
Assume you're building many templates for your organization or a large build farm consisting of several operating systems, architectures, and configurations. As a result, you end up with many different Packer templates. Some provider-specific information, like how to authenticate, which hosts to use, and whatnot, is being duplicated everywhere. You could define a local or variable and reuse that, but the extra boilerplate adds noise to the templates.
This feature request is to be able to centralize the configuration of a provider and reuse that. The provider can be seen as having defaults that sources and builders can use if nothing is specified but perhaps be overwritten in the builder and sources themselves.
Use Case(s)
You tend to duplicate provider-specific information when you have numerous packer templates using VMware vSphere (as an example). It just adds toil and unnecessary boilerplate. With this feature request, we can reduce the boilerplate required by Packer and reuse the configuration.
Potential configuration
Taken from Terraform
Or, in the case where you need to support multiple isolated installations of VMware vSphere (as an example):
Something Terraform does not support but would be somewhat helpful is something as follows:
I'm using VMware vSphere purely for illustrative examples. It also applies to other providers.
Potential References