Authenticate to hashicorp.vault
After you install or migrate to the hashicorp.vault collection, authentication is configured in the Ansible Automation Platform user interface. An administrator creates a custom credential type to authenticate to Vault. Then users create credentials to use with job templates.
About the Vault integration Copy linkLink copied!
Vault lets you centrally store and manage secrets securely. The Ansible Automation Platform certified hashicorp.vault collection provides fully automated lifecycle and operation management for Vault. You can create, update, and delete secrets through playbooks.
- Existing
community.hashi_vaultusers: Thehashicorp.vaultsolution is intended to replace unsupportedcommunity.hashi_vaultcollection. Use the migration path to keep your existing playbooks. - New Vault users: The
hashicorp.vaultcollection is included in the supported execution environment from automation hub.
Although the hashicorp.vault and hashi.terraform collections work independently of each other and are designed for different tasks, you can use them together in advanced workflows.
Authentication architecture Copy linkLink copied!
The hashicorp.vault collection manages authentication through environment variables and client initialization. This approach enhances security by preventing sensitive credentials from being passed directly as module parameters within playbook tasks.
The hashicorp.vault collection injects credentials into job templates with environment variables, so you get simpler, cleaner task definitions while ensuring that authentication details remain secure.
The following authentication types are supported:
- appRole authentication: Use either one of the following methods when using appRole authentication:
- Set the
VAULT_APPROLE_ROLE_IDandVAULT_APPROLE_SECRET_IDenvironment variables. When you use environment variables, you must also create a custom credential type and credentials that will be passed to the job template. - Directly pass the
role_idandsecret_idparameters to the tasks, for example:- name: Create a secret with AppRole authentication hashicorp.vault.kv2_secret: url: https://vault.example.com:8200 auth_method: approle role_id: "{{ vault_role_id }}" secret_id: "{{ vault_secret_id }}" path: myapp/config data: api_key: secret-api-key
- Set the
- Token authentication: Set the
VAULT_TOKENenvironment variable.Optionally, you can configure parameters for the token. If parameters are not provided, then the module uses environment variables.
Create a custom credential type for Vault Copy linkLink copied!
As an admin, you create a secure credential type in Ansible Automation Platform, which is used to authenticate to Vault.
Before you begin Copy linkLink copied!
Do one of the following:
- New users: Install the Ansible Automation Platform certified
hashicorp.vaultcollection from Automation hub. community.hashi_vaultcollection users: Migrate fromcommunity.hashi_vault.
About this task Copy linkLink copied!
You can configure role-based (appRole) authentication or allow users to directly provide a token.
Procedure Copy linkLink copied!
- Log in to Ansible Automation Platform.
- From the navigation panel, select .
- Click . The Create Credential Type page opens.
- Enter a name and a description in the corresponding fields.
- If you want to configure token authentication for individual users:
- If you want to configure appRole authentication using
role_idandsecret_id: - Click .
What to do next Copy linkLink copied!
Create a custom credential Copy linkLink copied!
Vault users must create a custom credential to use with job templates in Ansible Automation Platform.
Before you begin Copy linkLink copied!
- Your administrator has created a Vault credential type.
Procedure Copy linkLink copied!
- Log in to Ansible Automation Platform.
- From the navigation panel, select , and then select .
- Enter a name and a description in the corresponding fields.
- (Optional) From the Organization list, select an organization.
- From the Credential type list, select a Vault credential type. The fields that display depend on the credential type.
- Do one of the following:
- For the token authentication, add your Vault token and edit any fields as needed.
- For the appRole authentication method, enter the IDs in the appRole Role ID and appRole Secret ID fields. Edit any other fields as needed.
- Click . You are ready to use the credential in a job template.