hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.04k stars 3.32k forks source link

Using "packer build -only" still parses sources not included by -only, generating errors #11365

Closed hawko2600 closed 2 years ago

hawko2600 commented 2 years ago

I have a hcl template which uses hyperv-iso to create a base image, and hyperv-vmcx to then use that image to customise other builds. I use packer build -only xxx to select a build target.

When the iso source artefact hasn't been created yet, the run of packer build (to create it) will also complain with an error for each of the other sources that the vmcx image doesn't exist, despite none of those builds being selected via -only.

My expected behaviour is that using -only will only worry about the only build that I selected, not have a sook about unrelated and unselected builds. The template parser should ignore configuration variables in sections that do not match the names specified in -only.

The workaround is to use two templates, which then means two places to maintain the same build variables.

azr commented 2 years ago

Hey @hawko2600, thanks for opening, Packer core is currently done in big steps where everything is parsed, verified, etc. and chaining builds is a little hard and rather manual. Going there is planned for Packer v2.

Do you have a simplified template file I could look at ? Maybe I can help there, also we might use it to prototype our 'dag' feature, which will make this experience way better. Thanks.

nywilken commented 2 years ago

Duplicate of #11037

github-actions[bot] commented 2 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.