zarya/cmd/run.sh
2026-10-27 09:11:06 +03:00

28 lines
1,019 B
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -euo pipefail
ZARYA_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "${ZARYA_DIR}/lib/common.sh"
resolve_playbook() {
local id="$1"
local found
found=$(find "${REPO_ROOT}/ansible/playbooks" -maxdepth 1 -name "${id}_*.yml" | head -n1)
if [[ -z "${found}" ]]; then
log_err "Плейбук с префиксом [${id}] не найден в ansible/playbooks/"
exit 1
fi
echo "${found}"
}
if [[ $# -eq 0 ]] || [[ "${1:-}" == "list" ]]; then
echo -e "${BLUE}=== Каталог плейбуков (${REPO_ROOT}/ansible/playbooks/) ===${NC}"
for pb in $(ls -1 "${REPO_ROOT}/ansible/playbooks"/[0-9][0-9]_*.yml 2>/dev/null | sort); do
echo " $(basename "${pb}")"
done
exit 0
fi
id="$1"
shift || true
pb_path=$(resolve_playbook "${id}")
log_info "==> Исполнение: $(basename "${pb_path}")..."
run_isolated ansible-playbook -i "${REPO_ROOT}/ansible/inventory.yml" "${pb_path}" "$@"
log_ok "Плейбук выполнен."