ansible-community / ansible-vault

:key: Ansible role for Hashicorp Vault
BSD 2-Clause "Simplified" License
363 stars 194 forks source link
ansible-role consul devops hacktoberfest hashicorp vagrant vault vault-enterprise vault-hsm vault-key vault-tls virtualbox

Vault

Build Status Average time to resolve an issue Percentage of issues still open

This Ansible role performs a basic Vault installation, including filesystem structure and example configuration.

It can also bootstrap a minimal development or evaluation server or HA Consul-backed cluster in a Vagrant and VirtualBox based environment. See README_VAGRANT.md and the associated Vagrantfile for more details about the developer mode setup.

Installation

Brian Shumates transferred this role to @ansible-community/hashicorp-tools. This role resides on GitHub pending fixing the integration with Ansible Galaxy. To install this role create a roles/requirements.yml file in your Ansible project folder with the following contents:

- src: https://github.com/ansible-community/ansible-vault.git
  name: ansible-community.ansible-vault
  scm: git
  version: master

You can use git tag in the version attribute. Also you can honor its legacy name: brianshumate.ansible-vault.

Requirements

This role requires Archlinux, AmazonLinux, FreeBSD, Debian or a RHEL based Linux distribution. It might work with other software versions, but does work with the following specific software and versions:

Sorry, there is no planned support at the moment for Windows.

Warning

