Pull-Mechanik: local.yml, schul-pull.sh, systemd-Units
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>
This commit is contained in:
8
files/ansible-pull.service
Normal file
8
files/ansible-pull.service
Normal file
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Schul-Laptops: Konfiguration per ansible-pull aktualisieren
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/schul-pull.sh
|
||||
11
files/ansible-pull.timer
Normal file
11
files/ansible-pull.timer
Normal file
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Schul-Laptops: regelmaessiger ansible-pull (Boot + alle 30 min)
|
||||
|
||||
[Timer]
|
||||
OnBootSec=2min
|
||||
OnUnitActiveSec=30min
|
||||
RandomizedDelaySec=5min
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
24
files/schul-pull.sh
Normal file
24
files/schul-pull.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user