Skip to content

Instantly share code, notes, and snippets.

@kenorb
Created July 31, 2019 11:27
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 kenorb/dea25e154658fd09442d4591bf6f3897 to your computer and use it in GitHub Desktop.
Save kenorb/dea25e154658fd09442d4591bf6f3897 to your computer and use it in GitHub Desktop.
ansible-keyring
#!/usr/bin/env bash
#/
#/ Fetch Ansible vault password from GNOME keyring
#/
#/ How to configure:
#/ Set name of the VAULT_ID for the current Git repo: git config --local ansible.vault VAULT_ID
#/ Set password with GNOME keyring: keyring set ansible VAULT_ID
#/ Set environment variable ANSIBLE_VAULT_PASSWORD_FILE to the location of this file
set -eu
#
# Display usage of the script, which is a specially marked comment
#
usage() {
grep '^#/' <"$0" | cut -c 4-
}
DEFAULT_VAULT_ID=vault_password
VAULT_ID=$(git config --get ansible.vault || echo "${DEFAULT_VAULT_ID}")
/usr/bin/keyring get ansible "${VAULT_ID}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment