I've been trying to figure out the possibility of using option vars in packer, my script is as follows:
"provisioners": [{
"type": "shell",
"scripts": [
"scripts/centos/5.11/puppet-{{user `config`}}.sh",
]
}],
"variables": {
"config": "{{user `type`}} | slave",
}
Were a typical command would be:
packer build \
-var 'config=master' \
template.json
But also be able to just do the following:
packer build template.json # were config would default to slave
Command line variables override settings in your json templates. See Packer's documentation: https://www.packer.io/docs/templates/user-variables.html
So just set the default value in the template and override with the command line example you were already using.
Your template would be:
"provisioners": [{
"type": "shell",
"scripts": [
"scripts/centos/5.11/puppet-{{user `config`}}.sh"
]
}],
"variables": {
"config": "slave"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With