By default, this role may restart vault service when played (when there's a configuration change, OS Packages installed/updated)

When there's no auto-unseal setup on your cluster, the restart may lead to a situation where all Vault instances will be sealed and your cluster will be down.

To avoid this situation, the service restart by the playbook can be disabled by using the vault_service_restart role variable.

Setting this vault_service_restart to false will disable the vault service restart by the playbook. You may have to restart the service manually to load any new configuration deployed.

Role Variables

The role defines variables in defaults/main.yml:

vault_listener_localhost_enable

vault_privileged_install

vault_version

vault_enterprise

vault_pkg

vault_enterprise_pkg

vault_zip_url

vault_checksum_file_url

vault_install_hashi_repo

vault_rhsm_repo_id

vault_rhsm_subscription_name

vault_install_remotely

vault_shasums

vault_enterprise_shasums

vault_bin_path

vault_config_path

vault_use_config_path

vault_plugin_path

vault_plugins_enable

vault_plugins_src_dir_remote

vault_plugins_src_dir_local

vault_plugins_src_dir_cleanup

vault_data_path

vault_log_path

vault_run_path

vault_harden_file_perms

vault_manage_user

vault_user

vault_group

vault_groups

vault_manage_group

vault_cluster_name

vault_datacenter

vault_ui

vault_service_restart

vault_service_reload

vault_start_pause_seconds

TCP Listener Variables

vault_tcp_listeners

Storage Backend Variables

vault_backend

vault_backend_tls_src_files

vault_backend_tls_certs_path

vault_backend_tls_private_path

vault_backend_tls_cert_file

vault_backend_tls_key_file

vault_backend_tls_ca_file

Raft Storage Backend

vault_raft_leader_tls_servername

vault_raft_group_name

vault_raft_cluster_members

vault_raft_data_path

vault_raft_node_id

vault_raft_performance_multiplier

vault_raft_trailing_logs

vault_raft_snapshot_threshold

vault_raft_max_entry_size

vault_raft_autopilot_reconcile_interval

vault_raft_cloud_auto_join

vault_raft_cloud_auto_join_exclusive

vault_raft_cloud_auto_join_scheme

vault_raft_cloud_auto_join_port

Consul Storage Backend

vault_backend_consul

vault_consul

vault_consul_scheme

vault_consul_path

vault_consul_service

vault_consul_token

etcd Storage Backend

vault_etcd

vault_etcd_api

vault_etcd_path

vault_etcd_discovery_srv

vault_etcd_discovery_srv_name

vault_etcd_ha_enabled

vault_etcd_sync

vault_etcd_username

vault_etcd_password

vault_etcd_request_timeout

vault_etcd_lock_timeout

File Storage Backend

vault_backend_file

Raft Integrated Storage Backend

vault_backend_raft

vault_raft_node_id

vault_raft_retry_join

leader_api_addr
leader_ca_cert_file
leader_client_cert_file
leader_client_key_file
leader_ca_cert
leader_client_cert
leader_client_key

DynamoDB Storage Backend

For additional documentation for the various options available, see the Vault documentation for the DynamoDB storage backend.

vault_dynamodb

vault_dynamodb_table

vault_dynamodb_ha_enabled

vault_dynamodb_max_parallel

vault_dynamodb_region

vault_dynamodb_read_capacity

vault_dynamodb_write_capacity

vault_dynamodb_access_key

vault_dynamodb_secret_key

vault_dynamodb_session_token

Google Cloud Storage Storage Backend

vault_gcs_bucket

vault_gcs_ha_enabled

vault_gcs_chunk_size

vault_gcs_max_parallel

vault_gcs_copy_sa

vault_gcs_credentials_src_file

vault_gcs_credentials_dst_file

Consul Service Registration

For additional information on the various options, see the Vault documentation for Consul service registration. Note that this is only available starting at Vault version 1.4.

vault_service_registration_consul_enable

vault_service_registration_consul_template

vault_service_registration_consul_address

vault_service_registration_check_timeout

vault_service_registration_disable_registration

vault_service_registration_consul_scheme

vault_service_registration_consul_service

vault_service_registration_consul_service_tags

vault_service_registration_consul_service_address

vault_service_registration_consul_token

vault_service_registration_consul_tls_certs_path

vault_service_registration_consul_tls_private_path

vault_service_registration_consul_tls_ca_file

vault_service_registration_consul_tls_cert_file

vault_service_registration_consul_tls_key_file

vault_service_registration_consul_tls_min_version

vault_service_registration_consul_tls_skip_verify

Kubernetes Service Registration

For additional information on the various options, see the Vault documentation for Kubernetes service registration. Note that this is only available starting at Vault version 1.4.

vault_service_registration_kubernetes_consul_enable

vault_service_registration_kubernetes_template

vault_service_registration_kubernetes_namespace

vault_service_registration_pod_name

vault_log_level

vault_iface

vault_address

vault_port

vault_max_lease_ttl

vault_default_lease_ttl

vault_main_config

vault_main_configuration_template

vault_custom_configuration

vault_http_proxy

vault_https_proxy

vault_no_proxy

vault_cluster_address

vault_cluster_addr

vault_api_addr

vault_disable_api_health_check

vault_cluster_disable

validate_certs_during_api_reachable_check

vault_proxy_protocol_behavior

vault_tls_certs_path

vault_tls_private_path

vault_tls_disable

vault_tls_gossip

vault_tls_src_files

vault_tls_ca_file

vault_tls_client_ca_file

vault_tls_cert_file

vault_tls_key_file

vault_tls_min_version

vault_tls_cipher_suites

vault_tls_require_and_verify_client_cert

vault_tls_disable_client_certs

vault_tls_copy_keys

vault_tls_files_remote_src

vault_x_forwarded_for_authorized_addrs

vault_bsdinit_template

vault_sysvinit_template

vault_debian_init_template

vault_systemd_template

vault_systemd_service_name

vault_telemetry_enabled

vault_unauthenticated_metrics_access

vault_telemetry_usage_gauge_period

OS Distribution Variables

The vault binary works on most Linux platforms and is not distribution specific. However, some distributions require installation of specific OS packages with different naming, so this role was built with support for popular Linux distributions and defines these variables to deal with the differences across distributions:

vault_pkg

vault_centos_url

vault_centos_os_packages

vault_pkg

vault_debian_url

vault_sha256

vault_debian_os_packages

vault_pkg

vault_redhat_url

vault_sha256

vault_redhat_os_packages

vault_pkg

vault_ubuntu_url

vault_sha256

vault_enable_log

vault_enable_logrotate

vault_logrotate_freq

vault_logrotate_template

vault_ubuntu_os_packages

Dependencies

NOTE: Read these before executing the role to avoid certain frequently encountered issues which are resolved by installing the correct dependencies.

gtar

Ansible requires GNU tar and this role performs some local use of the unarchive module, so ensure that your system has gtar installed.

Python netaddr

The role depends on python-netaddr so:

pip install netaddr

on the Ansible control host prior to executing the role.

Example Playbook

Basic installation is possible using the included site.yml playbook:

ansible-playbook -i hosts site.yml

You can also pass variables in using the --extra-vars option to the ansible-playbook command:

ansible-playbook -i hosts site.yml --extra-vars "vault_datacenter=maui"

Specify a template file with a different backend definition (see templates/backend_consul.j2):

ansible-playbook -i hosts site.yml --extra-vars "vault_backend_file=backend_file.j2"

You need to make sure that the template file backend_file.j2 is in the role directory for this to work.

Vagrant and VirtualBox

See examples/README_VAGRANT.md for details on quick Vagrant deployments under VirtualBox for testing, etc.

example virtualBox playbook

example playbook for a file based vault instance.

- hosts: all
  gather_facts: True
  become: true
  vars:
    vault_backend: file
    vault_cluster_disable: True
    vault_log_level: debug
  roles:
    - vault

Vault Enterprise

The role can install Vault Enterprise based instances.

Place the Vault Enterprise zip archive into {{ role_path }}/files and set vault_enterprise: true or use the VAULT_ENTERPRISE="true" environment variable. Attempts to download the package from vault_zip_url if zip is not found in files/.

vault_enterprise_premium

Vault Enterprise with HSM

The role can configure HSM based instances. Make sure to reference the HSM support page and take notice of the behavior changes after HSM is installed.

vault_enterprise_premium_hsm

vault_configure_enterprise_license

vault_license_path

vault_license_file

vault_hsm_app

vault_backend_seal

NOTE: This seal will be migrated to the pkcs11 seal and made consistent with the other seal types with respect to breaking naming changes soon.

vault_seal_lib

vault_seal_pin

vault_seal_key_label

vault_seal_hmac_key_label

vault_seal_generate_key

vault_seal_key_mechanism

vault_seal_token_label

vault_softcard_enable

vault_seal_slot

vault_entropy_seal

The following stanza will be included in the hcl main configuration file if vault_entropy_seal=true:

entropy "seal" {
  mode = "augmentation"
}

Vault GCP Cloud KMS Auto-unseal

This feature enables operators to delegate the unsealing process to Google Key Management System Cloud to ease operations in the event of partial failure and to aid in the creation of new or ephemeral clusters.

This Auto-unseal mechanism is Open Source in Vault 1.0 but would require Enterprise binaries for any earlier version.

vault_gkms

vault_backend_gkms

vault_gkms_project

vault_gkms_copy_sa

vault_gkms_credentials_src_file

vault_gkms_credentials_content

vault_gkms_credentials

vault_gkms_region

vault_gkms_key_ring

vault_gkms_crypto_key

Vault OCI KMS Auto-unseal

This feature enabled operators to delegate the unsealing process to OCI KMS to ease operations in the event of a partial failure and to aid in the creation of new or ephemeral clusters.

vault_ocikms

vault_ocikms_backend

vault_ocikms_auth_type_api_key

vault_ocikms_key_id

vault_ocikms_crypto_endpoint

vault_ocikms_management_endpoint

Vault Transit Auto-unseal

This enables Vault to use another Vault instance for the unseal process using its transit secret engine

vault_transit

vault_transit_backend

vault_transit_config:

vault_transit_address:

vault_transit_token:

vault_transit_disable_renewal:

vault_transit_key_name

vault_transit_mount_path:

vault_transit_namespace:

vault_transit_tls_ca_cert:

vault_transit_tls_client_cert:

vault_transit_tls_client_key:

vault_transit_tls_server_name

vault_transit_tls_skip_verify:

Vault AWS KMS Auto-unseal

This feature enabled operators to delegate the unsealing process to AWS KMS to ease operations in the event of a partial failure and to aid in the creation of new or ephemeral clusters.

vault_awskms

vault_awskms_backend

vault_awskms_region

vault_awskms_access_key

vault_awskms_secret_key

vault_awskms_key_id

vault_awskms_endpoint

Vault Azure Key Vault Auto-unseal

This feature enabled operators to delegate the unsealing process to AZURE Key Vaultto ease operations in the event of a partial failure and to aid in the creation of new or ephemeral clusters.

vault_azurekeyvault

vault_backend_azurekeyvault

vault_azurekeyvault_client_id

vault_azurekeyvault_client_secret

vault_azurekeyvault_tenant_id

vault_azurekeyvault_vault_name

vault_azurekeyvault_key_name

Vault plugins

acme plugin

Installs vault-acme plugin, also enables the plugin if authenticated against vault (VAULT_ADDR, VAULT_TOKEN env).

vault_plugin_acme_install

vault_plugin_acme_sidecar_install

vault_plugin_acme_version

License

BSD-2-Clause

Author Information

Brian Shumate

Contributors

Special thanks to the folks listed in CONTRIBUTORS.md for their contributions to this project.