fdas
This commit is contained in:
parent
8a6395faf2
commit
0a53e76c81
2 changed files with 1 additions and 1 deletions
|
|
@ -1,70 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "Starting Ansible CI/CD run..."
|
||||
|
||||
# --- 1. Validate required environment variables ---
|
||||
if [[ -z "${PROXMOX_LOCAL_IMAGE_PATH_FROM_BUILD}" ]]; then
|
||||
echo "Error: PROXMOX_LOCAL_IMAGE_PATH_FROM_BUILD environment variable not set. Cannot find built image."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- 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."
|
||||
|
||||
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Navigate to the ansible directory
|
||||
cd ansible
|
||||
|
||||
# Run the image deployment playbook
|
||||
echo "Running Ansible upload-template playbook..."
|
||||
ansible-playbook upload-template.yml \
|
||||
-e "cpu_cores=4" \
|
||||
-e "memory_mb=4096"
|
||||
|
||||
echo "Ansible playbook completed."
|
||||
Loading…
Add table
Add a link
Reference in a new issue