nixos-base-image/scripts/run_ansible_ci.sh
plasmagoat 1f1d07644f
Some checks failed
Build & Upload NixOS Proxmox Image / Build NixOS Base Image (push) Failing after 1m15s
Build & Upload NixOS Proxmox Image / Release Image (push) Has been skipped
version tagging
2025-06-09 22:36:24 +02:00

49 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
echo "Starting Ansible CI/CD run..."
# --- 2. Navigate to the Ansible directory ---
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
ANSIBLE_DIR="${SCRIPT_DIR}/../ansible"
if [[ ! -d "${ANSIBLE_DIR}" ]]; then
echo "Error: Ansible directory not found at ${ANSIBLE_DIR}"
exit 1
fi
cd "${ANSIBLE_DIR}"
echo "Changed directory to: $(pwd)"
# # --- 3. Define Ansible Extra Variables ---
# # Base extra variables from our static definitions
EXTRA_VARS=(
# "local_image_path_ci=${PROXMOX_LOCAL_IMAGE_PATH_FROM_BUILD}" # Path to the image file on the CI runner
# "image_filename=$(basename "${PROXMOX_LOCAL_IMAGE_PATH_FROM_BUILD}")" # Extract filename
)
# # Append any other variables passed via ANSIBLE_EXTRA_VARS from the workflow
if [[ -n "${ANSIBLE_EXTRA_VARS:-}" ]]; then
# Split by space or newline and add to array
IFS=$'\n' read -r -d '' -a ADDITIONAL_VARS <<< "${ANSIBLE_EXTRA_VARS}" || true
for var in "${ADDITIONAL_VARS[@]}"; do
EXTRA_VARS+=("${var}")
done
fi
# # --- 4. Execute the Ansible Playbook ---
# echo "Executing Ansible playbook: upload-template.yml"
# # Construct the full --extra-vars string
EXTRA_VARS_ARGS=""
for var in "${EXTRA_VARS[@]}"; do
EXTRA_VARS_ARGS+=" -e ${var}"
done
ansible-playbook upload-template.yml \
--inventory inventory/hosts.yml \
${EXTRA_VARS_ARGS} # \
# --diff \
# --check false # Set to true for a dry run, false for actual execution
echo "Ansible playbook execution finished."