Stuck with the Ansible Error: Decryption Failed? We can help you.
It frustrates us to get an error when we try to run an ansible-playbook.
As part of our Server Management Services, we assist our customers with several Ansible queries.
Today, let us see how we can fix this error.
Ansible Error: Decryption Failed
Recently, we had a customer who came across the following error:
fatal: [server1.lab.com]: FAILED! => {“msg”: “Decryption failed (no vault secrets were found that could decrypt) on /home/bobcares/ansible/encrypted_data.txt”}
fatal: [server1.lab.com]: FAILED! => {“msg”: “A vault password or secret must be specified to decrypt /home/bobcares/ansible/Bobcares/encrypted_data.txt”}
With Ansible Vault, we can encrypt files rather than leaving them visible as plaintext in playbooks.
Generally, we use it on sensitive information like passwords, SSL private keys, etc.
By default, to encrypt data, the Ansible vault uses the AES256 algorithm.
File before encryption :
$> cat encrypted_data.txt This is an encrypted data
Encryption using Ansible Vault :
$ ansible-vault encrypt encrypted_data.txt
New Vault password:
Confirm New Vault password:
Encryption successful
After Encryption :
$ > cat encrypted_data.txt
$ANSIBLE_VAULT;1.1;AES256
30613332366266623564636132643536646265316132636439326535613939333061376337666433
3831313731303866643765313962323065346565613937650a396162373436306363383934643464
32393037346666303036306365396139383832383632373235323432666638366335623163363539
3530363234656536620a356138366536643164353462613138333664363134303533326566636232
32623530373362396231613230653939393865323639633966616530346261653863
Now it is safe to include as a parameter in the ansible-playbook.
In addition, we need to provide a decryption password when we run the ansible-playbook which contains a file encrypted with ansible vault.
Cause and Fix to the error
Moving ahead, let us see the cause and how our Support Techs fix this error.
Generally, we come across this error because the decryption password we provide to ansible is incorrect.
For example, consider a playbook for the encrypted_data.txt file which we used ansible vault to encrypt and copy over to a target machine after decryption.
vault.yml :
– hosts: server1.lab.com
tasks:
– name: Copying Encrypted file to target machine and decrypting
copy:
src: encrypted_data.txt
dest: /home/decrypted_data.txt
If we try to run the playbook directly like this:
ansible-playbook vault.yml
This will eventually end up in an error.
So, we have to provide the decryption password to the playbook, either as a prompt to the terminal or as a vault file.
ansible-playbook vault.yml –ask-vault-pass ## To prompt for vault password
ansible-playbook vault.yml –vault-password-file /home/bobcares/private/vault_pass.txt ## To automatically read the vault password
We use a convenient way to pass the vault password. The error disappears once we provide the correct password to the ansible controller.
[Need help with the fix? We’d be happy to assist]
Conclusion
To conclude, an incorrect decryption password can lead us to this error. Today, we saw how our Support Techs fix this error for our customers.
0 Comments