All Projects → jhaals → Ansible Vault

jhaals / Ansible Vault

Licence: bsd-3-clause
ansible lookup plugin for secrets stored in Vault(by HashiCorp)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ansible Vault

Tks
Enable enthusiasts and administrators alike to easily provision highly available and production-ready Kubernetes clusters on Proxmox VE.
Stars: ✭ 319 (-4.78%)
Mutual labels:  ansible, vault
Ops Cli
Ops - cli wrapper for Terraform, Ansible, Helmfile and SSH for cloud automation
Stars: ✭ 152 (-54.63%)
Mutual labels:  ansible, vault
Baize
白泽自动化运维系统:配置管理、网络探测、资产管理、业务管理、CMDB、CD、DevOps、作业编排、任务编排等功能,未来将添加监控、报警、日志分析、大数据分析等部分内容
Stars: ✭ 296 (-11.64%)
Mutual labels:  ansible
Ansible Consul
📡 Ansible role for Hashicorp Consul clusters
Stars: ✭ 320 (-4.48%)
Mutual labels:  ansible
Ansible Role Postgresql
Ansible Role - PostgreSQL
Stars: ✭ 310 (-7.46%)
Mutual labels:  ansible
Rundeck Ansible Plugin
Ansible Integration for Rundeck
Stars: ✭ 297 (-11.34%)
Mutual labels:  ansible
T Vault
Simplified secrets management solution
Stars: ✭ 316 (-5.67%)
Mutual labels:  vault
Awx Container
Ansible Container project that manages the lifecycle of AWX on Docker.
Stars: ✭ 294 (-12.24%)
Mutual labels:  ansible
Kubeoperator
KubeOperator 是一个开源的轻量级 Kubernetes 发行版,专注于帮助企业规划、部署和运营生产级别的 K8s 集群。
Stars: ✭ 4,147 (+1137.91%)
Mutual labels:  ansible
Home Cluster
My home Kubernetes (k3s) cluster managed by GitOps (Flux2)
Stars: ✭ 303 (-9.55%)
Mutual labels:  ansible
Applocker
🔐 Open source app locker, vault, call blocker application
Stars: ✭ 321 (-4.18%)
Mutual labels:  vault
F5 Ansible
Ansible modules that can manipulate F5 products
Stars: ✭ 308 (-8.06%)
Mutual labels:  ansible
Elasticluster
Create clusters of VMs on the cloud and configure them with Ansible.
Stars: ✭ 298 (-11.04%)
Mutual labels:  ansible
Ansible Rails
Ansible: Ruby on Rails Server
Stars: ✭ 317 (-5.37%)
Mutual labels:  ansible
Molecule
Molecule aids in the development and testing of Ansible roles
Stars: ✭ 3,262 (+873.73%)
Mutual labels:  ansible
Ansible Role Nodejs
Ansible Role - Node.js
Stars: ✭ 322 (-3.88%)
Mutual labels:  ansible
Postgresql cluster
PostgreSQL High-Availability Cluster (based on "Patroni" and "DCS(etcd)"). Automating deployment with Ansible.
Stars: ✭ 294 (-12.24%)
Mutual labels:  ansible
Sup3rs3cretmes5age
Simple to use, simple to deploy, one time self destruct messaging service, with hashicorp vault as a backend
Stars: ✭ 313 (-6.57%)
Mutual labels:  vault
Dotfiles
Sway acid dark
Stars: ✭ 330 (-1.49%)
Mutual labels:  ansible
Cryptr
Cryptr: a GUI for Hashicorp's Vault
Stars: ✭ 324 (-3.28%)
Mutual labels:  vault

ansible-vault lookup module Build Status

This is a lookup module for secrets stored in HashiCorp Vault. Supports Ansible 1.9.x and 2.x

Deprecation notice

ansible-vault has been deprecated due to lack of personal usage of ansible and vault over the last years. There are other plugins such as hashivault which provide the same functionality and are better maintained.

Installation

lookup plugins can be loaded from several different locations similar to $PATH, see lookup_plugins. An example setup can be found in the tests directory.

The source for the plugin can be pointed to via a requirements.yml file, and accessed via ansible-galaxy.

Configuration

The address to the Vault server:

export VAULT_ADDR=http://192.168.33.10:8200/

The plugin supports both Vault auth token and GitHub auth token. To use Vault auth token:

export VAULT_TOKEN=56f48aef-8ad3-a0c4-447b-8e96990776ff

