我一直在尝试找出在打包器中使用选项 vars 的可能性,我的脚本如下:
"provisioners": [{
"type": "shell",
"scripts": [
"scripts/centos/5.11/puppet-{{user `config`}}.sh",
]
}],
"variables": {
"config": "{{user `type`}} | slave",
}
一个典型的命令是:
packer build \
-var 'config=master' \
template.json
但也可以执行以下操作:
packer build template.json # were config would default to slave