Files
homelab/ansible/vault-password.sh
k.renner 01e7c6164e feat: Implement secure Ansible vault password management
- Added REVIEW_SUMMARY.md to provide an executive summary of the infrastructure review, highlighting critical issues and next steps.
- Created VAULT_PASSWORD_USAGE.md as a guide for securely managing the Ansible vault password using environment variables and password managers.
- Introduced vault-password.sh script to read the vault password from the ANSIBLE_VAULT_PASSWORD environment variable, ensuring secure access during Ansible operations.
- Removed the plaintext vault password file (.vault_pass) to enhance security.
2026-02-15 16:21:49 +01:00

23 lines
668 B
Bash
Executable File

#!/usr/bin/env bash
# Ansible Vault Password Script
# Reads password from ANSIBLE_VAULT_PASSWORD environment variable
#
# Usage in ansible.cfg:
# vault_password_file = vault-password.sh
#
# Usage in shell:
# export ANSIBLE_VAULT_PASSWORD="your-password-here"
# ansible-playbook playbook.yml
set -euo pipefail
if [ -z "${ANSIBLE_VAULT_PASSWORD:-}" ]; then
echo "ERROR: ANSIBLE_VAULT_PASSWORD environment variable is not set" >&2
echo "Please set it before running Ansible:" >&2
echo " export ANSIBLE_VAULT_PASSWORD='your-vault-password'" >&2
exit 1
fi
# Output password to stdout (Ansible will read this)
printf "%s" "$ANSIBLE_VAULT_PASSWORD"