I’m working on my first hcl2 template for packer and had a question about using the build name as part of the output_directory. This can be useful when you have two builds that use the same source and don’t want them to clobber each other.
The template is setup with two builds that are named build base & full. base
full
Within the source I’m specifying the output_directory using the templating syntax. However the build_name is not what I expected. It appears to be the name specified in the source resource.
Am I missing something obvious here? Maybe this is a bug with the build_name not sourcing the correct value? My expectation is that the build_name would be the same value used in the -only command line flag which would be base.vmware-iso.macOS_11 or full.vmware-iso.macOS_11.
I just went to look at this and I don’t think we have a way to do that. I think the issue here is that HCL differentiates between the source name and the build name, whereas in legacy Packer those were the same thing. So while we have ways to surface the source name – an example is"echo '${source.name}'", we don’t currently have that for the build name. I’m going to open an issue on our HCL implementation ticket.
Excellent!! Thank you for making this improvement so quickly! I’m porting a few templates to hcl2 that use this functionality and it will simplify things.
Awesome! Please feel free to open issues on the github repo if you find anything else that feels out of whack. We’re really hoping to get HCL out of “beta” by the new year.