If your Vault server is configured to use GitHub auth token:

export VAULT_GITHUB_API_TOKEN=56f48aef-8ad3-a0c4-447b-8e96990776ff

The plugin also supports Vault's CA-related environment variables, to enable use of a server certificate issued by a not-widely-trusted Certificate Authority. Use of this feature in the plugin requires Python 2.7.9.

export VAULT_CACERT=/etc/ssl/certs/localCA.pem
export VAULT_CAPATH=/etc/ssl/localCA

The Vault address, CA certificate, and path can also be set via the Ansible variables vault_addr, vault_cacert, and vault_capath, respectively.

export VAULT_CAHOSTVERIFY="no"

This avoid the hostname check for Vault certificate (useful with self-signed certicates). This option can also be set via the Ansible variable vault_cahostverify.

export VAULT_SKIP_VERIFY=1

This will disable ssl certs validation. VAULT_CACERT, VAULT_CAPATH and VAULT_CAHOSTVERIFY have to be unset. Can also be set via Ansible variable vault_skip_verify: <bool>.

For more information on setting variables in Ansible, see the variables docs.

The Vault token intentionally can not be set via an Ansible variable, as this is generally checked into revision control and would be a bad security practice somewhat defeating the purpose of using Vault. The token can be read from the file $HOME/.vault-token, as documented at Vault environment variables.

If any such parameter is set by both an environment variable and an alternative means, the environment variable takes precedence.

Caching

By default secrets fetched from Vault will be cached in memory, unless you specify

export ANSIBLE_HASHICORP_VAULT_USE_CACHE=no

Note that secrets will be fetched once per fork (defaults to 5). If you turn off this feature by toggling above variable, all lookups will be done per node instead.

Approle support

If you want to use the Approle auth backend, you can do this by setting the follwing environment variables. If those vars are set, it is tried to get an approle token. If caching is enabled, the token is stored in the cache, so that it can be reused.

export ANSIBLE_HASHICORP_VAULT_ROLE_ID=ba78195c-12c9-557f-f8e2-75705b9b52ec
export ANSIBLE_HASHICORP_VAULT_SECRET_ID=5a4d079b-e6aa-ad54-8b0c-09dd35b740ee

Per default the authentication will be done against ${YOUR_HOST}/v1/auth/approle/login You can change this to fit your layout by setting the following var to your value:

export ANSIBLE_HASHICORP_VAULT_ROLE_PATH=v1/auth/my/role/path/approle/login

Usage

ansible-vault works as any other lookup plugin.

- debug: msg="{{ lookup('vault', 'secret/foo', 'value') }}"
# templates/example.j2

# Generic secrets
{{ lookup('vault', 'secret/hello').value }} # world
# Generic secrets with parameters
{{ lookup('vault', 'pki/issue/example-dot-com common_name=foo.example.com format=pem_bundle').certificate }}
# Specify field inside lookup
{{ lookup('vault', 'secret/hello', 'value') }} # world
# This syntax for Ansible 1.9.x
{{ lookup('vault', ['secret/hello', 'value']) }} # world

# Dynamic secrets
{% set aws = lookup('vault', 'aws/creds/deploy') %}
access_key = {{ aws.access_key }} # AKSCAIZSFSYHFGA
secret_key = {{ aws.secret_key }} # 4XSLxDUS+hyXgoIHEhCKExHDGAJDHFiUA/adi

If the desired value is stored within Vault with the key 'value' (like 'value=world' shown above), within a task, the lookup can be performed with:

with_vault:
- secret/hello

And then referenced with "{{ item.value }}"

Alternatively, the lookup can be performed with:

with_vault:
- secret/hello
- value

And then referenced with "{{ item }}"

Both of these forms work with both Ansible 1.9.x and 2.x. They only work within tasks, though. You can not use the with_vault: syntax within a variable definition file.

Troubleshooting

If you use the version of Ansible shipped with Ubuntu 16.04 (2.0.0.2-2ubuntu1) and get the error Error was sequence item 0: expected string, dict found then you should install Ansible from the PPA instead. Related to this Ansible PR

What's the difference between ansible-vault and hashi_vault

  • (Ansible Vault) No external dependencies; (hashi_vault) requires hvac
  • (Ansible Vault) Uses the same environment variables as vault itself
  • (Ansible Vault) Quicker update cycle
  • (Ansible Vault) Supports dynamic secrets
  • (Ansible Vault) Supports custom fields
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].