简体   繁体   中英

Ansible Vault Password in variable

Is there a way to access the vault password as a variable in an Ansible playbook? I am looking for something like this:

---

debug: var=ansible_vault_password

I ended up solving this by copying the local vault password file to the server. The task to do that looks like that:

- name: setup ansible vault password file
  copy:
    src: /path/to/local/vault_pass
    dest: /root/.vault_pass
    mode: 0600
    owner: root
    group: root

And then the root user will execute the ansible-pull command.

Try to save the password into a different file and use "vars_files" to include the password. Example:

In Password.yml:

ansible_vault_password: redhat

In Playbook.yml:

Host: xyz

vars_files: password.yml

tasks:

   debug:

       var: "{{ ansible_vault_password }}"

Try this and please let me know.

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