如何在 Ansible Playbook 中使用 "become_pass"
How to use "become_pass" in an Ansible Playbook
我尝试编写一个 Ansible yml,它从加密的保管库文件中读取根密码,然后将其传递给 become_pass:
- hosts: sirius
remote_user: ansusr
become: yes
vars_files:
- vault_vars.yml
become_pass: "{{ root_pass_sirius }}"
</pre>
但这失败了:
错误! '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 }}"
我尝试编写一个 Ansible yml,它从加密的保管库文件中读取根密码,然后将其传递给 become_pass:
- hosts: sirius remote_user: ansusr become: yes vars_files: - vault_vars.yml become_pass: "{{ root_pass_sirius }}" </pre>
但这失败了: 错误! '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 }}"