#version=DEVEL text reboot lang de_DE.UTF-8 keyboard de timezone Europe/Berlin --utc # Lab-Bootstrap-Zugangsdaten. Ersetzt ein noch fehlendes Secret-Reference-Modell # (siehe 09-data-model-v1.md) und darf nicht als Produktionsmechanismus gelten. rootpw --plaintext test123 user --name=tuxflotte --groups=wheel --password=test123 network --bootproto=dhcp --activate --hostname=${TUXFLOTTE_HOSTNAME} zerombr clearpart --all --initlabel ${TUXFLOTTE_PARTITIONING_COMMAND} firewall --enabled selinux --enforcing bootloader --location=mbr %packages @core vim curl git jq ansible-core %end %post --erroronfail --interpreter=/bin/bash cat > /etc/motd <<'EOF' Provisioned by tuxflotte https://tuxflotte.de EOF localectl set-locale LANG=de_DE.UTF-8 localectl set-keymap de localectl set-x11-keymap de install -d -m 0700 /etc/tuxflotte # Identifikation soll in beide Richtungen moeglich sein: die Geraeteliste # zeigt den Fingerprint bereits an (siehe geraete_liste.html), aber bislang # gab es auf dem installierten Geraet selbst keine Datei, um ihn mit einem # einfachen "cat" gegenzupruefen - build_device_fingerprint() (10_hardware.sh) # berechnet ihn nur einmalig waehrend des Live-Boots und haelt ihn sonst # nirgends fest. Absichtlich Klartext, kein Secret - reiner Hardware-Hash, # kein chmod 0600 noetig wie bei agent.credentials. echo "${TUXFLOTTE_DEVICE_FINGERPRINT}" > /etc/tuxflotte/device_fingerprint cat > /etc/tuxflotte/runtime_blueprint.json <<'RUNTIME_BLUEPRINT_EOF' ${TUXFLOTTE_BLUEPRINTS_JSON} RUNTIME_BLUEPRINT_EOF # Provisioning Agent einrichten (backend_postinstall). Vorbereitung vor dem # ersten Reboot: Agent-Code holen, beim Provisioning-Server registrieren und # den Dienst für den ersten Boot aktivieren. Gestartet wird er erst danach, # durch systemd selbst (siehe provisioning-agent/README.md). # # Bewusst ohne globales `set -e`: vorangehende Schritte wie # `localectl set-x11-keymap` schlagen in der %post-Chroot best-effort fehl # (kein laufendes systemd/D-Bus) und sollen die Installation nicht abbrechen. # Der Agent-Block unten prüft deshalb jeden kritischen Schritt einzeln. tuxflotte_agent_fatal() { echo "tuxflotte: Provisioning-Agent-Einrichtung fehlgeschlagen: $*" >> /var/log/tuxflotte-postinstall.log exit 1 } ANODE_URL="https://anode.tuxflotte.de" AGENT_REPO_RAW="https://git.tuxflotte.de/admin/provisioning-agent/raw/branch/main" install -d /opt/tuxflotte/agent || tuxflotte_agent_fatal "Verzeichnis /opt/tuxflotte/agent konnte nicht angelegt werden." curl --silent --show-error --fail --location \ --output /opt/tuxflotte/agent/agent.py \ "${AGENT_REPO_RAW}/agent.py" || tuxflotte_agent_fatal "agent.py konnte nicht von ${AGENT_REPO_RAW} geladen werden." curl --silent --show-error --fail --location \ --output /etc/systemd/system/tuxflotte-agent.service \ "${AGENT_REPO_RAW}/tuxflotte-agent.service" || tuxflotte_agent_fatal "tuxflotte-agent.service konnte nicht von ${AGENT_REPO_RAW} geladen werden." AGENT_BOOTSTRAP_RESPONSE="$( curl --silent --show-error --fail --location \ --header 'Content-Type: application/json' \ --data-binary "{\"device_id\": \"${TUXFLOTTE_DEVICE_ID}\"}" \ "${ANODE_URL}/api/v1/agent/bootstrap" )" || tuxflotte_agent_fatal "Bootstrap-Aufruf gegen ${ANODE_URL} ist fehlgeschlagen." jq --exit-status '.success == true' <<<"${AGENT_BOOTSTRAP_RESPONSE}" >/dev/null || tuxflotte_agent_fatal "Server hat den Bootstrap abgelehnt: ${AGENT_BOOTSTRAP_RESPONSE}" jq --null-input \ --arg device_id "${TUXFLOTTE_DEVICE_ID}" \ --argjson response "${AGENT_BOOTSTRAP_RESPONSE}" \ '{device_id: $device_id, agent_secret: $response.agent_secret}' \ > /etc/tuxflotte/agent.credentials || tuxflotte_agent_fatal "Credentials-Datei konnte nicht erzeugt werden." chmod 0600 /etc/tuxflotte/agent.credentials systemctl enable tuxflotte-agent.service || tuxflotte_agent_fatal "systemd-Dienst tuxflotte-agent konnte nicht aktiviert werden." echo "tuxflotte: Runtime Blueprint unter /etc/tuxflotte/runtime_blueprint.json hinterlegt." >> /var/log/tuxflotte-postinstall.log echo "tuxflotte: Provisioning-Agent installiert, registriert und für den ersten Boot aktiviert." >> /var/log/tuxflotte-postinstall.log %end