Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
Last active November 25, 2022 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barbietunnie/48056e477d04ea7cf3b4b4e980176266 to your computer and use it in GitHub Desktop.
Save barbietunnie/48056e477d04ea7cf3b4b4e980176266 to your computer and use it in GitHub Desktop.
Decrypt/Encrypt with Ansible vault

Decrypt/Encrypt with Ansible vault

Pre-requisites

Ensure that ansible has been installed

ansible --version

If ansible has not been installed, go ahead and install it:

pip install ansible

Encryption

ansible-vault encrypt --vault-password-file=<vault-password-file> <input-file>

For example,

ansible-vault encrypt --vault-password-file=vaultkey.txt myfile.txt

Decryption

ansible-vault decrypt --vault-password-file=<vault-password-file> <input-file>

For example,

# Decrypt the file, using the input file as the output destination
ansible-vault decrypt --vault-password-file=vaultkey.txt encoded-file.txt

# OR

# Decrypt the file, dumping the out to standard out
cat encoded-file.txt | ansible-vault decrypt --vault-password-file=vaultkey.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment