diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index ae24912..96302e4 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -104,7 +104,12 @@ jobs: # Execute the script, passing necessary environment variables bash scripts/run_ansible_ci.sh env: - IMAGE_VERSION: ${{ steps.version.outputs.tag_name }} + # Provide VMIDs and names, overriding group_vars if desired. + # These will be passed as `--extra-vars` to Ansible. + ANSIBLE_EXTRA_VARS: >- + backup_template_vmid=${{ env.TEMPLATE_VMID | default('9001') }} + latest_template_vmid=${{ env.LATEST_TEMPLATE_VMID | default('9000') }} + version=${{ steps.version.outputs.tag_name }} - name: Extract flake metadata id: meta diff --git a/README.md b/README.md index c1f3e4d..55a09d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Nixs base image for promxox +# NixOS base image for promxox This is the nixos base image to be used as a template in proxmox ## Using this base image diff --git a/scripts/run_ansible_ci.sh b/scripts/run_ansible_ci.sh index 0d1bd7f..5213ffa 100755 --- a/scripts/run_ansible_ci.sh +++ b/scripts/run_ansible_ci.sh @@ -15,9 +15,34 @@ 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 \ - -e "version=${IMAGE_VERSION:-v0.0.0}" # \ + ${EXTRA_VARS_ARGS} # \ # --diff \ # --check false # Set to true for a dry run, false for actual execution