Laptops ziehen sich das Repo selbst (HTTPS via git.lehrstun.de, SSH-Fallback mit Deploy-Key) und fuehren local.yml aus. Timer laeuft bei Boot + alle 30 min. local.yml haelt die Mechanik selbst aktuell. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
25 lines
727 B
Bash
25 lines
727 B
Bash
#!/bin/bash
|
|
#
|
|
# Zieht das schul-laptops-Repo und fuehrt local.yml aus.
|
|
# HTTPS zuerst (funktioniert auch im Schulnetz), SSH mit Deploy-Key als Fallback.
|
|
# Wird vom systemd-Timer (ansible-pull.timer) als root aufgerufen.
|
|
#
|
|
set -u
|
|
|
|
HTTPS_URL="https://git.lehrstun.de/admin/schul-laptops.git"
|
|
SSH_URL="ssh://git@46.225.114.15:2222/admin/schul-laptops.git"
|
|
DEPLOY_KEY="/root/.ssh/ansible-pull-deploy"
|
|
CHECKOUT="/var/lib/schul-laptops"
|
|
|
|
run_pull() {
|
|
ansible-pull -U "$1" -d "$CHECKOUT" -c local -i localhost, local.yml
|
|
}
|
|
|
|
if run_pull "$HTTPS_URL"; then
|
|
exit 0
|
|
fi
|
|
|
|
echo "HTTPS fehlgeschlagen, versuche SSH-Fallback (Port 2222) ..." >&2
|
|
export GIT_SSH_COMMAND="ssh -i $DEPLOY_KEY -p 2222 -o BatchMode=yes"
|
|
run_pull "$SSH_URL"
|