Vault

This uses the Vault provider to declaratively manage secrets and policies in a running Vault instance. The Vault provider must be configured appropriately:

provider "vault" {
  address      = var.vault_address
  token        = var.vault_token
  ca_cert_file = var.vault_ca_cert_file
}

Workspaces

Ansible initializes Vault in the vault role. When doing so, any existing Vault resources in the same workspace are destroyed permanently. As such, care should be taken to ensure the appropriate workspaces are used when running the role on multiple Vault server instances or environments (eg. dev and prod).

Outputs

Vault produces the following outputs:

  • Certificate key pair for Ansible certificate authentication to Vault

Variables

VariableDescriptionTypeDefault
vault_addressVault addressstringhttps://localhost:8200
vault_token(Root) Vault token for providerstring
vault_ca_cert_fileLocal path to Vault CA cert filestring./certs/vault_ca.crt
vault_audit_pathVault audit file pathstring/vault/logs/vault.log
admin_passwordPassword for admin userstring
kvuser_passwordPassword for kv userstring
allowed_server_domainsList of allowed_domains for PKI server rolelist(string)["service.consul", "dc1.consul", "dc1.nomad", "global.nomad"]
allowed_client_domainsList of allowed_domains for PKI client rolelist(string)["service.consul", "dc1.consul", "dc1.nomad", "global.nomad"]
allowed_auth_domainsList of allowed_domains for PKI auth rolelist(string)["global.vault"]
allowed_vault_domainsList of allowed_domains for PKI vault rolelist(string)["vault.service.consul", "global.vault"]
ansible_public_key_pathLocal path to store Ansible public key for authstring../../certs/ansible.crt
ansible_private_key_pathLocal path to store Ansible private key for authstring../../certs/ansible_key.pem

Notes

  • The resources for Postgres database secrets engine are configured separately in Postgres. This is because the Postgres database might not be up when Vault is being initialized.
  • It is not recommended to change the ansible_*_key_path variables. Changing them will heavily affect the Ansible roles when they attempt to login to Vault with the auth certs.