How do you handle the vault password in CI/CD?
IntermediateProductionSecurity and Secrets
Answer
Store it in the CI system's secret store (masked, scoped to protected branches) and write it to a file or FIFO only for the job's duration.
umask 077
printf '%s' "$ANSIBLE_VAULT_PW" > "$RUNNER_TEMP/.vp"
ansible-playbook site.yml --vault-password-file "$RUNNER_TEMP/.vp"
rm -f "$RUNNER_TEMP/.vp"
A better pattern is an executable password script that fetches the password from a secrets manager using the runner's identity (OIDC), so no static secret lives in CI. Use different vault IDs per environment so a dev pipeline cannot decrypt prod.
More on Security and Secrets
How do you set up a secure automation user and SSH access?BeginnerHow do you give the automation user sudo with least privilege?IntermediateWhat are the alternatives to Ansible Vault for secrets, and when do you use them?IntermediateHow do you read AWS Secrets Manager and SSM parameters in a playbook?IntermediateHow do you integrate HashiCorp Vault with Ansible?AdvancedHow do you stop secrets from leaking into logs and output?Beginner