Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use user variable in vagrantfile_template with HCL2 packerfile #9

Open
ghost opened this issue Apr 21, 2021 · 0 comments
Open

Comments

@ghost
Copy link

ghost commented Apr 21, 2021

This issue was originally opened by @aacebedo as hashicorp/packer#10828. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

I am generating a vagrantfile when creating a box with packer. In this vagrantfile, I use variables defined in the packer file.
In the vagrantfile.tpl I add tags like {{ user myvariable }}. When I use a JSON packer file, everything is ok.
I upgraded my packer json file into the HCL2 format and the syntax seems to have changed for those variables as they are not replaced anymore. I may be missing something here but the document "engine" page of the JSON section does not exist in the HCL section.

Reproduction Steps

  • Create a HCL2 packer file using the vagrant post-processor
  • In the vagrant post-processor define a vagranfile_template file
  • In the vagrantfile template refers to user defined variables coming from the packer file using the {{ user myvariable }} syntax.
  • Run packer build, the variables are not changed.

Packer version

1.7.0

Simplified Packer Buildfile

file.pkr.hcl
[...]
  locals {
   mylocal = "helloworld"
  }
  post-processor "vagrant" {
    keep_input_artifact = true
    vagrantfile_template = ./vagrantfile.tpl
  }
[...]

file vagrantfile.tpl
[...]
something = {{ user `mylocal` }}
[...]

Operating system and Environment details

Linux x86_64

Log Fragments and crash.log files

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants