prole/etc/init_ansible.sh
chrisfu a7cb5b5fca Add prole_cfg.sh sourcing for configuration management
- Consistently source `prole_cfg.sh` across multiple init scripts for unified configuration handling.
- Enhanced error handling in `screen.py` to manage potential UI exceptions gracefully.
- Improved asynchronous function scheduling using the new `safe_after` method.
2026-01-30 23:37:32 -08:00

40 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# init_ansible.sh
# Purpose:
# - Initialize or update the Ansible vault password file (.vault_pass)
# - Should be run after init_openbao.sh
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck disable=SC1090
source "$SCRIPT_DIR/prole_cfg.sh"
PROLE_ROOT=$(cd "$SCRIPT_DIR/.." && pwd)
VAULT_PASS_FILE="$PROLE_ROOT/.vault_pass"
ACTION=${1:-initialize}
case "$ACTION" in
initialize|update)
# Use PROLE_PASSWD if set, otherwise prompt
if [[ -n "${PROLE_PASSWD:-}" ]]; then
echo "Using PROLE_PASSWD for Ansible Vault password."
echo "$PROLE_PASSWD" > "$VAULT_PASS_FILE"
else
echo -n "Enter Ansible Vault password: "
read -rs vault_pass
echo
echo "$vault_pass" > "$VAULT_PASS_FILE"
fi
chmod 600 "$VAULT_PASS_FILE"
echo "Ansible Vault password file $ACTION""d at $VAULT_PASS_FILE"
;;
*)
echo "Usage: $0 {initialize|update}" >&2
exit 2
;;
esac