tools: use toolkit inventory for all ansible commands

Route ansible_cmd through ppf inventory instead of /opt/ansible
default. Eliminates dynamic inventory warnings and connects
via WireGuard IPs.
This commit is contained in:
Username
2026-02-17 23:22:29 +01:00
parent 9eff4496d6
commit 9b8be9d302

View File

@@ -10,6 +10,7 @@ set -eu
PPF_DIR="${PPF_DIR:-$HOME/git/ppf}"
ANSIBLE_DIR="/opt/ansible"
ANSIBLE_VENV="${ANSIBLE_DIR}/venv/bin/activate"
PPF_INVENTORY="${PPF_DIR}/tools/playbooks/inventory.ini"
# ---------------------------------------------------------------------------
# Host topology
@@ -97,25 +98,25 @@ hosts_csv() {
# ---------------------------------------------------------------------------
# Ansible wrapper
# ---------------------------------------------------------------------------
# Runs ansible with venv activated and ANSIBLE_REMOTE_TMP set.
# Runs ansible with toolkit inventory via venv.
# Usage: ansible_cmd <ansible args...>
ansible_cmd() {
(
# shellcheck disable=SC1090
. "$ANSIBLE_VENV"
cd "$ANSIBLE_DIR"
ANSIBLE_REMOTE_TMP=/tmp/.ansible ansible "$@"
ansible -i "$PPF_INVENTORY" "$@"
)
}
# Runs ansible-playbook with venv activated and ANSIBLE_REMOTE_TMP set.
# Runs ansible-playbook with toolkit inventory via venv.
# Usage: ansible_playbook_cmd <ansible-playbook args...>
ansible_playbook_cmd() {
(
# shellcheck disable=SC1090
. "$ANSIBLE_VENV"
cd "$ANSIBLE_DIR"
ANSIBLE_REMOTE_TMP=/tmp/.ansible ansible-playbook "$@"
ansible-playbook "$@"
)
}