feat(engine): Adapter debian und Profil-Engine

Profile sind deklarative Schritte je Distributionsfamilie; der Adapter
übersetzt sie in ein idempotentes Shell-Skript. Ein neuer Adapter (rhel,
alpine) ist eine Datei und ein Eintrag in der Registry.

Variablen werden typisiert geprüft, in run-Schritten jeder Wert für die
Shell gequotet. SSH-Härtung läuft zuletzt, damit sich eine Provisionierung
per SSH nicht selbst aussperrt.

Geprüft mit shellcheck und echt in Containern (Debian 12/13, Ubuntu
22.04/24.04/26.04) inklusive zweitem Lauf. Dabei aufgefallen: frische
Images haben keine Paketlisten – der Vorspann macht jetzt apt-get update.

Closes #005

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 10:53:38 +02:00
co-authored by Claude Opus 5.5
parent acae1bc2a4
commit 01d22aac3a
15 changed files with 999 additions and 10 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
# Läuft im Container: systemctl-Stub, Skript ausführen, Ergebnis prüfen.
printf '#!/bin/sh\necho "[systemctl] $*" >> /tmp/systemctl.log\n' > /usr/local/bin/systemctl && chmod +x /usr/local/bin/systemctl
bash "$1" > /tmp/lauf.log 2>&1; code=$?
grep '::proxdeploy::' /tmp/lauf.log
echo "exit=$code"
[ $code -ne 0 ] && tail -25 /tmp/lauf.log
echo "--- Prüfung"
docker --version; docker compose version
zabbix_agent2 -V | head -1; cat /etc/zabbix/zabbix_agent2.d/proxdeploy.conf
cat /etc/timezone; readlink /etc/localtime; grep LANG /etc/default/locale; locale -a | grep -i de_de
grep XKBLAYOUT /etc/default/keyboard
id florian; cat /etc/sudoers.d/90-proxdeploy-florian; cat ~florian/.ssh/authorized_keys
cat /etc/apt/apt.conf.d/20auto-upgrades; dpkg -l fail2ban chrony qemu-guest-agent | grep ^ii | awk '{print $2}'
cat /tmp/systemctl.log | sort -u | tr '\n' ' '; echo
echo "--- Zweiter Lauf (Idempotenz)"; bash "$1" > /tmp/lauf2.log 2>&1; echo "exit2=$?"; grep -c florian ~florian/.ssh/authorized_keys
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# Führt die Profile base, docker und zabbix-agent wirklich aus: je ein frischer Container pro
# Distribution, danach Prüfung des Ergebnisses und ein zweiter Lauf (Idempotenz).
# Dauert einige Minuten und braucht Docker und Netz – deshalb nicht im Commit-Tor.
# pnpm test:container # alle
# pnpm test:container debian-13 # eine
set -euo pipefail
cd "$(dirname "$0")/../.."
export NVM_DIR="$HOME/.nvm"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
declare -A IMAGES=(
[debian-12]=debian:bookworm-slim [debian-13]=debian:trixie-slim
[ubuntu-22.04]=ubuntu:22.04 [ubuntu-24.04]=ubuntu:24.04 [ubuntu-26.04]=ubuntu:26.04
)
ziele=("${@:-debian-12 debian-13 ubuntu-22.04 ubuntu-24.04 ubuntu-26.04}")
arbeit="$(mktemp -d)"; trap 'rm -rf "$arbeit"' EXIT
cp tests/container/im-gast-pruefen.sh "$arbeit/"
fehler=0
for distro in ${ziele[*]}; do
pnpm -s exec tsx scripts/profil-rendern.ts "$distro" docker,zabbix-agent server=zbx.example fail2ban=true > "$arbeit/$distro.sh"
echo "=== $distro (${IMAGES[$distro]})"
if docker run --rm -v "$arbeit:/s:ro" "${IMAGES[$distro]}" bash /s/im-gast-pruefen.sh "/s/$distro.sh" > "$arbeit/$distro.log" 2>&1 \
&& grep -q '^exit=0$' "$arbeit/$distro.log" && grep -q '^exit2=0$' "$arbeit/$distro.log"; then
echo "✓ $distro"
else
echo "✗ $distro"; tail -30 "$arbeit/$distro.log"; fehler=1
fi
done
exit $fehler