Packer: Help with -only flag

Created on 15 Jun 2020  ยท  3Comments  ยท  Source: hashicorp/packer

Packer version

1.6.0

Goals

Migrate to HCL & split code into source, builder & variable files so we can write source blocks once and reuse them across any builder. Building images across providers should just be a case of adding a new source and adding it to the relevant builders files.

Problem

File layout is:

  • hcl/source-amazon-ebs.pkr.hcl
  • hcl/builder-alin2.pkr.hcl
  • hcl/builder-win2019.pkr.hcl
  • hcl/variables.pkr.hcl
  • hcl/vars-alin2.pkrvars.hcl
  • hcl/vars-win2019.pkrvars.hcl

Each of the hcl/builder-* files has a name attribute e.g. name = "alin2"

I expected the command to build a specific OS would be packer build -var-file=hcl/vars-alin2.pkrvars.hcl -only=alin2 hcl however nothing is built.

What am I doing wrong? Or is there an issue with the -only flag?

hcl2 question

Most helpful comment

Hey @vanderboon, thanks for opening, it is not yet possible to do this. For now only/except will solely match the source type and name. I am currently working towards making this part of Packer HCL2 a little bit better and consistent. The issue is this one: #9399

All 3 comments

Hey @vanderboon, thanks for opening, it is not yet possible to do this. For now only/except will solely match the source type and name. I am currently working towards making this part of Packer HCL2 a little bit better and consistent. The issue is this one: #9399

Thanks for the update. I'll monitor #9399.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mvermaes picture mvermaes  ยท  3Comments

shantanugadgil picture shantanugadgil  ยท  3Comments

frezbo picture frezbo  ยท  3Comments

znerd picture znerd  ยท  3Comments

wduncanfraser picture wduncanfraser  ยท  3Comments