Packer seems to be ignoring my -var-file

95 views
Skip to first unread message

DarwinJS

unread,
Aug 10, 2016, 2:03:45 PM8/10/16
to Packer

I have this in "variables" in my main template.
"variables": {
      "Build_with_ami": "",
}


I have this in "builders" of my main template: 
"type": "amazon-ebs",
"source_ami": "{{user `Build_with_ami`}}",


If I use packer -var 'Build_with_ami=ami-whatever' it works fine.

If, however, I put this in a varfile:

{
  "build_with_ami": "ami-whatever",
 }

and use -var-file 'variablefile.json'

Packer errors saying I must specify source_ami.

I have also tried using "source_ami" directly.

I have also tried removing it from the variables section in the template (but retaining the variables section itself.

I have tried -var-file='variablefile.json'

FYI -var-file=variablefile.json has the extension stripped off it when executing under powershell.

The only way Build_with_ami is recognized is if I set it on the command line or directly in the template "variables" section.

The log file does not show variables nor where they are read from - would be nice for debugging this.

All of the above is under PowerShell 5.0

Rickard von Essen

unread,
Aug 10, 2016, 3:12:27 PM8/10/16
to packe...@googlegroups.com
In your example you have two errors in:

{
  "build_with_ami": "ami-whatever",
}

1) Trailing , - that is invalid JSON formatting.
2) "build_with_ami" is without capital B and thus doesn't match "Build_with_ami".


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/28a6b81b-d87a-41c1-a9e7-c5ff8b46ee3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages