Executing ansible-playbook with encrypted files
To make use of our encrypted content, we first need to be able to inform ansible-playbook
of how to access any encrypted data it might encounter. Unlike ansible-vault
, which exists solely to deal with file encryption or decryption, ansible-playbook
is more general-purpose, and it will not assume it is dealing with encrypted data by default. Fortunately, all of our familiar --vault-id
parameters from the previous examples work just the same in ansible-playbook
as they do in ansible-vault
. Ansible will hold the provided passwords and IDs in memory for the duration of the playbook execution.
Let's now create a simple playbook named show_me.yaml
that will print out the value of the variable inside of a_vars_file.yaml
, which we encrypted in a previous example, as follows:
--- - name: show me an encrypted var hosts: localhost gather_facts: false vars_files: - a_vars_file...