Interview Prep/Ansible/Vault, Performance and Execution Behaviour

`ERROR! Decryption failed (no vault secrets were found that could decrypt) on inventories/prod/group_vars/all/vault.yml`

BeginnerTroubleshootingVault, Performance and Execution Behaviour
Answer

Likely causes → A password was supplied but it is the wrong one, for example the staging password used for a prod file. Another cause is a password file with a trailing newline or extra characters. Ansible strips one trailing newline, but not \r\n from Windows editors.

Diagnose →

head -1 inventories/prod/group_vars/all/vault.yml   # $ANSIBLE_VAULT;1.2;AES256;prod
ansible-vault view --vault-id prod@prompt inventories/prod/group_vars/all/vault.yml
od -c ~/.secrets/prod.pass | tail -2               # look for \r

Fix → Use the correct password for that environment, and remove the stray \r with dos2unix.

Prevent → Use one vault ID per environment, with IDs that match the inventory directories.

All Ansible questions Roadmap: Ansible

More on Vault, Performance and Execution Behaviour