I have the following playbook:
---
- hosts: all
vars_files:
- files/test1/.env
- files/test2/.env
- files/test3/.env
roles:
- role: test1
- role: test2
- role: test3
All those .env
files are encrypted using different password using ansible-vault
. To decrypt them when copied to the remote host, I want to provide the passwords using a passfile. For that, I have a .passfile
with the following content:
pass1
pass2
pass3
Each of those passwords are ordered in a way that match the order of vars_files
in the playbook. When I want to check that decryption happens properly I run ansible-vault view files/test1/.env --vault-pass-file .passfile
but I get the following error: ERROR! Decryption failed (no vault secrets were found that could decrypt) on files/test1/.env for files/test1/.env
When I remove passwords pass2
and pass3
from .passfile
, then the exact same command works and I can view the contents of the file. Same happens when I execute the playbook. If there's only one password in the .passfile
, it fails that it cannot decrypt files/test2/.env
but when I add pass2
in the .passfile
then it fails saying it could not decrypt files/test1/.env
.
How can I make Ansible decrypt all those files that have been encrypted using different passwords by just using one passfile
? Thanks in advance.
P.S.: the passfile
was created with vim
, ensuring there are no extra lines, whitespaces etc... passwords do contain special characters, tho.