2025-03-14 21:59:59 -06:00
|
|
|
# ansible-vault
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
> Encrypt and decrypt values, data structures, and files within Ansible projects.
|
|
|
|
|
> More information: <https://docs.ansible.com/projects/ansible/latest/vault_guide/index.html>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Create a new encrypted vault file with a prompt for a password:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`ansible-vault create {{path/to/vault_file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
- Edit, view or re-key (re-encrypt) an existing encrypted vault file with a prompt for the password:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`ansible-vault {{edit|view|rekey}} {{path/to/vault_file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
- Create a new encrypted vault file using a password file to encrypt it:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`ansible-vault create --vault-password-file {{path/to/password_file}} {{path/to/vault_file}}`
|
|
|
|
|
|
|
|
|
|
- Encrypt an existing plaintext file in-place using a password file:
|
|
|
|
|
|
|
|
|
|
`ansible-vault encrypt --vault-password-file {{path/to/password_file}} {{path/to/file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Encrypt a string using Ansible's encrypted string format, displaying interactive prompts:
|
|
|
|
|
|
|
|
|
|
`ansible-vault encrypt_string`
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
- View an encrypted vault file by using a password file to decrypt:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`ansible-vault view --vault-password-file {{path/to/password_file}} {{path/to/vault_file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
- Re-key (re-encrypt) an already encrypted vault file with a new password file:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`ansible-vault rekey --vault-password-file {{path/to/old_password_file}} --new-vault-password-file {{path/to/new_password_file}} {{path/to/vault_file}}`
|