When we are dealing with sensitive material that we need to reference in our Ansible playbooks, such as passwords, we shouldn't save this data in plain text. Ansible Vault provides a method to encrypt this data and therefore be safely decrypted and accessed while the playbook is running. In this recipe, we will outline how to use Ansible Vault in order to secure sensitive information in Ansible.
Securing secrets with Ansible Vault
How to do it...
- Create a new file called decrypt_passwd as shown:
$ echo 'strong_password' > decrypt_passwd
- Using ansible-vault creates a new file called secrets, as shown here:
$ ansible-vault create --vault-id=decrypt_passwd secrets
- Add the following variables to this new...