Local Ansible CLI Integration#
When running ansible playbooks locally via the ansible CLI, one option is to utilize your own vault permissions to retrieve (or write) secrets with the community.hashi_vault collection. Using this method does not require a specific approle or policy to be setup in Vault as you use your own SAML based authentication and matching policy to interact with Vault.
-
Install the following pre-requisites
Bash Sessionpip install hvac ansible-galaxy install community.hashi_vault
-
Set the following environmental variables
Bash Sessionexport ANSIBLE_HASHI_VAULT_ADDR=https://hcp-vault-private-vault-fc507e0d.5d5b1f21.z1.hashicorp.cloud:8200 export ANSIBLE_HASHI_VAULT_NAMESPACE=admin/<CESI>
-
Login to vault (login token will be good for 1hr)
Bash Sessionvault login --method=saml --namespace=admin
-
Use the community.hashi_vault collection. See this example playbook.