Interview Prep/Ansible/Vault, Performance and Execution Behaviour

Vaulted variables are undefined, although the file decrypts fine with `ansible-vault view`

BeginnerTroubleshootingVault, Performance and Execution Behaviour
Answer

Likely causes → The vault file is not where Ansible loads variables from. It sits at group_vars/prod/secrets/vault.yml (too deep is fine), or at vars/vault.yml (never loaded automatically), or it is named after a group that does not exist.

Fix → Use the standard pattern:

inventories/prod/group_vars/all/vars.yml    # db_password: "{{ vault_db_password }}"
inventories/prod/group_vars/all/vault.yml   # vault_db_password: ...  (encrypted)

Or load it explicitly with vars_files.

Prevent → Use the vault_ prefix and indirection pattern, so grep can always find where a secret is used.

All Ansible questions Roadmap: Ansible

More on Vault, Performance and Execution Behaviour