I am trying to use Ansible vault encrypted password in my playbook and don’t see clear documentation on how to use it.
Here is what I did so far -
In ansible.cfg I have set the ‘vault_password_file’.
I have all my playbooks in a directory called devplaybooks. I have created a sub-directory in devplaybooks directory with name ‘vault’ and executed following command
ansible-vault create passwords
Contents in passwords file : ansible_password= secret123
I am trying to maintain password (encrypted using ansible-vault) and my playbook (clear-text) in separate files. If I understand correctly the below URL is suggesting to encrypt the password string and copy the same in my playbook.
I am trying to maintain password (encrypted using ansible-vault) and my playbook (clear-text) in separate files. If I
understand correctly the below URL is suggesting to encrypt the password string and copy the same in my playbook.
1) Let's assume the vault password has bee configured properly (you have set
the 'vault_password_file' in ansible.cfg) . Let's use global variable here.
For example
$ set | grep VAULT
ANSIBLE_VAULT_PASSWORD_FILE=/home/admin/.vault_pass.txt
Ok, I found the solution myself. Group or host variables should have different directory. There is no need of explicit mention such as in the playbook, but create a directory called group_vars or host_vars in the directory where the playbook is placed.
these directories will have files with variables you want to define. File structure should be in yml format.