是否有一种在包装商配置器中添加条件的明智方法?有什么影响:
$ packer build -var "debug=true" build.json
"provisioners": [{
"type": "puppet-masterless",
"execute_command": "{{ if eq `debug` "true" }} strace {{ end }} {{ .FacterVars }} puppet apply --verbose --detailed-exitcodes --modulepath='/tmp/manifests/modules' {{ .ManifestFile }}",
"facter": {},
"manifest_dir": "../manifests",
"manifest_file": "../manifests/vagrant/nocm.pp",
"module_paths": [
"../manifests/modules/external"
]
}],
"variables": {
"debug": "false",
}
执行命令包含
{{ if eq `debug` "true" }} strace {{ end }}
答案 0 :(得分:2)
您是否尝试在provisioner
部分添加变量:
注意:我自己没有测试,但将其用于普通的shell配置程序
"provisioners": [{
"environment_vars": [
"DEBUG={{user `debug`}}",
]
"type": "puppet-masterless",
"execute_command": "{{ if eq .DEBUG "true" }} strace {{ end }} {{ .FacterVars }} puppet apply --verbose --detailed-exitcodes --modulepath='/tmp/manifests/modules' {{ .ManifestFile }}",
"facter": {},
"manifest_dir": "../manifests",
"manifest_file": "../manifests/vagrant/nocm.pp",
"module_paths": [
"../manifests/modules/external"
]
}],
"variables": {
"debug": "false",
}