我尝试编写一个 Ansible yml,它从加密的保险库文件中读取根密码,然后将其传递给 become_pass:
- hosts: sirius
remote_user: ansusr
become: yes
vars_files:
- vault_vars.yml
become_pass: "{{ root_pass_sirius }}"
但这失败了: 错误! 'become_pass' 不是 Play 的有效属性
但为什么呢? - 根据 Ansible 文档,这是一个有效的命令。
最佳答案
According to the Ansible documentation this is a valid command.
错了。 become_pass
不是 Play 的有效属性(毕竟它不是命令)。
请参阅List of Behavioral Inventory Parameters .有 ansible_become_pass
变量。
所以你需要设置一个变量:
- hosts: sirius
remote_user: ansusr
become: yes
vars_files:
- vault_vars.yml
vars:
ansible_become_pass: "{{ root_pass_sirius }}"
关于python - 如何在 Ansible Playbook 中使用 "become_pass",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49151299/