Using bash and supported inventories

This commit is contained in:
2024-12-08 11:57:56 +01:00
parent f5b3e51671
commit 01a45b43d4
3 changed files with 18 additions and 7 deletions

View File

@@ -1,17 +1,25 @@
#!/usr/bin/env ash
#!/usr/bin/env bash
INPUT_PLAYBOOK_PATH="$playbook"
INPUT_ONLY_CHECK="$only_check"
INPUT_INVENTORY_FILE="$inventory"
set -e
ANSIBLE_OPTIONS="-vv"
ANSIBLE_OPTIONS=("-vv")
if [ "$INPUT_ONLY_CHECK" = "true" ]; then
ANSIBLE_OPTIONS="${ANSIBLE_OPTIONS} --check --diff"
ANSIBLE_OPTIONS+=("--check" "--diff")
fi;
echo "Running playbook with options: ansible-playbook $ANSIBLE_OPTIONS \"$INPUT_PLAYBOOK_PATH\""
ansible-playbook $ANSIBLE_OPTIONS "$INPUT_PLAYBOOK_PATH"
IFS=',' read -r -a inventories <<< "$INPUT_INVENTORY_FILE"
for inv in "${inventories[@]}"; do
ANSIBLE_OPTIONS+=("--inventory" "$inv")
done
ANSIBLE_OPTIONS+=("$INPUT_PLAYBOOK_PATH")
echo "Running playbook with options: ansible-playbook ${ANSIBLE_OPTIONS[*]}"
ansible-playbook "${ANSIBLE_OPTIONS[@]}"
exit 0