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.
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
.
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.
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.
The role defines variables in defaults/main.yml
:
vault_listener_localhost_enable
vault_privileged_install
vault_version
Version to install
VAULT_VERSION
environment variableDefault value: 1.5.5
vault_enterprise
VAULT_ENTERPRISE
environment variablevault_pkg
"vault_{{ vault_version }}_linux_amd64.zip"
vault_enterprise_pkg
"vault-enterprise_{{ vault_version }}_{{ vault_os }}_{{ vault_architecture }}.zip"
vault_zip_url
"https://releases.hashicorp.com/vault/{{ vault_version }}/vault_{{ vault_version }}_linux_amd64.zip"
vault_checksum_file_url
"https://releases.hashicorp.com/vault/{{ vault_version }}/vault_{{ vault_version}}_SHA256SUMS"
vault_install_hashi_repo
true
when installing Vault via HashiCorp Linux repository.
When set, you can also define vault_repository_key_url
and vault_repository_url
to override the default URL of the GPG key for the repository and the default URL of the
repository used.vault_rhsm_repo_id
vault_install_hashi_repo
is set to true
to enable repo install. And optionally also
the rhsm subscription name with vault_rhsm_subscription_name
.vault_rhsm_subscription_name
vault_install_hashi_repo
is set to true
to enable repo install. And also that
vault_rhsm_repo_id
is set.vault_install_remotely
true
will download Vault binary from each target instead of localhostvault_shasums
"vault_{{ vault_version }}_SHA256SUMS"
vault_enterprise_shasums
vault_checksum_file_url
if not present in files/"vault-enterprise_{{ vault_version }}_SHA256SUMS"
vault_bin_path
/usr/local/bin
vault_config_path
/etc/vault.d
vault_use_config_path
"{{ vault_config_path }}"
to configure vault instead of "{{ vault_main_config }}"
vault_plugin_path
/usr/local/lib/vault/plugins
vault_plugins_enable
tasks/plugins
to see supported plugins.)vault_plugins_enable: [ 'acme', 'example' ]
[]
vault_plugins_src_dir_remote
/usr/local/src/vault/plugins
vault_plugins_src_dir_local
{{ role_path }}/files/plugins
vault_plugins_src_dir_cleanup
false
vault_data_path
/var/vault
vault_log_path
/var/log/vault
vault_run_path
/var/run/vault
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
>0
will add a pause
time after the first Vault start.vault_tcp_listeners
vault_tcp_listeners:
- vault_address: '{{ vault_address }}'
vault_port: '{{ vault_port }}'
vault_cluster_address: '{{ vault_cluster_address }}'
# vault_proxy_protocol_behavior: '{{ vault_proxy_protocol_behavior }}'
# vault_proxy_protocol_authorized_addrs: '{{ vault_proxy_protocol_authorized_addrs }}'
vault_tls_disable: '{{ vault_tls_disable }}'
vault_tls_certs_path: '{{ vault_tls_certs_path }}'
vault_tls_private_path: '{{ vault_tls_private_path }}'
vault_tls_cert_file: '{{ vault_tls_cert_file }}'
vault_tls_key_file: '{{ vault_tls_key_file }}'
vault_tls_ca_file: '{{ vault_tls_ca_file }}'
vault_tls_min_version: '{{ vault_tls_min_version }}'
vault_tls_cipher_suites: '{{ vault_tls_cipher_suites }}'
vault_tls_require_and_verify_client_cert: '{{ vault_tls_require_and_verify_client_cert }}'
vault_tls_disable_client_certs: '{{ vault_tls_disable_client_certs }}'
# vault_x_forwarded_for_authorized_addrs: '{{ vault_x_forwarded_for_authorized_addrs }}'
# vault_x_forwarded_for_hop_skips: '{{ vault_x_forwarded_for_hop_skips }}'
# vault_x_forwarded_for_reject_not_authorized: '{{ vault_x_forwarded_for_reject_not_authorized }}'
# vault_x_forwarded_for_reject_not_present: '{{ vault_x_forwarded_for_reject_not_present }}'
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
vault_raft_leader_tls_servername
vault_raft_group_name
vault_raft_cluster_members
vault_raft_group_name
groupvault_raft_group_name
vault_raft_cluster_members:
- peer: vault-host-1
api_addr: https://vault-host-1:8200
- peer: vault-host-2
api_addr: https://vault-host-2:8200
- peer: vault-host-3
api_addr: https://vault-host-2:8200
vault_raft_cluster_members
statically enables you to run the role against a single host (instead of the entire host group)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
leader_api_addr
vault_raft_cloud_auto_join_exclusive
true
, any leader_api_addr
occurences will be removed
from the configuration.
Keeping this to false
will allow auto_join
and leader_api_addr
to coexistvault_raft_cloud_auto_join_scheme
auto_join
https
is the default value set by
Vault if not specified)vault_raft_cloud_auto_join_port
auto_join
8200
is the default value set by
Vault if not specified)vault_backend_consul
backend_consul.j2
vault_consul
vault_consul_scheme
vault_consul_path
vault_consul_service
vault_consul_token
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
vault_backend_file
backend_file.j2
vault_backend_raft
vault_backend_raft.j2
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
For additional documentation for the various options available, see the Vault documentation for the DynamoDB storage backend.
vault_dynamodb
AWS_DYNAMODB_ENDPOINT
.vault_dynamodb_table
"vault-dynamodb-backend"
AWS_DYNAMODB_TABLE
.vault_dynamodb_ha_enabled
"false"
DYNAMODB_HA_ENABLED
.AWS_
prefix is not a typo, this particular variable is not
prefixed in both the Vault documentation and source code.vault_dynamodb_max_parallel
"128"
vault_dynamodb_region
us-east-1
AWS_DEFAULT_REGION
vault_dynamodb_read_capacity
5
AWS_DYNAMODB_READ_CAPACITY
.vault_dynamodb_write_capacity
5
AWS_DYNAMODB_WRITE_CAPACITY
.vault_dynamodb_access_key
AWS_ACCESS_KEY_ID
vault_dynamodb_secret_key
blank will cause Vault to
attempt to retrieve the credentials from the AWS metadata service.vault_dynamodb_secret_key
AWS_SECRET_ACCESS_KEY
vault_dynamodb_access_key
blank will cause Vault to
attempt to retrieve the credentials from the AWS metadata service.vault_dynamodb_session_token
AWS_SESSION_TOKEN
vault_gcs_bucket
vault_gcs_ha_enabled
"false"
vault_gcs_chunk_size
"8192"
vault_gcs_max_parallel
"128"
vault_gcs_copy_sa
true
and no value is specified for vault_gcs_credentials_src_file
, the default instance service account credentials are used."false"
vault_gcs_credentials_src_file
vault_gcs_credentials_dst_file
{{ vault_home }}/{{ vault_gcs_credentials_src_file | basename}}"
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
service_registration_consul.hcl.j2
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_tls_certs_path }}
vault_service_registration_consul_tls_private_path
{{ vault_tls_private_path }}
vault_service_registration_consul_tls_ca_file
{{ vault_tls_ca_file }}
vault_service_registration_consul_tls_cert_file
{{ vault_tls_cert_file }}
vault_service_registration_consul_tls_key_file
{{ vault_tls_key_file }}
vault_service_registration_consul_tls_min_version
{{ vault_tls_min_version }}
vault_service_registration_consul_tls_skip_verify
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
service_registration_kubernetes.hcl.j2
vault_service_registration_kubernetes_namespace
vault_service_registration_pod_name
vault_log_level
vault_iface
VAULT_IFACE
environment variablevault_address
"{{ hostvars[inventory_hostname]['ansible_'+vault_iface]['ipv4']['address'] }}"
vault_port
vault_max_lease_ttl
vault_default_lease_ttl
vault_main_config
"{{ vault_config_path }}/vault_main.hcl"
vault_main_configuration_template
vault_custom_configuration
vault_http_proxy
vault_https_proxy
or vault_no_proxy
""
vault_https_proxy
vault_no_proxy
""
vault_no_proxy
""
vault_cluster_address
"{{ hostvars[inventory_hostname]['ansible_'+vault_iface]['ipv4']['address'] }}:{{ (vault_port | int) + 1}}"
vault_cluster_addr
"{{ vault_protocol }}://{{ vault_cluster_address }}"
vault_api_addr
"{{ vault_protocol }}://{{ vault_redirect_address or hostvars[inventory_hostname]['ansible_'+vault_iface]['ipv4']['address'] }}:{{ vault_port }}"
vault_disable_api_health_check
false
vault_cluster_disable
validate_certs_during_api_reachable_check
vault_proxy_protocol_behavior
use_always
, allow_authorized
, or deny_unauthorized
use_always
, you must also set
vault_tls_certs_path
/etc/vault/tls
vault_tls_private_path
/etc/vault/tls
vault_tls_disable
VAULT_TLS_DISABLE
environment variablevault_tls_gossip
vault_tls_src_files
VAULT_TLS_SRC_FILES
environment variable{{ role_path }}/files
vault_tls_ca_file
VAULT_TLS_CA_CRT
environment variableca.crt
vault_tls_client_ca_file
vault_tls_cert_file
VAULT_TLS_CERT_FILE
environment variableserver.crt
vault_tls_key_file
VAULT_TLS_KEY_FILE
environment variableserver.key
vault_tls_min_version
VAULT_TLS_MIN_VERSION
environment variablevault_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_service_bsd_init.j2
vault_sysvinit_template
vault_sysvinit.j2
vault_debian_init_template
vault_service_debian_init.j2
vault_systemd_template
vault_service_systemd.j2
vault_systemd_service_name
vault_telemetry_enabled
vault_unauthenticated_metrics_access
vault_telemetry_usage_gauge_period
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_version }}_linux_amd64.zip
vault_centos_url
{{ vault_zip_url }}
vault_centos_os_packages
vault_pkg
"{{ vault_version }}_linux_amd64.zip"
vault_debian_url
"{{ vault_zip_url }}"
vault_sha256
vault_debian_os_packages
vault_pkg
"{{ vault_version }}_linux_amd64.zip"
vault_redhat_url
"{{ vault_zip_url }}"
vault_sha256
vault_redhat_os_packages
vault_pkg
"{{ vault_version }}_linux_amd64.zip"
vault_ubuntu_url
"{{ vault_zip_url }}"
vault_sha256
vault_enable_log
vault_log_path
vault_enable_logrotate
vault_logrotate_freq
vault_logrotate_template
vault_logrotate.j2
vault_ubuntu_os_packages
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.
The role depends on python-netaddr
so:
pip install netaddr
on the Ansible control host prior to executing the role.
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.
See examples/README_VAGRANT.md
for details on quick Vagrant deployments
under VirtualBox for testing, etc.
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
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
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
true
to use vault_license_path
or vault_license_file
.vault_license_path
license_path
in the main configuration file. Only used if vault_configure_enterprise_license: true
.{{ vault_config_path }}/license.hclic
vault_license_file
vault_configure_enterprise_license: true
.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_backend_seal.j2
vault_seal_lib
/lib64/hsmlibrary.so
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
is true.vault_softcard_enable
vault_seal_slot
vault_softcard_enable
is false (default).vault_entropy_seal
entropy
stanza which enables entropy augmentation for supported seals. Supported Seal types include PKCS11, AWS KMS, and Vault Transit.The following stanza will be included in the hcl main configuration file if vault_entropy_seal=true
:
entropy "seal" {
mode = "augmentation"
}
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_seal_gcpkms.j2
vault_gkms_project
vault_gkms_copy_sa
true
and no value is specified for vault_gkms_credentials_src_file
, the default instance service account credentials are used."true"
vault_gkms_credentials_src_file
vault_gkms_credentials_content
vault_gkms_credentials
/home/vault/vault-kms.json
vault_gkms_region
vault_gkms_key_ring
vault_gkms_crypto_key
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_seal_ocikms.j2
vault_ocikms_auth_type_api_key
vault_ocikms_key_id
vault_ocikms_crypto_endpoint
vault_ocikms_management_endpoint
This enables Vault to use another Vault instance for the unseal process using its transit secret engine
vault_transit
false
vault_transit_backend
vault_seal_transit.j2
vault_transit_config
:vault_transit.hcl
vault_transit_address
:`, this variable is mandatory if
vault_transit: true`vault_transit_token
:`, this variable is mandatory if
vault_transit: true`vault_transit_disable_renewal
:false
vault_transit_key_name
autounseal
vault_transit_mount_path
:transit/
vault_transit_namespace
:vault_transit_tls_ca_cert
:ca_cert.pem
, omitted if vault_transit_tls_skip_verify: true
vault_transit_tls_client_cert
:client_cert.pem
, omitted if vault_transit_tls_skip_verify: true
vault_transit_tls_client_key
:ca_cert.pem
, omitted if vault_transit_tls_skip_verify: true
vault_transit_tls_server_name
vault_transit_tls_skip_verify
:false
, can also be set via VAULT_SKIP_VERIFY
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_seal_awskms.j2
vault_awskms_region
vault_awskms_access_key
vault_awskms_secret_key
vault_awskms_key_id
vault_awskms_endpoint
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_seal_azurekeyvault.j2
vault_azurekeyvault_client_id
vault_azurekeyvault_client_secret
vault_azurekeyvault_tenant_id
vault_azurekeyvault_vault_name
vault_azurekeyvault_key_name
Installs vault-acme plugin, also enables the plugin if authenticated against vault (VAULT_ADDR
, VAULT_TOKEN
env).
vault_plugin_acme_install
remote
will download the acme plugin to each target instead of copying it from localhost.remote
vault_plugin_acme_sidecar_install
HTTP-01
/TLS_ALPN_01
challenges in addition to DNS-01.false
vault_plugin_acme_version
latest
for obtaining the latest available version.latest
BSD-2-Clause
Special thanks to the folks listed in CONTRIBUTORS.md for their contributions to this project.