星期五的时候,我一直在努力将 Ansible 命令行转换为 Packer .json 所需的格式。Ansible:
ansible-playbook playbook.yml -e @env/users/user01.yml --ask-vault --ask-become
我尝试的 Packer 阻止:
"provisioners": [
{
"ansible_env_vars": ["ANSIBLE_HOST_KEY_CHECKING=False"],
"playbook_file": "{{ template_dir }}/../path/playbook.yml",
"type": "ansible",
"user": "{{ user `ssh_username` }}",
"extra_arguments": ["--extra-vars", "@env", "../path/env/users/user01.yml", "desktop=false", "--vault-password-file", "../vaultpass"]
}
],
我尝试了各种 key=value 组合(如文档所述)而不是单独的"thing",
块,但看起来 Ansible 试图将所有内容读取为一个大参数--extra-vars
(而我认为至少--vault-password-file
应该是分开的?)。
答案1
好的"extra_arguments": ["--extra-vars", "@../path/env/users/user01.yml", "-e", "desktop=false", "--vault-password-file", "../vaultpass"]
,成功了。