What are vault IDs and why use them?
AdvancedConceptVault, Privilege Escalation and Error Handling
Answer
A vault ID labels a vault password, so you can use different passwords per environment and supply several at once.
ansible-vault encrypt --encrypt-vault-id prod group_vars/prod/vault.yml
ansible-playbook site.yml \
--vault-id dev@~/.vault_dev \
--vault-id prod@prompt
The label is stored in the file header ($ANSIBLE_VAULT;1.2;AES256;prod). Ansible tries the matching ID first and then falls back to the other supplied passwords. It is not a security boundary on its own, but it lets a team give developers only the dev password while CI holds prod.
More on Vault, Privilege Escalation and Error Handling
What is Ansible Vault?BeginnerWhich `ansible-vault` commands do you use day to day?BeginnerHow do you supply the vault password when running a playbook?BeginnerWhat is `encrypt_string` and when is it better than encrypting a whole file?IntermediateHow is Vault data encrypted and what does the file look like?AdvancedHow do you rotate a vault password?Intermediate