Skip to content

Instantly share code, notes, and snippets.

@shreddedbacon
Forked from shawnsi/README.md
Created August 10, 2019 06:26
Show Gist options
  • Select an option

  • Save shreddedbacon/701b4200419e1ab67c321f29a8cae3b7 to your computer and use it in GitHub Desktop.

Select an option

Save shreddedbacon/701b4200419e1ab67c321f29a8cae3b7 to your computer and use it in GitHub Desktop.
Ansible Vault Environment Variable

Ansible Vault Environment Variable

Per http://docs.ansible.com/ansible/playbooks_vault.html you can set an environment variable to use a password file for vault access. We can use this to create an environment variable to hold the password.

Password Script

Copy vault-env from this project to ~/bin. Then add this to your ~/.bashrc:

export ANSIBLE_VAULT_PASSWORD_FILE=~/bin/vault-env

Usage

Now just export your password in your shell as needed. Don't be a douche and put this in your profile though.

export ANSIBLE_VAULT_PASSWORD=<password>
#!/bin/bash
echo $ANSIBLE_VAULT_PASSWORD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment