Skip to main content

Ansible Vars Plugin for Hashicorp Vault

Project description

Ansible Vars Plugin for Hashicorp Vault

An Ansible Vars Plugin for Hashicorp Vault to lookup credentials/secrets, injecting these into the playbook run (e.g. ansible_user, ansible_password, etc).

Use Hashicorp Vault like you would ansible-vault'ed group_vars, domain_vars [a new concept in this module!] and host_vars.

This module was originaly developed for the gostint project.

Prereqs

  • Ansible
  • You may need pip install urllib3
  • pip install hvac

Installation

sudo pip install hashivault-vars

Enable in Ansible

In ansible.cfg:

vars_plugins = /usr/local/lib/python2.7/dist-packages/hashivault_vars

Or, symlink from ansible's vars plugins folder to hashivault_vars.py, e.g.:

$ cd /usr/local/lib/python2.7/dist-packages/ansible/plugins/vars
$ sudo ln -s /usr/local/lib/python2.7/dist-packages/hashivault_vars/hashivault_vars.py .

On Alpine Linux:

pip install hvac hashivault-vars && \
ln -s /usr/lib/python2.7/site-packages/hashivault_vars/hashivault_vars.py \
  /usr/lib/python2.7/site-packages/ansible/plugins/vars

Vault Secret Paths

Root path in vault:

  • /secret/ansible/

Precendence (applied top to bottom, so last takes precendence):

  • Groups:

    • /secret/ansible/groups/all
    • /secret/ansible/groups/ungrouped
    • /secret/ansible/groups/your_inv_item_group
    • ...
  • Hosts/Domains:

    • /secret/ansible/{connection}/domains/com
    • /secret/ansible/{connection}/domains/example.com
    • /secret/ansible/{connection}/hosts/hosta.example.com

where {connection} is ansible_connection, e.g.: "ssh", "winrm", ... (this plugin attempts to make assumptions where ansible_connection is not set)

All values retrieved from these paths are mapped as ansible variables, e.g. ansible_user, ansible_password, etc.

The layered lookups are merged, with the last taking precendence over earlier lookups.

Lookups to the vault are cached for the run.

Developer Notes

Travis CI

Pull requests and merges to master trigger pylint and BATS tests.

Running BATS tests

in vagrant:

$ tests/test.sh

Enable Debugging

(danger, will reveal retrieved vault secrets in the ansible log)

Set environment variable HASHIVAULT_VARS_DEBUG=1.

Release to PyPi

From vagrant (pip prereqs are required), e.g.:

$ ./setup.py sdist bdist_wheel

Release from host:

$ twine upload dist/hashivault_vars-0.1.17*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hashivault_vars-0.1.20.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

hashivault_vars-0.1.20-py2-none-any.whl (6.4 kB view details)

Uploaded Python 2

File details

Details for the file hashivault_vars-0.1.20.tar.gz.

File metadata

  • Download URL: hashivault_vars-0.1.20.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15rc1

File hashes

Hashes for hashivault_vars-0.1.20.tar.gz
Algorithm Hash digest
SHA256 e65b7ae2cd82b1bfbcf64cc2616a746b012f6e6b751283a699bbc4401caeab05
MD5 cf5a52136efb1ae086e1623c35ce0162
BLAKE2b-256 4184c2c9dd2c70c160fefa069f2922961fa209615419203c6699e398495bc59e

See more details on using hashes here.

File details

Details for the file hashivault_vars-0.1.20-py2-none-any.whl.

File metadata

  • Download URL: hashivault_vars-0.1.20-py2-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15rc1

File hashes

Hashes for hashivault_vars-0.1.20-py2-none-any.whl
Algorithm Hash digest
SHA256 d04b91b3852ed96197c90760d46503c83b3556c3a08737a74c8220a78cb10eac
MD5 1168b199a637c0c3ca466343bfd4cdeb
BLAKE2b-256 f92f6a75d4f5bdd4390683e05caa7a99698cab10d61ba4c116c5c473caf3a4df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page