Encrypt a variable with Vault
Encrypt one string so you can paste it straight into vars
ansible-vault encrypt_string 'mysecretpassword' --name 'db_password'
- tool
- ansible56 commands
More ansible commands
-
ansible-playbook deploy.yml -i inventory.ini --limit 'web01,web02'Run the playbook only on web01 and web02
-
ansible-playbook site.yml -i inventory.ini --stepConfirm each task before it runs; useful for debugging
-
ansible-vault rekey vault.yml --new-vault-password-file new_pass.txtRe-encrypt a vault file with a new password without exposing the plaintext; a safe way to rotate the vault password
-
ansible-playbook site.yml --vault-id dev@dev_pass.txt --vault-id prod@promptMix vault IDs: a password file for dev and a prompt for prod, so each environment has its own secrets
-
EDITOR=vim ansible-vault edit group_vars/prod/secrets.yml --vault-password-file ~/.vault_passDecrypt, edit in $EDITOR and encrypt again in one step; the decrypted temp file is removed when you close the editor