Skip to content

Add --chdir flag #12183

Open
Open
@gammore

Description

@gammore

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Description

Hello! When using packer on my repo it would be very useful to be able to "chdir" o a folder when execution packer build.

The idea is the same on Terraform: https://developer.hashicorp.com/terraform/cli/commands#switching-working-directory-with-chdir

Use Case(s)

My repo structure is as follows:

repo/
  Makefile
  packer/
    variables/
      variables.pkrvars.hcl
    frontend/
      packer.pkr.hcl
    backend/
      packer.pkr.hcl
 
  terraform/
    terraform stuff

I would like to be able to execute packer from the root of my repo, from a Makefile, to make it very easy to build my images.

Potential configuration

An example of execution would be, using my repo structure above:

packer init -chdir packer/frontend/packer.pkr.hcl
packer build -chdir packer/frontend/packer.pkr.hcl -var-file packer/variables/variables.pkrvars.hcl

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions