Re: [packer] How to declare paths in execute_command

12 views
Skip to first unread message

Megan Marsh

unread,
Mar 14, 2019, 12:24:02 PM3/14/19
to packe...@googlegroups.com
The env_var_file described in the docs won't do what you want. It is created by Packer from the env vars that you supply to environment_vars. 

It's just writing the environment vars to a file and dot-sourcing that file, rather than declaring the variables inline. It's intended to help people work around difficulties escaping special characters.

You can't currently modify it to add your own vars separately from what you add to environment_vars.

Your best bet is to use the file provisioner to upload your own var file and then either dot-source it from within your shell script or dot-source it in the execute_command. For example, maybe you can change the execute_command to: 

"execute_command": "chmod +x {{ .Path }}; . tmp/.myenvvarfile sudo {{ .Path }}",

Where you previously uploaded .myenvvarfile to tmp.

(Note, I haven't tested this but in theory it should work)
Reply all
Reply to author
Forward
0 new messages