ansible-vault
Encrypt and decrypt sensitive data
TLDR
SYNOPSIS
ansible-vault command [--vault-password-file file] [options] files
DESCRIPTION
ansible-vault encrypts sensitive data like passwords, keys, and credentials within Ansible projects. It uses AES256 encryption to protect files while allowing them to be used directly in playbooks.Encrypted files can be edited, viewed, and used in playbooks without manual decryption; ansible-playbook handles decryption automatically when provided with the vault password.
PARAMETERS
create file
Create new encrypted fileencrypt files
Encrypt existing filesdecrypt files
Decrypt filesedit file
Edit encrypted file in placeview file
View encrypted file contentsencrypt_string string
Encrypt a string for embedding in a playbook or vars filerekey files
Re-encrypt files with a new password--vault-password-file file
File containing the vault password--vault-id label@source
Vault identity to use (label plus password source)-J, --ask-vault-pass
Prompt for the vault password-n name, --name name
Variable name to assign (encrypt_string only)--encrypt-vault-id id
Vault id to use when encrypting (when several are provided)--output file
Write output to the named file instead of stdout--new-vault-password-file file
Password file holding the new password for rekey--new-vault-id id
Vault id holding the new password for rekey
CONFIGURATION
/etc/ansible/ansible.cfg
System-wide Ansible configuration, including vault password file path and vault identity settings.~/.ansible.cfg
Per-user Ansible configuration overriding system defaults.ansible.cfg
Project-level configuration in the current directory, highest priority.
CAVEATS
Vault password must be available during playbook runs. Encrypted files should be committed to version control, not the password. Use vault-id for multiple passwords.
HISTORY
ansible-vault was introduced in Ansible 1.5 (2014) to address the need for secure handling of sensitive data in automation. Multiple vault passwords support was added in Ansible 2.4.
SEE ALSO
ansible-playbook(1), ansible(1), gpg(1)