简体   繁体   中英

How to use “become_pass” in an Ansible Playbook

I try to write an Ansible yml that reads the root-passwords from an encrypted vault-file and then pass it to become_pass:


    - hosts: sirius
      remote_user: ansusr
      become: yes
      vars_files:
         - vault_vars.yml
      become_pass: "{{ root_pass_sirius }}"
        

But this fails: ERROR! 'become_pass' is not a valid attribute for a Play

But why ? - According to the Ansible documentation this is a valid command.

According to the Ansible documentation this is a valid command.

Wrong. become_pass is not a valid attribute (and it is not a command after all) for a Play.

Please see List of Behavioral Inventory Parameters . There is ansible_become_pass variable.

So you need to set a variable:

- hosts: sirius
  remote_user: ansusr
  become: yes
  vars_files:
    - vault_vars.yml
  vars:
    ansible_become_pass: "{{ root_pass_sirius }}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM