Files
computer-playbook/roles/web-app-moodle/files/build/install/auth-oidc.sh
kevinveenbirkenbachandClaude Opus 5 1cd9578b83 fix(moodle): fetch the source from a host that answers the runners
download.moodle.org returns 403 to GitHub-hosted runners while serving the identical artefact elsewhere: 12 failures across three runners over twelve hours, each 40-66ms after TLS, with curl's four retries and Ansible's three exhausted. The GitHub tag archive is content-equivalent - both tarballs extracted and diffed over 39312 entries, the only delta being githash.php, which nothing in the 4.5.11 tree includes - and needs --strip-components=1 because it roots at moodle-4.5.11/ rather than moodle/.

auth-oidc.sh was the next landmine, two Dockerfile lines behind the fixed one: an anonymous api.github.com tag query, 60 requests per hour per runner IP, no retry, -s swallowing the rate-limit body under set -e, and a floating plugin version as the build input. It now reads a new meta/addons/auth_oidc.yml, which declares bridges: [sso] and update.monitored so the version is watched by the update pipeline instead of frozen.

MOODLE_BRANCH and MOODLE_TARBALL_FILENAME die with the old URL; the latter was already dead, demanded only by its own :?required guard.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 13:46:35 +02:00

27 lines
1.0 KiB
Bash

#!/bin/bash
# Install the Microsoft auth_oidc plugin. All values come from env vars
# exported by the Dockerfile (single source of truth:
# roles/web-app-moodle/vars/main.yml).
set -euxo pipefail
: "${MOODLE_SOURCE_DIR:?required}"
: "${MOODLE_OIDC_PLUGIN_RELPATH:?required}"
: "${MOODLE_OIDC_PLUGIN_ARCHIVE_URL:?required}"
: "${MOODLE_AUTH_SUBDIR:?required}"
PLUGIN_DIR="${MOODLE_SOURCE_DIR}/${MOODLE_OIDC_PLUGIN_RELPATH}"
ZIP_PATH="$(mktemp -t auth-oidc.XXXXXX.zip)"
EXTRACT_DIR="$(mktemp -d -t auth-oidc-extract.XXXXXX)"
trap 'rm -rf "${ZIP_PATH}" "${EXTRACT_DIR}"' EXIT
test -d "${MOODLE_SOURCE_DIR}/${MOODLE_AUTH_SUBDIR}"
curl --connect-timeout 5 --max-time 300 --retry 3 --retry-all-errors --retry-delay 2 -fSL -o "${ZIP_PATH}" "${MOODLE_OIDC_PLUGIN_ARCHIVE_URL}"
unzip -q "${ZIP_PATH}" -d "${EXTRACT_DIR}"
rm -rf "${PLUGIN_DIR}"
SRC="$(find "${EXTRACT_DIR}" -maxdepth 1 -type d -name 'moodle-auth_oidc-*' | sort | head -n1)"
[ -n "${SRC}" ] || { echo "auth_oidc unpack produced no directory" >&2; exit 1; }
mv "${SRC}" "${PLUGIN_DIR}"