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
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.