Packer: using -var-file doesnt work

Created on 19 Nov 2014  ยท  8Comments  ยท  Source: hashicorp/packer

i am trying to use the -var-file with no luck. it says the variables are not found. anyone have any ideas? ref: https://www.packer.io/docs/templates/user-variables.html

i am using Packer v0.7.2

question

All 8 comments

Gist your config.json, var-file.json and your command line you are trying.

@rickard-von-essen sure:

the config.json -
https://gist.github.com/developerinlondon/092429caf39a8d21c16a

the var-file.json -
https://gist.github.com/developerinlondon/dbfc29349a6be91ca615

command I am running:

$ packer build  -var-file=var-file.json build-hh-jenkins-prod-base.json
Failed to parse template: 8 error(s) occurred:

* Unknown user variables: log_volume_size
* Unknown user variables: jenkins_volume_size
* Unknown user variables: environment
* Unknown user variables: aws_region
* Unknown user variables: base_ami
* Unknown user variables: instance_type
* Unknown user variables: virtualisation
* Unknown user variables: root_volume_size

You must define a _variables_ block, see https://packer.io/docs/templates/user-variables.html

Sorry to comment on such an old item, but that would mean this documentation is wrong (under "From a File" as it does not show the "variables" section in the sample JSON: https://www.packer.io/docs/templates/user-variables.html

@DarwinJS the vars file _shouldn't_ have a variables map but the _template_ file must and that was what was missing. Post on the mail-list if you need help with using var files. If you think there is a error in the docs please open a issue and describe in details what is wrong or unclear.

I understand now - your comment to the original poster was not clear which file the block should go in.

It was also not clear me how the main packer file and the variable file should be formatted.
Thanks for the comments. Below a gist as an example with a working file syntax.
https://gist.github.com/kral2/7c3151d9d82f0481dc6ad444cf453595

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