>_ IzzyLab

Hands-on task

This task is step 9 of the course “Terraform and Ansible”

Ansible: encrypt vault secrets

medium~7 min

The file /root/secrets.yml with passwords is stored in plaintext. Encrypt it with ansible-vault using the password izzy (in place — the file stays at /root/secrets.yml, but becomes encrypted).

What you'll practise:
  • ansible-vault
  • encrypting secrets
  • encrypt
  • vault-password-file

Topic breakdown

ansible-vault encrypts files with secrets so they can be stored safely in a repository: an encrypted file starts with the $ANSIBLE_VAULT header and can't be read without the password. In-place encryption of an existing file is done by the encrypt subcommand, which replaces the contents with an encrypted block. Instead of typing the password by hand, you can put it in a separate file and feed it in with the --vault-password-file flag — handy for automation.

What's checked

  1. /root/secrets.yml is encrypted with ansible-vault
  2. decrypts with the password izzy back to the original data

What it looks like