diff --git a/docs/GNAI-000-DOC_Index.md b/docs/GNAI-000-DOC_Index.md index a44f934..de0dea2 100644 --- a/docs/GNAI-000-DOC_Index.md +++ b/docs/GNAI-000-DOC_Index.md @@ -41,6 +41,8 @@ jeweiligen Fachdokumenten. Die priorisierte weitere Umsetzung beschreibt der | [CT 101 / GNAI-017](platform/proxmox-server/lxc/ct-101-samba/GNAI-017-PLAN_Samba-NFS-Export.md) | Samba-Dateiserver `10.0.0.9`: Aufnahme ins Repository, NFS-Export und Encoding-Shares | | [CT 101 / GNAI-018](platform/proxmox-server/lxc/ct-101-samba/GNAI-018-REQ_Encoding-Pipeline-Integration.md) | Requirements der Encoding-Pipeline an CT 101 — Übergabe an den Ansible-Rebuild | | [CT 101 / GNAI-019](platform/proxmox-server/lxc/ct-101-samba/GNAI-019-DEC_Ansible-Migration.md) | Entwurfsentscheidungen der CT-101-Ansible-Migration: natives Samba, NFS-Ganesha als Quadlet, Fresh-State-Rebuild | +| [CT 114 / GNAI-024](platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md) | geplanter Litecoin-Wallet-LXC `ltc-node` (`10.0.0.61`): Prüfung der Research-Dokumente, Tor-only Cold Node, Ansible-Projekt und Provisioning — noch nicht angelegt (Plan 25.11.2026) | +| [CT 117 / GNAI-025](platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md) | Fluxer-Chat-LXC `fluxer` (`10.0.0.62`) in Betrieb: `https://fluxer.ghostnet.selfhost.eu` live über NPM (LE-Cert), Keycloak-Client `fluxer` angelegt, Split-DNS live, alle CTs konvergiert (`changed=0`); offen: SSO-Verkabelung im Admin-Panel, FRITZ!Box-Voice-Ports, Abnahme (Stand 30.11.2026) | ### KI und Deployment @@ -96,7 +98,7 @@ Hauptverzeichnisse `llm-server/host/` (Grundkonfiguration des Servers), | Deployment | lokales Ansible-Control-Projekt und idempotente Hostrollen; Production-Inventar mit Referenz- und Rollback-Profil, `ai_environment_switch` und Backup-Timer deployt und abgenommen (GNAI-008 14.6); **M5-Fortschritt 10.11.2026:** statische CI (Gitea Actions, 4 Jobs) + repo-scoped Runner `ci-static-01` auf CT 116 + Branch-Protection `main` (required checks, 1 Approval) eingerichtet und per PR-Durchlauf bewiesen (GNAI-008 Abschnitt 12) | privilegierter Deployment-Runner mit Promotion-Tag-Freigabe, Secret-Store/-Rotation, getrennte Testing-/Production-Rechte, Secret-Scan über die Git-Historie (GNAI-008 Abschnitt 12, Fragen 3–5) | | VPN | wg-easy v15.4.0; einziger Peer `ghost-laptop` als Server Admin; native nftables-Zielpolicy und NAT, Legacy-Bereinigung, Fremdnetz-, Positiv-/Negativ-, Dienst- und LXC-Wiederanlauftests bestanden; CT 104 am 07.10.2026 als zwölftes Ziel praktisch abgenommen; WAN-Exposure-Erfassung 10.11.2026: nur TCP 80/443 offen, keine AAAA (GNAI-007 7); frischer Stop-Mode-vzdump + hostunabhängige Kopie auf `ghostnet-ki` am 10.11.2026 | Fremdnetz-WAN-Rescan vom Hotspot (UDP 51820, TCP-Portmatrix), FRITZ!Box-Forward-/IPv6-Abgleich, wg-easy-GUI-HTTPS und KI-Server-Test bei eingeschaltetem Host | | DNS / Pi-hole | CT 100 unter `10.0.0.14` mit digest-gepinntem Pi-hole 2026.09.0 als Podman-Quadlet; SSH/nftables, UDP/TCP-DNS, Split-DNS, Blocking/Allowlist, FRITZ!Box-Cutover, LXC-Reboot und Stop-Mode-Backup am 01.10.2026 abgenommen; Ansible-Projekt am 09.11.2026 adoptiert (ansible-deploy via pct; `site.yml`/`verify-production` `changed=0`) und Split-DNS-Record `mon.ghostnet.selfhost.eu → 10.0.0.10` live (verifiziert per `dig @10.0.0.14`); frischer Stop-Mode-vzdump + hostunabhängige Kopie auf `ghostnet-ki` + praktischer Restore-Test (CT 150) am 10.11.2026 (GNAI-012 10.2) | vollständige App-/OIDC-Regression, praktischer FRITZ!Box-Rollback, mobile DuckDuckGo-/IPv6-Strategie, WireGuard-Profile | -| Reverse Proxy | CT-103-Zugänge, SSH-/Firewall-Baseline, Reboot und lokales Backup abgenommen; NPM 2.15.1 routet öffentlichen OIDC- und internen Admin-vHost getrennt; öffentliche Keycloak-Administration liefert 403; vollständiger Ansible-Sollzustand importiert und adoptiert (07.11.2026; preflight/verify-production/`site.yml --check` am 09.11.2026 ohne Befund, `changed=0`); Fail2Ban-Funktionsabnahme (Jails, kontrollierter Ban/Unban, nftables-Nachweis, Dienstneustart, LXC-Reboot) am 10.11.2026 bestanden, frischer Rollback-vzdump + hostunabhängige Kopie auf `ghostnet-ki` (GNAI-006 10/12); NPM-Proxyhost `mon.ghostnet.selfhost.eu` → `10.0.0.90:8080` seit 09.11.2026 eingerichtet (ID 14, GNMON-000 M6); **12.11.2026: NPM-Proxyhost `chat.ghostnet.selfhost.eu` mit `proxy_read_timeout`/`proxy_send_timeout` 600 s für LLM-Research-Loops** (Betreiber-Schritt, GNAI-020 Abschnitt 6) | Fremdnetz-WAN-Rescan (Hotspot) und FRITZ!Box-Forward-/IPv6-Abgleich | +| Reverse Proxy | CT-103-Zugänge, SSH-/Firewall-Baseline, Reboot und lokales Backup abgenommen; NPM 2.15.1 routet öffentlichen OIDC- und internen Admin-vHost getrennt; öffentliche Keycloak-Administration liefert 403; vollständiger Ansible-Sollzustand importiert und adoptiert (07.11.2026; preflight/verify-production/`site.yml --check` am 09.11.2026 ohne Befund, `changed=0`); Fail2Ban-Funktionsabnahme (Jails, kontrollierter Ban/Unban, nftables-Nachweis, Dienstneustart, LXC-Reboot) am 10.11.2026 bestanden, frischer Rollback-vzdump + hostunabhängige Kopie auf `ghostnet-ki` (GNAI-006 10/12); NPM-Proxyhost `mon.ghostnet.selfhost.eu` → `10.0.0.90:8080` seit 09.11.2026 eingerichtet (ID 14, GNMON-000 M6); **12.11.2026: NPM-Proxyhost `chat.ghostnet.selfhost.eu` mit `proxy_read_timeout`/`proxy_send_timeout` 600 s für LLM-Research-Loops** (Betreiber-Schritt, GNAI-020 Abschnitt 6); **26.11.2026: Vorfall volle Root-Platte per Ansible behoben (Role `reverse_proxy_disk_housekeeping`) und NPM 2.15.1 → 2.17.1 wegen nginx2root/nginx2shell (CVE-2026-123007/-123633), siehe GNAI-006 Abschnitt 15; **26.11.2026 behoben: Ausfall `ghostnet-lxc-backup-sync` 15.11.–26.11. (gn-backup-Home-Mode 0750 statt 0711 auf ghostnet-ki, Fix per ki-host.yml), siehe GNAI-012 10.2 (27.11.)** | Fremdnetz-WAN-Rescan (Hotspot) und FRITZ!Box-Forward-/IPv6-Abgleich | | Keycloak | CT 102 unter `10.0.0.4` reproduzierbar per Ansible aufgebaut; gepinntes Keycloak 26.2.4 und PostgreSQL 16.15, Restore von CT 104, Container-/DB-Härtung, NPM-Cutover, interner Adminzugang, öffentliche Admin-Sperre, realer Vaultwarden-OIDC-Login und LXC-Neustart abgenommen; Stabilisierungsphase + praktischer NPM-Rückfalltest auf CT 104 am 10.11.2026 bestanden, CT 104 danach nach Betreiberfreigabe entfernt (GNAI-016 Phase F); Ansible-Drift CT 102 `changed=0`; frischer Stop-Mode-vzdump + hostunabhängige Kopie auf `ghostnet-ki` am 10.11.2026 | Betriebs-/Backup-/Restore-SOP | | Encoding | Konto, Pfade, eigener rootless Store und CPU-Isolation per Ansible verwaltet und verifiziert; NFS-Mount `/var/lib/ghostnet-pipeline` aktiv (verifiziert 09.11.2026); Planungsabschluss 19.10.2026 (Pipeline GNENC-002, Speicher auf CT-101); Monitoring-Anbindung umgesetzt (GNMON-000 M1–M5) | Implementierung (Images, Quadlets, Skripte, Worker); Lasttest und Limit-Feintuning; SMB-Output-Pickup als geschlossener Ablauf | | Monitoring | M1–M6 produktiv auf `10.0.0.90` (System-Scope, Konten `gn-monitor` 986 / `gn-dashboard` 984): node_exporter + AMD-Textfile-Collector, VictoriaMetrics, Loki + Alloy, vmalert + Alertmanager (inkl. `gnmon-ai`/`GnAiEnvironmentDown`), Dashboard **v0.3.6 öffentlich über `https://mon.ghostnet.selfhost.eu`** (NPM CT-103 ID 14, LE-TLS; Keycloak-OIDC Realm Ghost.net, Client `gnai-dashboard`, Rollen `gnai-dashboard-user`/`-admin`; 8080 per nftables nur von 10.0.0.10; E2E inkl. 403-Negativtest und WebSocket-Circuit bestanden 09.11.2026, GNMON-000 M6; Favicon-Revert auf v0.3.6 am 14.11.2026, GNAI-021) | echter SMTP-Versand, LLM-Metriken jenseits `gn_ai_active_env`, Retention-Feintuning, externer WireGuard-Zugriff auf mon (DNS/TLS öffentlich, praktisch ungetestet) | diff --git a/docs/platform/proxmox-server/README.md b/docs/platform/proxmox-server/README.md index e728163..fdca9a9 100644 --- a/docs/platform/proxmox-server/README.md +++ b/docs/platform/proxmox-server/README.md @@ -19,7 +19,11 @@ Hypervisors selbst. | [GNAI-018 / CT 101](lxc/ct-101-samba/GNAI-018-REQ_Encoding-Pipeline-Integration.md) | Requirements der Encoding-Pipeline an CT 101 für den Ansible-Rebuild (Übergabe) | | [GNAI-019 / CT 101](lxc/ct-101-samba/GNAI-019-DEC_Ansible-Migration.md) | Entwurfsentscheidungen der Ansible-Migration: natives Samba, NFS-Ganesha als Quadlet, Fresh-State-Rebuild | | [CT-101-Automation](../../../proxmox/lxc/ct-101-samba/README.md) | produktives Samba-Ansible-Projekt und CT-spezifische PVE-Helfer | -| [PVE-Host-Automation](../../../proxmox/pve-host/README.md) | Ansible-Verwaltung des PVE-Hosts selbst (`10.0.0.2`): Deploy-Account, Kernel-NFS-Export, LXC-Conf | +| [GNAI-024 / CT 114](lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md) | `10.0.0.61` (geplant): Litecoin Cold Wallet als Tor-only Full Node; Plan und Forschungsprüfung, CT noch nicht angelegt | +| [CT-114-Automation](../../../proxmox/lxc/ct-114-litecoin-wallet/README.md) | Ansible-Projekt und PVE-Provisioning-Skripte für CT 114 (GNAI-024) | +| [GNAI-025 / CT 117](lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md) | `10.0.0.62` (geplant): Fluxer-Chat-Server hinter NPM (CT 103) mit Keycloak-SSO; Machbarkeitsprüfung, CT noch nicht angelegt | +| [CT-117-Automation](../../../proxmox/lxc/ct-117-fluxer/README.md) | Ansible-Projekt und PVE-Provisioning-Skripte für CT 117 (GNAI-025) | +| [PVE-Host-Automation](../../../proxmox/pve-host/README.md) | Ansible-Verwaltung des PVE-Hosts selbst (`10.0.0.2`): Deploy-Account, Kernel-NFS-Export, LXC-Conf, tägliche CT-114-Snapshots (`pve_lxc_snapshot`) | Die versionierte Quelle für den optionalen, secretfreien Community-Scripts-Post-install-Hook liegt unter diff --git a/docs/platform/proxmox-server/lxc/ct-100-dns/GNAI-012-PLAN_Pi-hole-DNS-Handoff.md b/docs/platform/proxmox-server/lxc/ct-100-dns/GNAI-012-PLAN_Pi-hole-DNS-Handoff.md index f3d6b57..c3f12d1 100644 --- a/docs/platform/proxmox-server/lxc/ct-100-dns/GNAI-012-PLAN_Pi-hole-DNS-Handoff.md +++ b/docs/platform/proxmox-server/lxc/ct-100-dns/GNAI-012-PLAN_Pi-hole-DNS-Handoff.md @@ -3,7 +3,7 @@ **Dokumenten-ID:** GNAI-012-PLAN **Titel:** Pi-hole-LXC, FRITZ!Box-DNS und Split-DNS für interne Dienste **Status:** Implementiert und im LAN produktiv; Ansible-Sollzustand als CT-Projekt angelegt und am 09.11.2026 privilegiert adoptiert (ansible-deploy via pct exec; `site.yml`/`verify-production` konvergent `changed=0`); Split-DNS-Record `mon.ghostnet.selfhost.eu → 10.0.0.10` seit 09.11.2026 live (GNMON-M6). Klar ausgewiesene Folgepunkte offen -**Stand:** 2026-11-09 +**Stand:** 2026-11-27 **Referenzen:** [Projekt-Roadmap](../../../../GNAI-001-PLAN_Project-Roadmap.md), [Zugriffskonzept](../../../GNAI-005-SEC_Access-Control.md), [LXC-SSH-Architektur](../../GNAI-011-SEC_LXC-SSH-Architecture.md), [Reverse Proxy](../ct-103-reverse-proxy/GNAI-006-SEC_Reverse-Proxy.md), [WireGuard](../ct-105-wireguard/GNAI-007-SEC_VPN.md) ## 1. Auftrag und Umsetzungsergebnis @@ -449,6 +449,13 @@ kann nun den internen NPM-Proxy-Host und Keycloak `hostname-admin` einrichten, den internen Login testen und danach `auth.ghostnet.selfhost.eu/admin` für öffentliche Quellen sperren. +### 10.2 Aktualisierung vom 27.11.2026 (Backup-Sync-Ausfall 15.11.–26.11. behoben) + +- **Befund:** `ghostnet-lxc-backup-sync.service` auf dem PVE-Host lief ab 15.11.2026 02:30 Uhr mit `gn-backup@10.0.0.90: Permission denied (publickey)` fehl; letzter Erfolg 14.11. 02:40 Uhr (`DONE all archives verified on receiver`). 12 Tage lang keine hostunabhängige Kopie der vzdump-Archive. +- **Ursache:** Das Home `/var/lib/ghostnet-ai-backup` von `gn-backup` auf ghostnet-ki stand auf `0750 root:root` statt des von Rolle `gn_backup_receiver` (llm-server/host/ansible, seit 10.11.2026, Commit 2fe80bc) deklarierten `0711`. uid 999 konnte das Verzeichnis nicht traversieren, sshd konnte als gn-backup die `authorized_keys` nicht lesen („key is not allowed“ im sshd-Debug). Key-Fingerprints auf PVE und ki identisch (`SHA256:tabCXnfr…`), `from="10.0.0.2"` passte — reiner Berechtigungsfehler. Die Drift entstand zwischen 14.11. und 15.11. außerhalb des Repos. +- **Behebung (26.11.2026):** `llm-server/host/ansible/playbooks/host.yml` (Inventar `host`) gegen ghostnet-ki — `--check --diff` zeigte nur Mode `0750`→`0711`, real `ok=76 changed=1 failed=0`, danach `--check` `changed=0`. Manueller `systemctl start ghostnet-lxc-backup-sync.service`: Transfer + SHA-256 aller Archive OK, `DONE`, Prune auf ≤4 Archive pro CT. +- **Verifikation (27.11.2026):** Timer-Lauf 03:30 Uhr `status=0/SUCCESS` (`DONE all archives verified on receiver` 02:40:11Z), PVE ohne failed Units, Receiver 21 Dateien mit ≤4 Archiven pro CT, Home-Mode weiterhin `0711 root:root`. Unabhängig vom CT-103-Vorfall vom 26.11. (volle Platte, siehe GNAI-006 Abschnitt 15). + ### 10.2 Lesende Wiederholungsprüfung vom 14.10.2026 Die erneute Live-Inventur bestätigte einen fehlerfreien LXC ohne fehlgeschlagene diff --git a/docs/platform/proxmox-server/lxc/ct-103-reverse-proxy/GNAI-006-SEC_Reverse-Proxy.md b/docs/platform/proxmox-server/lxc/ct-103-reverse-proxy/GNAI-006-SEC_Reverse-Proxy.md index 85d445d..7ac552c 100644 --- a/docs/platform/proxmox-server/lxc/ct-103-reverse-proxy/GNAI-006-SEC_Reverse-Proxy.md +++ b/docs/platform/proxmox-server/lxc/ct-103-reverse-proxy/GNAI-006-SEC_Reverse-Proxy.md @@ -2,7 +2,7 @@ **Dokumenten-ID:** GNAI-006-SEC **Titel:** Reverse Proxy und Fail2Ban – Konfiguration, Betrieb und Sicherheitsabnahme -**Status:** NPM 2.15.1 und Fail2Ban aktiv; Keycloak-Public/Admin-Trennung seit 14.10.2026 abgenommen; Fail2Ban-Funktionsabnahme offen +**Status:** NPM 2.17.1 (seit 26.11.2026, nginx2root-Fixes) und Fail2Ban aktiv; Keycloak-Public/Admin-Trennung seit 14.10.2026 abgenommen; Fail2Ban-Funktionsabnahme offen; Disk-Housekeeping seit 26.11.2026 im Ansible-Sollzustand (Abschnitt 15) **Vorgänger / Referenzen:** [Architektur](../../../llm-server/ai/GNAI-004-INFRA_Architecture.md), [LXC-SSH](../../GNAI-011-SEC_LXC-SSH-Architecture.md), [Zugriffskonzept](../../../GNAI-005-SEC_Access-Control.md), [WireGuard](../ct-105-wireguard/GNAI-007-SEC_VPN.md) @@ -36,6 +36,8 @@ | 2026-10-31 | 2.9 | spektr / Mistral Vibe | Lesenden Infrastruktur-Audit vor dem LLM-Ausbau durchgeführt (Abschnitt 2.4): Dienste, Image-Pins, SSH- und Dateihärtung, Firewall-Verhaltenstests, TLS, DNS und Keycloak-Pfade geprüft; keine Abweichung. Fail2Ban-Funktionsabnahme bleibt offen. | | 2026-11-09 | 3.0 | Mistral Vibe | Ansible-Sollzustand im Repository importiert (`proxmox/lxc/ct-103-reverse-proxy/ansible/`) und am 07.11.2026 adoptiert (Konten `ghost-agent`/`ghost`/`ansible-deploy`, verwaltetes nftables, NPM-/Fail2Ban-Quadlets). Verifiziert 09.11.2026: `preflight.yml` (agent) ok=15 failed=0, `verify-production.yml` (production) ok=27 changed=0 failed=0, `site.yml --check` changed=0 — Host und Sollzustand sind konvergent. | | 2026-11-09 | 3.1 | spektr / Mistral Vibe | Proxy-Host ID 14 `mon.ghostnet.selfhost.eu → 10.0.0.90:8080` angelegt (Abschnitt 7): WebSocket Support, Block Common Exploits, LE-Zertifikat, Force SSL, HSTS; Advanced-Config mit `X-Forwarded-Proto $scheme`/`X-Forwarded-Host $host` (NPM setzt sonst nur das leere `$x_forwarded_proto`) und `proxy_buffer_size 32k` (großer OIDC-Cookie). GNMON-M6-Abnahme siehe GNMON-000. | +| 2026-11-26 | 3.2 | spektr / Mistral Vibe | Vorfall volle Root-Platte dokumentiert und per Ansible behoben: NPM-Logs hatten keine Rotation, nginx hielt gelöschte Inodes offen; NPM lieferte 0-Byte-Assets (Gitea „Frontend is not initialized“, Keycloak ungestylt). Neues Role `reverse_proxy_disk_housekeeping` (Journald-Cap, logrotate mit `copytruncate`, selbstheilender Guard) im Sollzustand; Details in Abschnitt 15. | +| 2026-11-26 | 3.3 | spektr / Mistral Vibe | NPM 2.15.1 → 2.17.1 wegen nginx2root/nginx2shell (CVE-2026-123007, CVE-2026-123633; Fixes in nginx 1.30.7/1.31.9 vom 18.11.2026, in 2.17.1 als Backport im OpenResty-Base-Image). Backup vor Upgrade, Verifikation aller VHosts; Abschnitt 15. | --- @@ -117,7 +119,7 @@ Hostschlüsselprüfung und ausschließlich diesen Schlüssel. | System | Debian 13, PVE-Kernel `7.0.14-14-pve`, Podman 5.4.2, nftables 1.1.3 und OpenSSH `10.0p1-7+deb13u4`. | | Dienste | SSH, nftables, `nginx-proxy-manager` und `fail2ban` aktiv; keine fehlgeschlagenen systemd-Units. NPM läuft seit 02.09., Fail2Ban seit 16.09.; jeweils `NRestarts=0`. | | Updates | `unattended-upgrades` aktiv und aktiviert; apt-daily- und apt-daily-upgrade-Timer vorhanden. | -| Containerdefinition | NPM ist im Quadlet auf `2.15.1`, Fail2Ban auf `1.1.0-r2-ls43` gepinnt. Beide laufen rootful mit Hostnetz; Fail2Ban besitzt `NET_ADMIN` und `NET_RAW`. | +| Containerdefinition | NPM ist im Quadlet auf `2.17.1`, Fail2Ban auf `1.1.0-r2-ls43` gepinnt. Beide laufen rootful mit Hostnetz; Fail2Ban besitzt `NET_ADMIN` und `NET_RAW`. | | Listener | TCP 80, 81 und 443 auf IPv4, TCP 22 und NPM-Backend 3000 auf IPv4/IPv6 beziehungsweise allen Adressen. Auf `eth0` existiert nur IPv4 plus link-lokales IPv6. Listener beweisen keine Erreichbarkeit durch die Firewall. | | Firewall | Persistente und aktive nftables-INPUT-Policy `drop`; erlaubt TCP 22/81 aus `10.0.0.0/24` und TCP 80/443 allgemein. Port 3000 fällt durch die Default-Policy. `nftables.service` ist aktiv und aktiviert. Der SSH-Socket lauscht auf `*:22`, seine Netzfreigabe wird durch nftables begrenzt. | | SSH | `ghost-agent` und persönliches Konto `ghost` mit getrennten Schlüsseln aktiv; Drop-in mit `AllowUsers ghost-agent ghost`. Root-/Passwortversuche extern abgelehnt, persönlicher Login und passwortgeschütztes sudo erfolgreich. `ssh.socket` und `ssh.service` aktiv. | @@ -158,7 +160,7 @@ Workstation aus dem LAN. Es wurden keine Konfigurationen verändert. | Bereich | Beobachtung am 31.10.2026 | | --- | --- | | System und Dienste | Debian 13.7; `nftables`, `nginx-proxy-manager`, `fail2ban`, `ssh.socket` und `ssh.service` aktiv; keine fehlgeschlagenen Units; Uptime rund 2,5 Wochen. | -| Containerdefinitionen | Quadlets unverändert gepinnt: NPM `docker.io/jc21/nginx-proxy-manager:2.15.1`, Fail2Ban `lscr.io/linuxserver/fail2ban:1.1.0-r2-ls43`; Fähigkeiten und Volumes entsprechen Abschnitt 4. | +| Containerdefinitionen | Quadlets unverändert gepinnt: NPM `docker.io/jc21/nginx-proxy-manager:2.17.1`, Fail2Ban `lscr.io/linuxserver/fail2ban:1.1.0-r2-ls43`; Fähigkeiten und Volumes entsprechen Abschnitt 4. | | Listener und Firewall | TCP 80/81/443 nur auf IPv4, TCP 22 und NPM-Backend 3000 auf allen Adressen. Verhaltenstests aus dem LAN: Port 81 erreichbar (HTTP 200), Port 3000 Timeout – die INPUT-Drop-Policy ist damit wirksam, die Port-Matrix aus Abschnitt 3 bestätigt. | | SSH-Härtung | Drop-in `99-security.conf` entspricht vollständig der dokumentierten Baseline (Root-/Passwort-Login aus, `AllowUsers ghost-agent ghost`, sämtliche Forwarding- und Tunnel-Sperren, `MaxAuthTries 3`). | | Dateihärtung | `/opt/nginx-proxy-manager/data` ist `0750 root:root`; Datenbank, Schlüsseldatei und Logs sind für `ghost-agent` unlesbar – die Härtung vom 22.09.2026 (Abschnitt 2.3) ist intakt. | @@ -234,7 +236,7 @@ Nginx Proxy Manager und Fail2Ban werden als rootful Podman-Container via systemd ### 4.1 Nginx Proxy Manager Quadlet * **Datei:** `/etc/containers/systemd/nginx-proxy-manager.container` -* **Image, live bestätigt am 22.09.2026:** `docker.io/jc21/nginx-proxy-manager:2.15.1` *(ausdrücklich gepinnt)* +* **Image, live bestätigt am 22.09.2026 (2.15.1) und am 26.11.2026 (2.17.1):** `docker.io/jc21/nginx-proxy-manager:2.17.1` *(ausdrücklich gepinnt; Upgrade wegen nginx2root/nginx2shell siehe Abschnitt 15)* ```ini [Unit] @@ -243,7 +245,7 @@ Wants=network-online.target After=network-online.target [Container] -Image=docker.io/jc21/nginx-proxy-manager:2.15.1 +Image=docker.io/jc21/nginx-proxy-manager:2.17.1 ContainerName=nginx-proxy-manager Network=host Volume=/opt/nginx-proxy-manager/data:/data:rw @@ -632,4 +634,44 @@ LLM Admins dürfen nur `.90` erreichen und haben keinen allgemeinen NPM-/LXC-Zug | Keycloak Admin extern nutzbar | am 14.10.2026 geschlossen: öffentlich 403, intern 200, OIDC und realer Vaultwarden-Login bestanden | | TLS-Zuordnung des auth-Hosts unklar | am 14.10.2026 für öffentlichen und internen HTTPS-vHost funktional abgenommen | | Fail2Ban auf `1.1.0-r2-ls43` gepinnt und Container wieder laufend | am 10.11.2026 geschlossen: Image/Version/Digest, Config-Test, Jails, Filter-Dry-Run, kontrollierter Ban/Unban mit nftables-Nachweis, Dienstneustart und LXC-Reboot bestanden (Abschnitt 12) | -| NPM-Daten und Logs lokal weltlesbar beziehungsweise weltbeschreibbar | am 22.09.2026 korrigiert und positiv/negativ regressionsgeprüft; künftige Dateierzeugung und Logrotation weiter beobachten | +| NPM-Daten und Logs lokal weltlesbar beziehungsweise weltbeschreibbar | am 22.09.2026 korrigiert und positiv/negativ regressionsgeprüft; Logrotation der NPM-Logs seit 26.11.2026 per Ansible sichergestellt (`copytruncate`, Abschnitt 15) | + +--- + +## 15. Vorfall 2026-11-26: Volle Root-Platte, 0-Byte-Assets und NPM-Sicherheitsupgrade + +**Entscheidung des Betreibers (26.11.2026):** Vorfall per Ansible reproduzierbar beheben und dauerhaft verhindern; NPM wegen nginx2root/nginx2shell sofort auf 2.17.1 aktualisieren. Umsetzung durch Mistral Vibe, Verifikation siehe unten. + +### 15.1 Befund + +a) Gegen 17:36 Uhr zeigten `git.ghostnet.selfhost.eu` (CT 110) „Frontend is not initialized, check console errors or asset files" und `auth.ghostnet.selfhost.eu` (CT 102) eine ungestylte Seite. +b) Über NPM lieferten alle gehashten Gitea-Assets (JS/CSS/Bilder) HTTP 200 mit **0 Byte Body** (Header behauptete z. B. `content-length: 661667`); Keycloak-CSS ebenso 0 B statt 1158689 B. +c) Die Backends waren gesund: direkt von CT 103 aus lieferte `10.0.0.17:3000` das JS mit 661667 B, `10.0.0.4:8080` die Keycloak-CSS mit 1158689 B. +d) `df -h /` auf CT 103: 7,8 G, **100 % belegt, 0 verfügbar**; `du` sah nur 1,3 G (Rest in root-only-Verzeichnissen bzw. gelöschten, von Prozessen gehaltenen Dateien). `logrotate.service` und `man-db.service` standen auf `failed`. Inodes unkritisch (26 %). + +### 15.2 Ursache + +Die NPM-Zugriffslogs unter `/opt/nginx-proxy-manager/data/logs/*.log` hatten **keine Logrotate-Policy** und wuchsen unbounded. Weil nginx im Container die Datei-Handles hält, landet selbst gelöschter Logplatz nicht wieder im freien Bestand (deleted-open inodes). Bei voller Platte kann nginx Proxy-Antworten größer als der Speicherpuffer nicht in Temp-Dateien schreiben und schneidet sie ab — daher 200 mit 0-Byte-Body. Alle Dienste hinter NPM waren betroffen, nicht nur Gitea/Keycloak. + +### 15.3 Lösung (Ansible-Sollzustand, Branch `lxc/ct-103-gnai-006-disk-housekeeping`) + +a) Neues Role `reverse_proxy_disk_housekeeping` in `site.yml` (`proxmox/lxc/ct-103-reverse-proxy/ansible/`), dazu Playbook `disk-housekeeping.yml`: + - Journald-Drop-in `/etc/systemd/journald.conf.d/99-ghostnet-limits.conf` (`SystemMaxUse=200M`, `MaxRetentionSec=7d`) + - Logrotate-Policy `/etc/logrotate.d/nginx-proxy-manager` für `/opt/nginx-proxy-manager/data/logs/*.log` mit **`copytruncate`** (Pflicht wegen der offenen FDs im Container), weekly, rotate 4, compress/delaycompress + - Selbstheilender Guard: unterschreitet der freie Root-Platz die Schwelle `reverse_proxy_minimum_root_available_bytes` (1 GiB, ohnehin in `audit-production.yml` assertet), vacuumt das Role das Journal, truncatet die NPM-Logs in-place, leert den NPM-Proxy-Cache und startet NPM neu; danach wird der Headroom erneut assertet. Die Aufräum-Phase läuft vor dem Schreiben der Configs, weil bei 0 Byte frei keine neuen Dateien anlegbar sind. + - Failed-Zustand der betroffenen oneshot-Units (`logrotate.service`, `man-db.service`) wird gecleared. +b) `verify-production.yml` asserten jetzt zusätzlich Root-Headroom und die beiden Drop-ins. +c) Verifikation: `disk-housekeeping.yml` real (24 Logs getruncat, NPM-Neustart, changed=6, Headroom-Assert bestanden), `site.yml` ok=93 changed=1 failed=0, `verify-production.yml` ok=30 failed=0, zweiter `site.yml --check` **changed=0** (idempotent). Platte danach 53 % (3,6 G frei), keine failed units. Extern: Gitea-JS 661667 B, Keycloak-CSS 1158689 B via NPM vollständig; alle VHosts antworten. + +### 15.4 NPM-Upgrade 2.15.1 → 2.17.1 (nginx2root/nginx2shell) + +a) NGINX2Shell/nginx2root = **CVE-2026-123007** (HTTP/2-Flow-Control, memory corruption, alle Releases seit 1.9.5) und **CVE-2026-123633** (HTTP/2 use-after-free, seit 1.19.7); Fixes in **nginx 1.30.7 / 1.31.9** vom 18.11.2026. Der bisherige Stand NPM 2.15.1 mit openresty/1.29.2.5 (nginx 1.29.x) war betroffen; Port 443 ist öffentlich und HTTP/2 aktiv. +b) Ziel **v2.17.1** (GitHub „Latest“, Docker Hub seit 19.11.2026): „updated base OpenResty image with nginx2root backported fixes“ (PR #6058). v2.17.0 hätte nicht genügt (openresty 1.31.8.1 = nginx 1.31.8, ungefixt). `nginx -v` meldet im Container weiterhin `openresty/1.31.8.1` — die Fixes sitzen als Backport im Base-Image. +c) Ablauf: Backup `/opt/nginx-proxy-manager-backup-pre-2.17.1.tar.gz` (63 M) auf CT 103; Pin in `reverse_proxy_npm/defaults` + allen drei Inventaren + Role-README auf `2.17.1`; `site.yml --check --diff` zeigte nur die `Image=`-Zeile; NPM-Neustart zog das Image; `site.yml` ok=93 changed=1 failed=0, `verify-production.yml` ok=30 failed=0, `site.yml --check` changed=0. Alle 7 VHosts (git/auth/nextcloud/vault/jellyfin/japan/mon) funktional getestet. Altes Image 2.15.1 bleibt lokal als Rollback. + +### 15.5 Prävention + +- Logrotation der NPM-Logs und Journald-Cap sind jetzt Sollzustand (Abschnitt 15.3); der Guard heilt eine volle Platte bei jedem `site.yml`-Lauf selbst. +- NPM-Image bleibt gepinnt; Upgrades bewusst per Pin-Änderung im Ansible-Projekt (wie 15.4), nie `latest`. +- Browser-seitig: 0-Byte-Assets waren mit `max-age≈6h` gecacht — nach Proxy-Incidents hart neu laden (Strg+Umschalt+R). +- Offen: Monitoring-Alarm bei >90 % Root-Belegung auf CT 103 (z. B. GNMON), optional Platte vergrößern (`pct resize 103 rootfs +XG` auf dem PVE-Host). diff --git a/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md b/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md new file mode 100644 index 0000000..8019e1d --- /dev/null +++ b/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md @@ -0,0 +1,305 @@ +# Litecoin Wallet LXC (CT 114) – Plan, Prüfung der Recherche und Umsetzungsstand + +**Dokumenten-ID:** GNAI-024-PLAN +**Titel:** Litecoin Full Node (Cold Wallet) als gehärteter unprivilegierter LXC CT 114 auf Ghostnet Proxmox +**Status:** Plan vollständig, reviewed; CT 114 noch nicht angelegt — Provisioning und Konvergenz sind Operator-Schritte (Abschnitt 6) +**Geltungsbereich:** neuer LXC CT 114 `ltc-node` (`10.0.0.61`) auf Proxmox `10.0.0.2`; Änderungen am PVE-Host nur über das bestehende `proxmox/pve-host`-Ansible-Projekt +**Referenzen:** [Auftrag/Research `litecoin-lxc-setup.txt`](litecoin-lxc-setup.txt), [Testplan `litecoin-lxc-tests.txt`](litecoin-lxc-tests.txt), [GNAI-011 SSH-Architektur](../../GNAI-011-SEC_LXC-SSH-Architecture.md), [GNAI-007 Adressplan](../ct-105-wireguard/GNAI-007-SEC_VPN.md), [GNAI-016 Ansible-Rebuild CT 102](../../lxc/ct-102-keycloak/GNAI-016-PLAN_Keycloak-Ansible-Rebuild.md), [CT-114-Automation](../../../../../proxmox/lxc/ct-114-litecoin-wallet/ansible/README.md), [CT-114-Skripte](../../../../../proxmox/lxc/ct-114-litecoin-wallet/scripts/README.md), [Doku-Index](../../../../GNAI-000-DOC_Index.md) + +## Änderungsverlauf + +| Datum | Version | Autor | Änderung | +| --- | --- | --- | --- | +| 2026-11-25 | 0.1 | Mistral Vibe | Erstfassung: Prüfung der beiden Research-Dokumente gegen Repo-Konventionen (Abschnitt 2), Zielarchitektur, Zugriffsmodell, Ansible-Projekt, Provisioning-Skripte, Phasenplan, Abnahmetests. | +| 2026-11-27 | 0.2 | Mistral Vibe | CT 114 produktiv provisioniert und per Ansible konvergiert (Abschnitt 12): Hook grün, Fingerprint gepinnt, nesting=0, site.yml idempotent (changed=0), verify/audit grün, Reboot-Test bestanden, restic-Repo auf ghostnet-ki initialisiert + erster Wallet-Snapshot, PVE-Snapshot-Timer aktiv. | + +## 1. Zweck und Leitentscheidung + +Der Betreiber möchte Litecoin von Bitpanda empfangen und Dienste im Internet +(z. B. Rapidgator) bezahlen — bei bestmöglicher Sicherheit und Privatsphäre. +Leitentscheidung: ein eigener, unprivilegierter LXC **CT 114** betreibt +einen Litecoin Full Node (`litecoind` v0.21.5.8) als Cold Wallet. Der +P2P-Verkehr läuft ausschließlich über Tor (onion-only, `listen=0`), der +RPC ist auf `127.0.0.1:9332` gebunden und nur per SSH-Exec erreichbar. +Kein Port wird nach außen geöffnet; die FRITZ!Box bekommt keinen Forward +für CT 114. + +Die Research-Dokumente (`litecoin-lxc-setup.txt`, `litecoin-lxc-tests.txt`) +werden mit den Befunden in Abschnitt 2 an die etablierten Verfahren des +Repositories angepasst (GNAI-011 SSH-Baseline, nftables statt ufw, +Drei-Inventar-Ansible-Projekte, PVE-Host-Automation, hostunabhängige +Backups, Secret-Regeln). + +## 2. Prüfung der Recherche-Dokumente (Befunde) + +| Nr. | Befund | Entscheidung | +| --- | --- | --- | +| a) | Versionsangabe „v0.21.5.x, mindestens 5.6/5.7/5.8 wegen MWEB-Sicherheitsfixes 2026“ geprüft am 2026-11-25: aktuellstes Release ist **v0.21.5.8** (GitHub, publiziert 2026-09-12); Release-Notes: Maintenance-Release inkl. des nur an Pools verteilten **v0.21.5.7-Sicherheitsfixes** (MWEB-Konsensusregel ab Height 3.172.640), „upgrading strongly recommended“. SHA-256 des x86_64-Tarballs `43200c9f…ab1be9` gegen das signierte `SHA256SUMS.asc` von `download.litecoin.org` verifiziert (Download 2026-11-25, Summe identisch). | Version **0.21.5.8** wird gepinnt; die Rolle `litecoin_core` lädt nur mit `checksum: sha256:43200c9f…` (fail-closed) und assertiert `litecoind --version`. GPG-Verifikation des `SHA256SUMS.asc` mit den Litecoin-Release-Keys bleibt zusätzlicher Operator-Schritt beim manuellen Review. | +| b) | Research schlägt `ufw` vor. Repo-Konvention ist native **nftables** mit eigener `ghostnet_filter`-Tabelle (CT 100/102/103, CT 105). | Rolle `litecoin_firewall` deployt `/etc/nftables.conf`: input policy drop, nur SSH (TCP 22) aus `10.0.0.0/24` + `10.8.0.0/24`, output accept (Tor-Ausgang), forward drop. **Keine** Ports 9333/9332/9050/9051 nach außen. | +| c) | Research nennt `rpcport=8332` — das ist der **Bitcoin**-Port. Litecoin-RPC ist **9332**, P2P 9333. | Korrigiert: `rpcport=9332`, `rpcbind=127.0.0.1`, `rpcallowip=127.0.0.1`. | +| d) | Research empfiehlt RPC-Zugriff per SSH-Tunnel (`ssh -L 8332:...`). Die GNAI-011-Baseline setzt jedoch `AllowTcpForwarding no` **und** `DisableForwarding yes` (CT-102-Dropin, Hook), und die Agenten-Schlüssel sind `restrict`/`no-port-forwarding`. | **Kein SSH-Tunnel.** RPC nur per SSH-Exec: `ssh -F ~/.ssh/config ghostnet-ct114-ghost 'sudo -u litecoin litecoin-cli -conf=/etc/litecoin/litecoin.conf '`; der Agent nutzt den Wrapper `ltc-readonly` (NOPASSWD-Sudo, Kommando-Whitelist, nur Lese-RPCs). | +| e) | Research empfiehlt `rpcauth` (niemals `rpcpassword` im Klartext). | Es wird gar kein RPC-Credential in Dateien abgelegt: **Cookie-Auth** (Default) — `litecoin-cli` läuft als User `litecoin` und nutzt `/var/lib/litecoin/.cookie`. `litecoin.conf` enthält keine Secrets (Mode 0640 root:litecoin). | +| f) | MWEB: Bitpanda und Rapidgator unterstützen keine MWEB-Adressen; `ltcmweb1…` an eine Exchange wäre Verlust. | Wallet erzeugt nur legacy/bech32-Adressen (`getnewaddress "" "bech32"` → `ltc1…`). MWEB bleibt lokal nutzbar (Cake Wallet), wird aber nie an Exchanges/Dienste adressiert. Dokumentiert in `litecoin.conf` und Abschnitt 8. | +| g) | Research nimmt einen „separaten Proxmox Backup Server im LAN“ an, dessen Zugangsdaten der Betreiber liefert. Im Repo existiert **kein PBS**; das etablierte hostunabhängige Backup-Ziel ist der `gn-backup`-Account auf `ghostnet-ki` (`10.0.0.90`, eigene Hardware, Rolle `pve_lxc_backup_sync` / `gn_backup_receiver`). | Default: restic-Repo `sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic` (Inventar-Variable `litecoin_backup_repository`, clientseitig verschlüsselt — das Ziel sieht nur Ciphertext). Falls der Betreiber doch ein PBS betreibt, genügen die PBS-Zugangsdaten als Inventar-Override. **Offener Punkt 11.1.** | +| h) | Research: LXC-Backup „nur Snapshots, kein vzdump“. Repo-Konvention syncet alle `vzdump-lxc-*`-Archive nach ghostnet-ki (`pve_lxc_backup_sync`). | Bewusste, begründete Abweichung: CT 114 wird **nicht** in den vzdump-Job aufgenommen (150 GiB Chain, nächtlich ×4 Archive wären teuer; Chain ist per Neu-Sync rekonstruierbar; `wallet.dat` ist durch restic verschlüsselt **und** durch Snapshots geschützt). Umsetzung: Rolle `pve_lxc_snapshot` (täglich 04:00, 7 Snapshots Retention) + restic aus dem CT. **Operator-Schritt:** CT 114 im PVE-Backup-Job ausschließen (Abschnitt 6, Phase 0). | +| i) | Ressourcen 2 vCPU / 4 GiB / 150 GiB rootfs auf SSD/NVMe. | Übernommen; `local-lvm` (thin, snapshotfähig). Preflight im Provisioning-Skript: `local-lvm` aktiv und ≥ 214 GiB frei. Kein Nesting nötig (kein Podman; `litecoind` als systemd-Service unter User `litecoin`). | +| k) | Research: `onlynet=onion` (P2P ausschließlich zu onion-Peers). Live geprüft 2026-11-27: die kompilierten onion-Seeds von v0.21.5.8 sind alle unerreichbar („host unreachable“ via Tor), während clearnet-via-Tor funktioniert (check.torproject.org via SOCKS: IsTor=true; duckduckgo-onion: HTTP 301). Der Node bliebe ohne Peers. | **Anpassung:** `onlynet=onion` entfällt; mit `proxy=127.0.0.1:9050` geht ALLER Verkehr (DNS-Seeds, clearnet-Peers via Tor-Exits, onion) durch Tor — unsere IP wird nie exponiert, `listen=0`/`discover=0` verhindern Inbound. Audit prüft: jedes Netzwerk hat proxy=127.0.0.1:9050, keine inbound Peers. | +| j) | Debian 13, unprivileged, Key-Only-SSH, fail2ban, unattended-upgrades, dedizierter User `litecoin`. | Übernommen nach Repo-Muster: frischer CT per gepinntem Community-Scripts-`debian.sh` + Bootstrap-Hook (wie CT 102, GNAI-016 Phase D), dann Ansible (`litecoin_lxc_baseline`, `litecoin_access`, `litecoin_fail2ban`, …). `unattended-upgrades` auf Debian-Security eingeschränkt (CT-100/101/102-Konvention). | + +## 3. Zielarchitektur + +| Komponente | Wert | +| --- | --- | +| CT-ID / Hostname | `114` / `ltc-node` | +| IP | `10.0.0.61/24` (statischer Serverbereich bis `.99`; DHCP ab `.100`), GW `10.0.0.1`, DNS `10.0.0.14` (Pi-hole), vmbr0, IPv6 aus | +| OS / Typ | Debian 13, unprivileged, onboot, protection | +| Ressourcen | 2 vCPU, 4096 MiB RAM, 1024 MiB Swap, 150 GiB rootfs `local-lvm` | +| Software | `litecoind` v0.21.5.8 in `/opt/litecoin` (Symlink), `tor` (Client-only, SOCKS 127.0.0.1:9050), nftables, fail2ban, unattended-upgrades, restic | +| Node-Konfig | `proxy=127.0.0.1:9050` (alle Netze, Befund k), `listen=0`, `dnsseed=0`, `upnp=0`, `natpmp=0`, RPC `127.0.0.1:9332` Cookie-Auth, `wallet=cold`, `dbcache=2048` | +| Firewall | nftables default-deny; nur SSH 22 aus LAN/WireGuard; kein Forwarding | +| Backups | täglich 04:00 Snapshot auf PVE (Retention 7, Rolle `pve_lxc_snapshot`) + täglich 03:00 `backupwallet` + restic (verschlüsselt) nach `gn-backup@ghostnet-ki`; monatlich `restic check` | +| Monitoring | systemd-Status in `verify-production.yml`/`audit-production.yml`; GNMON-Integration späterer Schritt (11.4) | + +## 4. Zugriffsmodell (GNAI-011) + +| Konto | UID | Rechte | Schlüssel | +| --- | --- | --- | --- | +| `ghost-agent` | 1000 | locked, `restrict,from="10.0.0.0/24,10.8.0.0/24"`, NOPASSWD nur für `/usr/local/bin/ltc-readonly` (Lese-RPCs als `litecoin`) | `~/.ssh/id_ed25519_ghostnet_ct114_agent` (passphrase-los, 2026-11-25 erzeugt), Alias `ghostnet-ct114-agent` | +| `ghost` | 1001 | passwort-gated sudo | `~/.ssh/id_ed25519_ghostnet_ct114_ghost` (**Operator-Schritt: interaktiv mit Passphrase erzeugen**, Abschnitt 6 Phase 0), Alias `ghostnet-ct114-ghost` | +| `ansible-deploy` | 1002 | locked, `NOPASSWD: ALL`, `restrict,from=…` | `~/.ssh/id_ed25519_ghostnet_ct114_ansible_deploy` (passphrase-los), Alias `ghostnet-ct114-ansible-deploy` | +| `litecoin` | 1100 | Service-Account, `nologin`, locked, kein SSH | — | + +Öffentliche Schlüssel liegen in +[`ansible/files/ssh/`](../../../../../proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh); +`sshd` härtet per Drop-in (`PermitRootLogin no`, PasswordAuthentication no, +`DisableForwarding yes`, AllowUsers nur die drei Konten). Hostkey-Fingerprint +wird nach dem ersten Boot gepinnt (`litecoin_expected_ssh_host_key_fingerprint`, +aktuell `PENDING`-Platzhalter — fail-closed). Optional: `10.0.0.61` in die +WireGuard-Server-Admin-Ziele auf CT 105 aufnehmen (eigener Change, 11.2). + +## 5. Ansible-Projekt + +`proxmox/lxc/ct-114-litecoin-wallet/ansible/` folgt dem CT-102/CT-100-Schema: + +``` +ansible/ +├── ansible.cfg # roles_path inkl. shared/ansible/roles +├── files/ssh/litecoin-*.pub # nur öffentliche Schlüssel +├── inventories/{agent,bootstrap,production}/ +│ ├── hosts.yml # ghost-agent / ghost / ansible-deploy +│ ├── group_vars/litecoin_hosts.yml # Erwartungen, Firewall, Core-Pin, restic-Ziel +│ └── host_vars/litecoin-ct114.yml # CTID 114, IP, Fingerprint-Pin, Ressourcen +├── playbooks/ +│ ├── preflight.yml # read-only, agent-Inventar, Identitäts- und Leerstands-Gates +│ ├── verify-deploy-access.yml # ansible-deploy-Grenze +│ ├── site.yml # Rollen: baseline → access → firewall → fail2ban → tor → core → backup +│ ├── verify-production.yml # read-only Produktions-Verifikation (Listener, Dienste, Firewall, SSH) +│ └── audit-production.yml # read-only Deep-Audit +└── roles/ + ├── litecoin_lxc_baseline # Pakete, litecoin-User (1100), Zeitzone, unattended-upgrades, Verzeichnisse + ├── litecoin_access # Konten, authorized_keys, sudoers, sshd-Dropin, ltc-readonly + ├── litecoin_firewall # nftables ghostnet_filter (default-deny, SSH only) + ├── litecoin_fail2ban # sshd-Jail, systemd-Backend, nftables-Action + ├── litecoin_tor # Client-only torrc, SOCKS 127.0.0.1:9050 + ├── litecoin_core # gepinnter Download (SHA256), litecoin.conf, systemd-Unit, logrotate + └── litecoin_backup # backupwallet + restic (Timers 03:00 / monatlich check) +``` + +## 6. Phasen und Checkliste (Operator-Schritte hervorgehoben) + +- **Phase 0 — Vorbereitung (Operator, Workstation + PVE):** + 1. `ghost`-Schlüssel interaktiv erzeugen (`ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_ghostnet_ct114_ghost -C "ghost@ghostnet-ct114"`), `.pub` nach `ansible/files/ssh/litecoin-ghost.pub` kopieren; `ADMIN_PUBLIC_KEY`-Platzhalter im Hook ersetzen; Hook-SHA neu pinnen (siehe `scripts/README.md` Schritt 0). + 2. restic-Backup-Key für CT 114 erzeugen und für `gn-backup@ghostnet-ki` quellbeschränkt auf `10.0.0.61` autorisieren; privater Key landet später per Operator auf dem CT unter `/etc/litecoin-backup/.ssh/id_ed25519` (0600) — nie im Repo. + 3. CT 114 im PVE-vzdump-Backup-Job ausschließen (Befund h). + 4. Hooks auf dem PVE installieren und SHAs verifizieren; `provision-ct114-litecoin.sh` als root@pve ausführen (erstellt CT 114, setzt Swap, verifiziert Profil + Hook). + 5. `pct exec 114 -- passwd ghost` (interaktiv); Hostkey-Fingerprint pinnen; FRITZ!Box: sicherstellen, dass **kein** Forward auf 10.0.0.61 existiert. +- **Phase 1 — Agent-Preflight:** `preflight.yml` gegen `inventories/agent` mit `--private-key ~/.ssh/id_ed25519_ghostnet_ct114_agent` (read-only, `ghost-agent`). +- **Phase 2 — Deploy-Grenze:** `verify-deploy-access.yml` gegen `inventories/production`. +- **Phase 3 — Konvergenz (braucht explizites Go des Betreibers):** `site.yml --check --diff`, dann `site.yml` gegen `inventories/production`. Zweiter Lauf muss `changed=0` liefern. +- **Phase 4 — Verifikation:** `verify-production.yml`, `audit-production.yml`; LXC-Neustart-Test über PVE (nie boot_id-Waiter, GNAI-016 §7) und erneute Verifikation. +- **Phase 5 — Wallet-Inbetriebnahme (interaktiv, nie im Playbook):** Node syncen lassen (`ltc-readonly getblockchaininfo` → `initialblockdownload: false`), `sudo -u litecoin litecoin-cli … createwallet "cold"`, sofort `encryptwallet` (Passphrase wird nur interaktiv eingegeben und im Secret-Store des Betreibers abgelegt — nie in Repo/Logs), Empfangsadresse `getnewaddress "" "bech32"`, restic-Repo anlegen (`restic init`) mit dem Operator-Passwort, erstes `backupwallet` + `restic backup` + `restic check`. +- **Phase 6 — Abnahme:** Tests aus Abschnitt 10. + +## 7. Sicherheitsregeln (verbindlich) + +- Nie Seed-Phrase, Wallet-Passphrase, restic-Passwort oder private Schlüssel + in Dateien, Repos, Logs oder Tickets — nur Secret-Store (Vaultwarden) / + interaktive Übergabe. +- Keine Ports nach außen öffnen (kein 9333, kein 9332/9050/9051); `listen=0` + nie „zum Debuggen“ aufheben; P2P nur über Tor (SOCKS-Proxy für alle + Netze, Befund k). +- Nur gepinnte, Prüfsummen-verifizierte Software (SHA256-Pin in der Rolle; + GPG-Review des signierten `SHA256SUMS.asc` als Operator-Schritt). +- RPC nur loopback + SSH-Exec; kein Port-Forwarding (GNAI-011). +- Nie MWEB-Adressen (`ltcmweb1…`) an Bitpanda, Rapidgator oder sonstige + externe Dienste; nur `ltc1…`/legacy. +- Zahlungen nur mit kleinen Beträgen nach bestandenem Restore-Test + (Abschnitt 10); Adressen am Bildschirm visuell vergleichen. +- Alle Änderungen dokumentieren (dieses Dokument, Änderungsverlauf). + +## 8. Wallet-Betrieb und Zahlungen (SOP) + +Empfang (Bitpanda → Node): Bitpanda sendet auf die `ltc1…`-Adresse; lokal +`ssh -F ~/.ssh/config ghostnet-ct114-agent 'sudo ltc-readonly getbalance'` / +`listtransactions` (6 Bestätigungen abwarten; zur Prüfung nie öffentliche +Explorer, nur Tor). + +Senden (Node → Bitpanda/Rapidgator): interaktiv als `ghost` oder +`ansible-deploy` per SSH-Exec — kurzes Unlock-Fenster, dann sofort sperren: + +```bash +ssh -F ~/.ssh/config ghostnet-ct114-ghost +sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf walletpassphrase "" 120 +sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf sendtoaddress "" +sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf walletlock +``` + +Die Passphrase wird nur interaktiv eingegeben (ggf. via `read -s` in einer +One-Shot-Shell), nie in History/Dateien. Der Agent-Account kann über +`ltc-readonly` ausschließlich lesend prüfen (getbalance, getblockchaininfo, +getnetworkinfo, getpeerinfo, getwalletinfo, listtransactions, …). + +## 9. Backup- und Restore-Konzept + +- **Snapshot (PVE-Host):** täglich 04:00, Retention 7 — Rolle + `pve_lxc_snapshot` im `proxmox/pve-host`-Projekt (Befund h). +- **Wallet-Backup (im CT):** täglich 03:00 `backupwallet` als `litecoin` + + restic (clientseitig verschlüsselt) nur von `/var/lib/litecoin/backups` + nach `gn-backup@ghostnet-ki` (oder Betreiber-PBS, 11.1); Retention 30 + Tage; monatlich `restic check`. Passwort/Key liegen root-only in + `/etc/litecoin-backup/`. +- **Restore:** Snapshot in PVE zurückspielen **oder** frischer CT 114 per + `provision-ct114-litecoin.sh` + Ansible, Chain neu syncen, `wallet.dat` + aus restic zurückspielen, `walletpassphrase` → fertig. Restore-Test + vor dem ersten nennenswerten Betrag (Abschnitt 10, Phase 1). + +## 10. Abnahmetests (aus `litecoin-lxc-tests.txt`, an Repo-Verfahren angepasst) + +- **Phase 0 (vor dem ersten Euro):** Node gesynct (`initialblockdownload: + false`); `getnetworkinfo`: ipv4/ipv6/onion alle via `proxy=127.0.0.1:9050`, + keine lokalen Adressen; Wallet verschlüsselt + (`getwalletinfo.unlocked_until` nur nach `walletpassphrase`); `nmap` von + einem anderen LAN-Gerät gegen `10.0.0.61` → keine offenen Ports außer + SSH-aus-dem-LAN-Ergebnis; Snapshot-Liste auf PVE; `restic snapshots` und + `restic check` fehlerfrei; `verify-production.yml` + `audit-production.yml` + bestanden; `site.yml`-Zweitlauf `changed=0`. +- **Phase 1 (Restore zuerst):** Snapshot-Restore auf einen Scratch-CT + (wie CT 150 bei CT 100) testen; `wallet.dat` aus restic auf Test-CT + einspielen, mit `walletpassphrase` öffnen, `getbalance` zeigt Test-Coins; + Seed/Metall-Backup physisch prüfen. +- **Phase 2 (kleine echte Beträge):** Bitpanda → `ltc1…` (kleinster Betrag, + 6 Bestätigungen, `listtransactions`); Node → Bitpanda zurück; Node → + Cake Wallet; Cake → extern. Nie über öffentlichen Explorer prüfen. +- **Phase 3 (MWEB, klein):** peg-in/peg-out in Cake Wallet; nie MWEB an + Bitpanda/Rapidgator. +- **Phase 4 (Notfall):** Server aus → Cake Wallet unabhängig; Handy weg → + Cake-Seed auf zweitem Gerät; `walletlock` → Senden ohne Passphrase schlägt + fehl. +- **Bericht an den Betreiber:** CT-ID, IP, Core-Version + SHA-256, + Sync-Status, Snapshot-/restic-Listen, Firewall-Regeln, RPC-Variante + (SSH-Exec, Befund d), Doku-Link. + +## 11. Offene Punkte / Entscheidungen des Betreibers + +1. **Backup-Ziel:** Default `gn-backup@ghostnet-ki` (Befund g). Falls ein + separater PBS im LAN existiert: Zugangsdaten liefern, Inventar-Variable + `litecoin_backup_repository` überschreiben und Ziel-Hostkey pinnen. +2. **WireGuard-Zugriff:** `10.0.0.61` auf CT 105 in die Server-Admin-Ziele + aufnehmen? (Default: nein, LAN-SSH genügt.) +3. **vzdump-Ausschluss CT 114** im PVE-Backup-Job bestätigen (Befund h). +4. **GNMON-Monitoring** für CT 114 (Node synced, Backup-Timer) als Folge-Schritt. +5. **IP/CT-ID bestätigen:** CT 114 / `10.0.0.61` waren am 2026-11-25 frei + (dokumentiertes Inventar: CT 100–105, 110, 116; IPs .2–.90 belegt, .61 + frei). Vor Provisioning live gegen `pct list` prüfen — das + Provisioning-Skript fail-closed bei belegter ID. + +## 12. Implementierungsstand 2026-11-25 + +- Branch `lxc/ct-114-gnai-024-litecoin-wallet` (keine Kollision mit + `main` oder anderen Feature-Branches). +- Angelegt: Ansible-Projekt `proxmox/lxc/ct-114-litecoin-wallet/ansible/` + (3 Inventare, 5 Playbooks, 7 Rollen), PVE-Host-Skripte + (`provision-ct114-litecoin.sh` mit gepinnten Community-Scripts-SHAs, + `ghostnet-litecoin-ansible-bootstrap-hook.sh`), Rolle `pve_lxc_snapshot` + im `pve-host`-Projekt, READMEs. +- Workstation: SSH-Keys `id_ed25519_ghostnet_ct114_agent` und + `id_ed25519_ghostnet_ct114_ansible_deploy` erzeugt (passphrase-los), + Aliase `ghostnet-ct114-{agent,ghost,ansible-deploy}` in `~/.ssh/config`. +- **2026-11-27 (Operator):** `ghost`-Key interaktiv mit Passphrase erzeugt, + alle drei `.pub` nach `ansible/files/ssh/` kopiert, `ADMIN_PUBLIC_KEY`- + Platzhalter im Hook ersetzt; eingebettete Hook-Keys matchen byte-identisch + mit den Repo-Pubkeys (geprüft), Hook-SHA neu gepinnt + (`9e1db709…14d69`, siehe `scripts/README.md`). +- Verifiziert: Litecoin v0.21.5.8 SHA-256 gegen signiertes `SHA256SUMS.asc` + (Befund a); Shell-Syntax aller Skripte; Ansible-Syntax aller Playbooks; + yamllint, Secret-Scan und Markdown-Linkcheck (CI-Skripte lokal) bestanden. +- **2026-11-27:** restic-Key `id_ed25519_ghostnet_ct114_restic` + (`restic@ct114`, Fingerprint `SHA256:i4UFMsAmdGdi8s0pJeVnK7Ros1liEqXzJ2IghyBCBiU`) + erzeugt und als `ct114-restic.pub` in der Rolle `gn_backup_receiver` + (llm-server/host) hinterlegt, quellbeschränkt auf `10.0.0.61`, plus + Zielverzeichnis `/var/lib/ghostnet-ai-backup/ct114` für das restic-Repo. + Anwenden auf ghostnet-ki per `llm-server/host/ansible` `host.yml` + (Operator, mit Go). +- **2026-11-27 — CT 114 ist produktiv (Infrastruktur), Wallet noch unverschlüsselt:** + - CT 114 angelegt (`ltc-node`, 10.0.0.61, unprivileged, 2 vCPU/4096 MiB/1024 + Swap, 150G local-lvm, nesting/keyctl **0** — nachträglich gesetzt, das + Provisioning-Skript pinnt das jetzt ab), Bootstrap-Hook grün + (`ghost-agent` 1000 / `ghost` 1001 / `ansible-deploy` 1002, gelockt, + quellbeschränkte Keys); Hostkey `SHA256:nkRMQWpzpBkUaGNOgyCRsEaXK2KhdraTuiL5ihUdXW4` + in allen drei host_vars gepinnt. + - Ansible: preflight (agent) ok=13, verify-deploy-access ok=5, site.yml + konvergiert, danach `changed=0`; verify-production ok=27 und + audit-production ok=23 grün; `pct reboot 114` bestanden (0 failed units; + dev-mqueue/run-lock/tmp.mount sind ohne nesting maskiert). + - Listener: nur 22 (nftables auf LAN/WG beschränkt), 9332 + 9050 loopback; + litecoind v0.21.5.8 läuft, Tor `Bootstrapped 100%`, onion-only + (`getnetworkinfo`: onion reachable, ipv4/ipv6 nicht). Sync läuft + (`initialblockdownload: true`). **2026-11-27 später:** Befund k — + onion-Seeds tot, daher Umstellung auf „alles via Tor“ (proxy für alle + Netze, kein Inbound); danach Peer-Aufbau und Sync verifiziert (Header-Sync + 18000 → 300000+ in Minuten, Peers via Tor-Exit, Tip 3220399). Tor-Exit- + Verbindungen auf 9333 churnen — Sync dauert länger, läuft aber stabil. + `pct reboot`-Warnung 'Systemd 257 … nesting' ist bei nesting=0 erwartete + Kosmetik: nach Reboot 0 failed units, alle Services aktiv, + is-system-running=running (dev-mqueue/run-lock/tmp.mount maskiert). + - restic: Key von CT 114 (10.0.0.61) auf gn-backup@ghostnet-ki positiv + getestet, von der Workstation negativ (Permission denied); Repo + `sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic` + initialisiert, `restic check` clean; Timer 03:00 + monatlicher Check + aktiv; erster Lauf: Snapshot `35be2d5c` (wallet-2026-11-27). + restic-Passwort wurde **on-target** generiert + (`/etc/litecoin-backup/restic-password`, 0600) — Operator holt es einmal + per Konsole und legt es im Vaultwarden ab. + - **Speicherbudget (gemessen 2026-11-27):** rootfs 147 GiB, belegt 3,1 GiB + (Blockdateien sparse preallokiert). Prognose Vollsync: Chain ~60–90 GiB + + chainstate ~5–10 GiB → datadir < 100 GiB, passt in die 150 GiB. restic + sichert nur `backups/` (wallet.dat ~2,2 MiB/Tag → ~1 GiB/Jahr auf + ghostnet-ki, client-seitig verschlüsselt); PVE-Snapshots (Retention 7) + wachsen um den täglichen Chain-Zuwachs. RAM: litecoind-Peak ~2,5 GiB + (dbcache=2048) innerhalb der 4 GiB. + - PVE-Host: `pve_lxc_snapshot` aktiv, erster Snapshot + `ghostnet-daily-20261127-072519`, Timer täglich 04:00 (Retention 7). + vzdump: kein Cluster-Backup-Job vorhanden, der CT 114 fassen würde + (`pvesh get /cluster/backup` leer) — Befund h damit erledigt. + - Wallet `cold` per `createwallet` angelegt; **`encryptwallet` ist der + nächste Operator-Schritt** (exakter Befehl siehe „Noch offen“) — bis + dahin darf kein Betrag auf den Node. + - Fixes unterwegs (alle gecommitt): awk-END-Falle im Storage-Gate, sed traf + die Hook-Guard-Zeile (Pin aktualisiert), delegate_to-Tasks brauchen + become: false, Debian 13 hat kein torctl (Journal statt Dateilog), + sshd -T listet allowusers zeilenweise, sudoers ist (root)-beschränkt + (ltc-readonly statt sudo -u), restic 0.18 braucht sftp.command als + komplette Zeile inkl. Host + `-s sftp` und `-o` nach dem Subcommand. +- **2026-11-27 (Operator erledigt):** `pct exec 114 -- passwd ghost` gesetzt; + restic-Passwort aus `/etc/litecoin-backup/restic-password` geholt und im + Vaultwarden abgelegt. +- **Noch offen (Operator, manuelle Eingabe):** `encryptwallet` mit Passphrase + — Daemon läuft mit `-conf=/etc/litecoin/litecoin.conf -datadir=/var/lib/litecoin`, + Cookie unter `/var/lib/litecoin/.cookie`; die cli braucht daher **explizit + `-conf=/etc/litecoin/litecoin.conf`** (sonst sucht sie in + `$HOME/.litecoin` und findet kein Cookie). Passphrase via `-stdin`, nie als + argv (sonst in Host-`ps`/Logs); `-stdin` liest eine JSON-gequotete Zeile: + `printf '"%s"\n' '' | pct exec 114 -- sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf -stdin encryptwallet` + danach `pct exec 114 -- systemctl restart litecoind`. FRITZ!Box-Check (kein + Forward auf 10.0.0.61); Abnahmetests Abschnitt 10 (Restore-Test vor erstem + Betrag); PR gegen main. diff --git a/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-setup.txt b/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-setup.txt new file mode 100644 index 0000000..d160907 --- /dev/null +++ b/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-setup.txt @@ -0,0 +1,119 @@ +# Auftrag: Litecoin Full Node (Cold Wallet) als LXC auf Proxmox + +**Ziel:** Ein gehärteter, unprivilegierter LXC auf dem Proxmox-Host betreibt einen eigenen Litecoin Full Node (`litecoind`) als Cold Wallet. P2P-Traffic läuft ausschließlich über Tor, RPC-Zugriff nur lokal per SSH-Tunnel. Backups: tägliche LXC-Snapshots + tägliches verschlüsseltes `wallet.dat`-Backup auf einen separaten Proxmox Backup Server im LAN. + +**Voraussetzungen (vom Auftraggeber vorgegeben):** +- Nur **Litecoin Core** (kein ElectrumX, kein GUI-Client im LXC) +- LXC-Backup: **nur Snapshots**, kein externes/vzdump-Backup des Containers +- Wallet-Backup: **separater Proxmox Backup Server im lokalen Netz** als Ziel (restic, client-seitig verschlüsselt) +- RPC-Zugang: Agent wählt die sicherste praktikable Variante und dokumentiert sie (Empfehlung: `rpcbind=127.0.0.1` + SSH-Tunnel) + +--- + +## 1. LXC anlegen (Proxmox VE) + +- Template: **Debian 13** (aktuelles offizielles Template) +- **Unprivileged** lassen (Default) +- Ressourcen: **2 vCPU, 4096 MB RAM, 150 GB rootfs** auf SSD/NVMe-Storage (Chain ~100 GB + Wachstum; NVMe wegen random I/O) +- Hostname: `ltc-node`; feste LAN-IP oder DHCP-Reservierung (nächste freie ID wählen, im Router reservieren) +- Kein Port-Forwarding, keine Bridge-Exposure außer LAN + +## 2. Container härten + +- SSH: Key-Only (`PasswordAuthentication no`, `PermitRootLogin no`), `fail2ban` installieren +- `unattended-upgrades` aktivieren (Security-Updates automatisch) +- Firewall `ufw`: default **deny incoming**, default allow outgoing; **keine Ports öffnen** (weder 9333 P2P noch 8332/8333 RPC) +- Dedizierter User `litecoin` (nicht root) für `litecoind`; datadir `/var/lib/litecoin` + +## 3. Tor installieren (im selben LXC) + +- `apt install tor`, Service aktivieren +- `torrc`: SOCKS-Proxy auf `127.0.0.1:9050` (Default), `ControlPort 9051` optional für auto-Onion-Service + +## 4. Litecoin Core installieren (verifiziert) + +- **Neueste stabile Version** herunterladen von `https://download.litecoin.org/` (Stand 2026: Reihe **v0.21.5.x**, mindestens v0.21.5.6/5.7/5.8 wegen der MWEB-Sicherheitsfixes 2026 – nie eine ältere Version) +- **SHA256-Summe prüfen** (aus den offiziellen release notes) **und Signatur verifizieren** (Signing-Key des Litecoin-Projekts, z. B. laanwj) +- Installation nach `/opt/litecoin-`, Symlink `/opt/litecoin` +- systemd-Unit `litecoind.service`: User `litecoin`, `ExecStart=/opt/litecoin/bin/litecoind -datadir=/var/lib/litecoin -conf=/etc/litecoin/litecoin.conf`, Restart=on-failure, Hardening (NoNewPrivileges, ProtectSystem=strict außer datadir, PrivateTmp) + +## 5. litecoin.conf (Kernstück) + +```ini +# Netzwerk: nur Tor, kein Clearnet, kein Inbound +proxy=127.0.0.1:9050 +onlynet=onion +listen=0 +discover=0 +upnp=0 + +# RPC: nur lokal, Agent entscheidet final (Empfehlung: SSH-Tunnel) +server=1 +rpcbind=127.0.0.1 +rpcallowip=127.0.0.1 +# rpcauth=:$ (niemals rpcpassword im Klartext) +rpcport=8332 + +# Performance / Wallet +dbcache=2048 +txindex=0 +wallet=cold +fallbackfee=0.0001 +``` + +## 6. Wallet einrichten + +1. Node starten, Sync abwarten (`litecoin-cli getblockchaininfo` → `initialblockdownload: false`) +2. `litecoin-cli -conf=/etc/litecoin/litecoin.conf createwallet "cold"` +3. **Sofort verschlüsseln:** `encryptwallet ""` – Passwort wird **nie** in Dateien, Logs oder diesem Auftrag gespeichert; Übergabe nur über vom Auftraggeber vorgesehenen Secret-Kanal +4. Empfangsadresse erzeugen und dokumentieren: `getnewaddress "" "bech32"` (nur legacy/bech32 – **Bitpanda unterstützt kein MWEB**, daher nie `ltcmweb1` an Bitpanda) +5. Descriptor/Seed-Infos exportieren und sicher ablegen (siehe Abschnitt 8) + +## 7. Snapshots (LXC-Backup, täglich) + +- Proxmox-Job oder Cron auf dem Host: täglicher **Snapshot** des LXC (Storage mit Snapshot-Support: ZFS oder LVM-thin), Retention z. B. 7 Stück +- Snapshot schützt gegen Korruption – ersetzt **nicht** das Wallet-Backup (Abschnitt 8) + +## 8. Verschlüsseltes wallet.dat-Backup zum separaten PBS im LAN (täglich) + +- `restic` im LXC installieren; Repo auf dem **separaten Proxmox Backup Server im LAN** anlegen (Zugriff per SSH), **client-seitige Verschlüsselung** (restic-Standard) +- Cron täglich 03:00 Uhr im LXC: + - `litecoin-cli backupwallet /var/lib/litecoin/backups/wallet-$(date +%F)` + - `restic backup /var/lib/litecoin/backups` (nur backups/, **nie** die komplette Chain – die wird bei Restore neu gesynct) + - `restic forget --keep-daily 30 --prune` +- Zugangsdaten/Passwörter für restic liegen im Secret-Store des Auftraggebers, nicht in Cron-Files im Klartext (restic nutzt RESTIC_PASSWORD_FILE oder env aus systemd-Credentials) +- Monatlich: `restic check` als Test + +## 9. Monitoring & Doku + +- systemd-Status `litecoind` + `tor` überwachen; Alarm wenn Node nicht synced (`getblockchaininfo`) +- `logrotate` für litecoin debug.log +- Doku im LXC (`/root/README.md`): genutzte Befehle, SSH-Tunnel-Anleitung, Restore-Anleitung: + - Snapshot-Restore in Proxmox **oder** + - frischer LXC + Core neu installieren + Chain neu syncen + `wallet.dat` aus restic zurückspielen + `walletpassphrase` → fertig +- Changelog aller Änderungen pflegen + +## 10. Abnahmetest (muss bestanden werden) + +1. Kleinen LTC-Betrag von Bitpanda auf `getnewaddress` (bech32/legacy) senden → 6 Bestätigungen abwarten → in `listtransactions` sichtbar +2. Test-Sendung kleiner Betrag zurück an Bitpanda → Tx via Tor gebroadcastet (Log/`getnetworkinfo` prüfen: nur onion-Verbindungen, `listen=0`) +3. Snapshot erstellen + auflisten +4. restic-Backup ausführen + `restic snapshots` + `restic check` erfolgreich +5. Firewall verifizieren: von außen kein Port offen (`nmap` vom anderen LAN-Gerät gegen LXC-IP) +6. Bericht an Auftraggeber: LXC-ID, IP, installierte Core-Version + Prüfsumme, Sync-Status, Snapshot-Liste, restic-Snapshot-Liste, Firewall-Regeln, gewählte RPC-Variante + Doku-Link + +## 11. Sicherheitsregeln (verbindlich) + +- **Nie** Seed-Phrase, wallet-Passwort, restic-Passwort, RPC-Credentials in Klartext in Dateien, Repos, Logs oder diesen Auftrag schreiben – nur verschlüsselt/secret +- Keine Ports nach außen öffnen (kein 9333, kein 8332/8333) +- Nur signierte/verifizierte Software-Downloads (SHA256 + GPG) +- Node nur über Tor erreichbar (onion-only); `listen=0` nicht „zum Debuggen“ aufheben +- Bitpanda/Handelsplätze: immer nur legacy/bech32-Adressen, nie MWEB-Adressen an Exchanges +- Alle Änderungen dokumentieren + +## 12. Offene Punkte (Agent entscheidet und dokumentiert) + +- LXC-ID, LAN-IP, Hostname (nächste freie Werte, DHCP-Reservierung vorschlagen) +- Finale RPC-Zugriffsvariante (Empfehlung: `rpcbind=127.0.0.1` + `ssh -L 8332:127.0.0.1:8332 ltc-node` vom Desktop) +- Snapshot-Zeitplan/Retention (Vorschlag: täglich, 7 behalten) +- restic-Repo-Details auf dem PBS (Ziel-URL/SSH-Host werden vom Auftraggeber geliefert) diff --git a/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-tests.txt b/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-tests.txt new file mode 100644 index 0000000..0da39e2 --- /dev/null +++ b/docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-tests.txt @@ -0,0 +1,37 @@ +Der wichtigste Test ist nicht „funktioniert eine Zahlung“, sondern **„komme ich an mein Geld, wenn etwas schiefgeht“**. Deshalb in dieser Reihenfolge, immer mit kleinen Beträgen: + +## Phase 0: Setup-Checks (vor dem ersten Euro) +- Node vollständig gesynct: `litecoin-cli getblockchaininfo` → `initialblockdownload: false`, Block-Höhe nahe dem Netzwerk-Top +- Nur Tor: `litecoin-cli getnetworkinfo` → Verbindungen nur `onion`, `listen=0` aktiv +- Wallet verschlüsselt: `litecoin-cli getwalletinfo` → `unlocked_until` nur nach `walletpassphrase`; ohne Passwort keine Sends möglich +- Firewall: von einem anderen LAN-Gerät `nmap ` → keine offenen Ports +- Backups laufen: Snapshot-Liste in Proxmox, `restic snapshots` zeigt Einträge, `restic check` fehlerfrei + +## Phase 1: Restore-Test (das wichtigste zuerst!) +Bevor nennenswert Geld drauf ist: +1. **Snapshot-Restore testen:** Snapshot des LXC in Proxmox zurückspielen (auf Kopie/CT-ID testen), prüfen ob `litecoind` startet und Wallet intakt +2. **Wallet-Restore testen:** `wallet.dat` aus restic auf einem Test-Rechner/Test-CT einspielen, Core mit `walletpassphrase` öffnen, `getbalance` zeigt die Test-Coins → Beweis, dass das Backup funktioniert +3. Seed/Metall-Backup physisch prüfen:Offline-Leseprobe (Wörter lesbar, vollständig) + +## Phase 2: Kleine echte Transaktionen (Cent- bis zweistellige Beträge) +1. **Bitpanda → Node:** kleinsten Betrag auf `getnewaddress "" "bech32"` senden, Adresse doppelt prüfen (kopieren, nicht abtippen), 6 Bestätigungen abwarten, in `listtransactions` prüfen – **nicht über öffentlichen Explorer** (der sieht deine Adresse; wenn doch, nur über Tor) +2. **Node → Bitpanda zurück:** `sendtoaddress` kleiner Betrag, prüfe im Bitpanda-Konto den Eingang; damit ist Ein- und Auszahlung bewiesen +3. **Node → Handy (Cake Wallet):** kleiner Betrag an die Cake-Adresse, warte Bestätigungen, in Cake Wallet sichtbar +4. **Handy → externe Adresse:** von Cake Wallet kleiner Betrag zurück an Node-Adresse oder Bitpanda + +## Phase 3: MWEB-Test (klein) +- In Cake Wallet oder Electrum-LTC: kleiner Betrag peg-in (MWEB-Adresse `ltcmweb1...`), innerhalb MWEB kleine Sendung, dann peg-out zurück auf normale Adresse +- Prüfen: an **Bitpanda/Rapidgator nie MWEB-Adressen** senden (da gehen Coins verloren) + +## Phase 4: Notfall-Übung +- Server ausmachen → Cake Wallet funktioniert unabhängig (Hot Wallet) +- Handy weg/defekt → Cake-Seed auf neuem Gerät wiederherstellen (Test mit zweitem Gerät) +- Node-Wallet-Sperre testen: `walletlock` → Senden ohne `walletpassphrase` muss fehlschlagen + +## Rote Linien währenddessen +- Nie Seed-Phrase irgendwo eingeben – auch nicht „zum Testen“ in Webseiten/Apps +- Nie größere Beträge, bevor Phase 1–3 bestanden sind +- Jede Adresse auf dem Bildschirm visuell vergleichen (bei Hardware-Wallet: auf dem Gerät) +- Logs/Fehler dokumentieren, bevor du weitermachst + +**Faustregel:** Wenn Restore-Test + kleine Ein-/Auszahlung + MWEB-Rundtrip bestanden sind, ist das Setup produktiv. Erst dann größere Beträge von Bitpanda rüberschieben – und auch dann immer erst Testbetrag, dann Rest. diff --git a/docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md b/docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md new file mode 100644 index 0000000..d9f4bc7 --- /dev/null +++ b/docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md @@ -0,0 +1,235 @@ +# Fluxer Chat LXC (CT 117) – Plan, Machbarkeitsprüfung und Umsetzungsstand + +**Stand:** 2026-11-30 +**Status:** CT 117 produktiv angelegt; Baseline, Access, Firewall, Podman und der komplette Fluxer-Stack laufen konvergiert (`site.yml`-Zweitlauf `changed=0`, 2026-11-30). Noch offen: Keycloak-Client `fluxer` (Phase 7), NPM-Vhost (Phase 9), Operator-Schritte SSO/DNS/Ports (Phase 8/10), Abnahmetests (Phase 11). + +## Änderungsverlauf + +| Datum | Version | Autor | Änderung | +| --- | --- | --- | --- | +| 2026-11-27 | 1.0 | Mistral Vibe | Erstfassung: Machbarkeitsprüfung (Abschnitt 2), Zielarchitektur, Repo-Artefakte, Operator-Phasen | +| 2026-11-27 | 1.1 | Mistral Vibe / Operator | RAM-Check bestätigt: PVE-Host 32 GiB, 25 % belegt (8 GiB) — 8 GiB für CT 117 unkritisch (Befund d); Phase 1 in Abschnitt 6 erledigt | +| 2026-11-27 | 1.2 | Mistral Vibe | Upstream-Pins gesetzt (Commit 872ed5d, compose-SHA d5558cd, 12 App-Image-Digests); pin-fluxer-images.sh für die restlichen Images; fluxer-worker läuft aus dem fluxer-api-Image | +| 2026-11-27 | 1.3 | Mistral Vibe / Operator | Provisioning: local-lvm-Extraktion schlägt fehl (tar Permission denied), Storage auf daten4 umgestellt (pvesm: daten4 4,7 % belegt); CT 117 noch nicht angelegt | +| 2026-11-27 | 1.4 | Mistral Vibe / Operator | Operator bestätigt: local-lvm hat reichlich Platz und alle bisherigen LXCs liefen dort — Storage-Wechsel auf daten4 war voreilig; Default bleibt local-lvm, Ursache der tar-Permission-denied wird diagnostiziert (LV-Mountpoint nicht schreibbar für uid 100000) | +| 2026-11-27 | 1.5 | Mistral Vibe / Operator | Ursache gefunden: `umask 077` im Provisioning-Skript vererbt sich an `pct create` → rootfs-Mountpoint 0700 root → tar unter lxc-usernsexec får „Permission denied“. Reproduziert (VMID 117 minimal OK, VMID 119 mit umask 077 FAIL). Fix: `umask 022` vor dem pct-Aufruf; Storage bleibt local-lvm | +| 2026-11-27 | 1.6 | Mistral Vibe | Zweiter Skript-Bug gefixt: rootfs-Verify-Regex enthielt `\\$` (literales Dollar statt EOL-Anchor) und matchte nie; jetzt `(,|$)`. Hinweis: Das CT-101-Template-Skript trägt dieselbe latente Regex — dort unberührt. Nach dem Fehllauf muss CT 117 vor dem Retry per `pct destroy 117 --purge` entfernt werden (Guard verhindert sonst den Rerun) | +| 2026-11-29 | 1.7 | Mistral Vibe / Operator | **CT 117 angelegt** (local-lvm, 64 GiB; Host-Key-Fingerprint gepinnt). Provisioning-Fixes aus 1.5/1.6 wirksam; Storage bleibt local-lvm. Compose-Pin korrigiert: main `872ed5d` hat die self-hosting-compose nicht mehr (rexctl-Umbau) — gepinnt auf `3b1eb567` (compose-SHA `1cb102f9…`; `d5558cd…` war die SHA-256 der 404-Seite), livekit.yaml/Caddyfile-SHA mitgepinnt. Preflight-Gate rootfs auf 60 GB dezimal (ext4-Overhead auf 64-GiB-LV). Rollen check-mode-sicher; `remote_tmp = ~/.ansible/tmp` (tmp.mount-Masking unmountet sonst /tmp mitten im Lauf) | +| 2026-11-30 | 1.8 | Mistral Vibe | Alle 18 Image-Digests docker.io-vollqualifiziert in allen drei Inventories (skopeo via `pin-fluxer-images.sh`; podman ohne unqualified-search-registries); Override pinnt alle 25 Services per Digest + `pull_policy: never` | +| 2026-11-30 | 1.9 | Mistral Vibe | Erste podman-compose-1.3.0-Laufzeitbefunde: Gateway verlangt `FLUXER_ERLANG_COOKIE`, Shards `FLUXER_PROFILE_PSEUDONYM_SECRET` (Override injiziert beide als runtime-Secrets); Secret-Generierung idempotent nachziehend (fehlende Keys werden ergänzt, statt nur bei leerer Datei); Firewall erlaubt podman-bridge (aardvark-dns `10.89.0.1:53` + intra-`10.89.0.0/16`) — sonst kein Inter-Container-DNS/Traffic; Unit mit `up -d --force-recreate` + `TimeoutStartSec=1800` (podman-compose recreatet sonst nicht bei .env-Änderung) | +| 2026-11-30 | 1.10 | Mistral Vibe | podman-compose-1.3.0-Substitutionsdefekte: nicht-leere compose-Defaults (`${VAR:-default}`) werden als **Leerstring** substituiert, wenn VAR im .env fehlt (Node-API lehnt leere Booleans ab) — alle Defaults explizit ins .env; 4 verschachtelte `${VAR:-${INNER:-…}}`-Refs werden zerpflückt — in der Adaption geflattet; VAPID-Keys im Fluxer-Format base64url **ohne Padding** (raw 32-Byte-Scalar/65-Byte-Point), falsch formatierte Altwerte regeneriert; seaweedfs-init-Bedingung `service_completed_successfully` wird von podman-compose 1.3.0 nie erfüllt | +| 2026-11-30 | 1.11 | Mistral Vibe | Stack läuft **vollständig und konvergiert** (23 Services Up, seaweedfs-init `Exited (0)` Sollzustand, api/postgres/valkey healthy, app-proxy HTTP 200, `site.yml`-Zweitlauf `changed=0`). Sieben weitere podman-compose/LiveKit-Befunde (Detail in Abschnitt 5a): (a) leer-defaultete `${VAR:-}`-Refs bleiben wörtlich im Container-Env, wenn die Var im .env fehlt → api „Invalid email app base URL"; (b) fehlender Podman-Bridge-Egress → LiveKit-STUN-Crashloop; (c) `depends_on: caddy` crasht podman-compose mit KeyError bei deaktiviertem Edge; (d) gepinnte livekit.yaml erwartet `webhook.api_key: fluxer` → LIVEKIT_API_KEY als Bezeichner fix `fluxer`; (e) `podman wait --condition=running` auf den Oneshot seaweedfs-init blockt ewig; (f) Rollen-Verification um den legitimen `Exited (0)` des Init-Containers erweitert; (g) Idempotenz: SHA-verifizierter Download auf separate `docker-compose.upstream.yml`, aktive Compose nur bei Upstream-Änderung erneuert | +| 2026-11-30 | 1.12 | Mistral Vibe / Operator | **Domain-Kollision korrigiert:** `chat.ghostnet.selfhost.eu` ist der live produktive OpenWebUI-Nutzerpfad (GNAI-001 M6, NPM → 10.0.0.90:8081) — Fluxer erhält `fluxer.ghostnet.selfhost.eu`. Umgezogen: CT-117-Inventories (`fluxer_stack_public_domain`), Keycloak-Client-Spec (CT-102-Rolle, Sync zieht die Redirect-URIs per PUT), NPM-Vhost-Rolle (CT 103), Pi-hole-Split-DNS (CT 100, `chat.` bleibt OpenWebUI vorbehalten), Doku. Keycloak-Client war zwischenzeitlich mit `chat.`-URIs angelegt (Phase-7-Lauf), wird beim nächsten Sync automatisch korrigiert | +| 2026-11-30 | 1.13 | Mistral Vibe / Operator | **Öffentlicher Pfad live:** `https://fluxer.ghostnet.selfhost.eu` → HTTP 200 (LE-Cert), alle vier CTs konvergiert (`changed=0`). Drei Begleitbefunde: (a) **NPM-Vorfall:** der Feature-Branch hatte den nie gemergten lokalen Branch `lxc/ct-103-gnai-006-disk-housekeeping` nicht (NPM 2.15.1→2.17.1, nginx2root/nginx2shell-CVE-Fix vom 26.11.) — der CT-103-Konvergenzlauf baute den Container per Quadlet auf 2.15.1 zurück, der Admin-Backend crashloopete am Migration-Check (`20260906220000_user_permission_meta.js` existiert erst ab 2.16/2.17; öffentliche Vhosts liefen weiter, Admin-API 502). Merge nachgeholt, Quadlet konvergiert auf 2.17.1, Admin-API 200; (b) **Firewall-DNAT-Befund:** per netavark gepublishte Ports laufen nach PREROUTING-DNAT durch die FORWARD-Kette (Ziel = Container-IP im Podman-Netz), input-only-Regeln sehen solchen Traffic nie — Forward-Regeln für NPM→app-proxy/LiveKit-Signaling und (Voice) WAN-Media-Ports ergänzt; (c) **Keycloak-Sync-Drift:** Keycloak liefert `redirectUris` in wechselnder Reihenfolge zurück — Vergleich im Sync-Skript jetzt ordnungsunempfindlich, sonst Dauer-PUT/`changed=1` | + +## 1. Zweck und Leitentscheidung + +Fluxer (AGPL, community-getriebene Revolt-Alternative; Chat + VoIP für +Freundeskreise) selbst hosten als **CT 117** (`fluxer`, `10.0.0.62`) im +bewährten Podman-LXC-Schema des Homelabs: unprivilegierter Debian-13-LXC, +rootful Podman unter systemd, digest-gepinnte Images, nftables default-deny, +drei Inventories (`agent`/`bootstrap`/`production`), PVE-seitige Anlage durch +diesen Operator. Öffentlich erreichbar über den bestehenden NPM-Edge (CT 103) +als `https://fluxer.ghostnet.selfhost.eu`. + +Entscheidungen (Operator-Pending, daher als solche markiert): + +- **D1 (offen für Betreiber):** Instanz öffentlich mit Fluxer-eigener Keycloak-SSO-Login-Seite, Registrierung auf **invite-only** gestellt — nicht zusätzlich hinter oauth2-proxy-IAP (GNAI-023-Muster wäre nachrüstbar). +- **D2 (offen für Betreiber):** Sprach-/Videoanrufe (LiveKit) ja/nein. Ja erfordert WAN-seitige UDP/TCP-Ports (Befund e); nein = reiner Text-Chat hinter NPM. + +## 2. Machbarkeitsprüfung (Befunde) + +Recherche Stand 2026-11-27 (Quellen: fluxer.com, docs.fluxer.com, +github.com/fluxerapp/fluxer `deploy/self-hosting/docker-compose.yml`, DeepWiki +fluxerapp/fluxer, fossengineer.com, selfhostedworld.com): + +| Befund | Ergebnis | | +| --- | --- | --- | +| a) **Auth über Keycloak** | **Machbar, nativ.** Fluxer unterstützt SSO über beliebige OIDC-Provider — Keycloak wird ausdrücklich genannt. Konfiguration im Admin-Panel `/admin` (Instance Settings): Issuer URL, Client ID, Client Secret; Callback-Pfad `/auth/sso/callback`. Keycloak-Seite: confidential Client `fluxer` im Realm `Ghost.net` (Redirect `https://fluxer.ghostnet.selfhost.eu/auth/sso/callback`), anlegbar über die bestehende `keycloak_realm_config`-Rolle (Abschnitt 4). Das Client-Secret wird von Keycloak generiert und vom Operator im Credentials-Tab abgelesen und im Fluxer-Admin-Panel eingetragen — es landet nie im Repo. Zusätzlich: Registrierung invite-only, damit nur Freunde Accounts bekommen. | ✅ | +| b) **Unattended Updates** | **Machbar, zweistufig.** (1) OS: `unattended-upgrades` auf Debian-Security beschränkt — exakt die CT-100/102/103-Konvention, in Rolle `fluxer_lxc_baseline` umgesetzt. (2) Container-Images: Repo-Konvention ist digest-gepinnt + Update per Ansible-Re-Run (`podman-auto-update.timer` bleibt wie bei CT 102/103 deaktiviert). Vollautomatisches `podman auto-update` wäre möglich, aber gegen die Change-Discipline (geprüfte Pins, `--check --diff` vor Produktivlauf) — bewusst nicht eingeschaltet. | ✅ | +| c) **Images/Pinning** | **Machbar.** Offizielle Images `ghcr.io/fluxerapp/fluxer-:v1` (FLUXER_REGISTRY/OWNER/TAG-override-fähig) für api, gateway, worker, media-proxy, app-proxy-self-hosted, static, admin, snowflakes, users, messages, gifs, unfurl, push; Infra: postgres, valkey, nats, meilisearch, seaweedfs, livekit-server, caddy. Die Rolle `fluxer_stack` lädt die upstream-compose am gepinnten Commit mit SHA-256-Check und pinnt Images per Digest (Platzhalter `PENDING-*` failen hart, bis der Operator pinnt). | ✅ | +| d) **Performance** | **Machbar mit Dimensionierung.** Upstream-compose: ~21 Services, docker memory limits summiert ~19,3 GB (Reservierungen deutlich darunter). Für einen Freundeskreis reicht 1 Shard; die Ghostnet-Override setzt upstream-eigene `FLUXER_*_MEMORY_LIMIT`-Knobs (Summe ~6 GiB). CT-Profil: **4 Cores / 8192 MiB RAM / 2048 MiB Swap / 64 GiB rootfs** (`local-lvm`). Ob der PVE-Host das tragen kann, muss der Operator vor Anlage prüfen (`free -h`/`pct config`-Summe auf dem Host — Agent hat keinen pct-Zugang). Erste Last nach Go-Live beobachten (`podman stats`), RAM ggf. auf 12–16 GiB hochziehen. | ✅ mit Bedingung | +| e) **VoIP (LiveKit) hinter NPM** | **Eingeschränkt.** Signaling/WS geht über NPM (`/livekit/` → 10.0.0.62:7880). WebRTC-Media braucht direkte Erreichbarkeit: TCP 7881, UDP 3478 (TURN/STUN), UDP 50000–50100 (RTP) — am besten FRITZ!Box-Portweiterleitung auf 10.0.0.62 plus `use_external_ip`. Alternative: TURN-Server oder Voice deaktivieren (`fluxer_stack_voice_enabled=false`, dann keine WAN-Media-Ports). | ⚠️ nur mit Portweiterleitung | +| f) **Edge/TLS** | **Machbar ohne upstream Caddy.** NPM (CT 103) terminiert TLS (bestehender Wildcard-/A-Record-Mechanismus für `*.ghostnet.selfhost.eu`), die Ghostnet-Override deaktiviert den Caddy-Edge (`profiles: [ghostnet-disabled-edge]`, keine veröffentlichten 80/443) und published nur app-proxy 8080 + LiveKit-Ports auf der CT-IP; nftables lässt HTTP nur von 10.0.0.10/32 (CT 103) zu. Discovery (`/.well-known/fluxer`) und exakte upstream-env-Namen gegen die gepinnte compose prüfen (Operator-Schritt, Rolle failt hart bei abweichenden Servicenamen). | ✅ | + +## 3. Zielarchitektur + +``` +Internet ──TLS──> FRITZ!Box (80/443 → CT 103 NPM; optional 7881/tcp, 3478/udp, + 50000-50100/udp → CT 117 bei Voice) + CT 103 NPM: fluxer.ghostnet.selfhost.eu → 10.0.0.62:8080 (+ /livekit/ → :7880) + CT 117 fluxer (10.0.0.62, Debian 13, unprivileged, nesting=1): + nftables default-deny (SSH aus 10.0.0.0/24+10.8.0.0/24, + 8080/7880 nur von 10.0.0.10, Voice-Ports WAN bei D2=ja) + fluxer-stack.service → podman compose (pinned, pull_policy=never): + app-proxy:8080, livekit:7880(+media), api, gateway, worker, + media-proxy, static, admin, shards, postgres, valkey, nats, + meilisearch, seaweedfs (caddy edge disabled) + Keycloak CT 102: Realm Ghost.net, Client `fluxer` (OIDC-SSO) + Pi-hole CT 100: Split-DNS fluxer.ghostnet.selfhost.eu → 10.0.0.10 +``` + +CT-Profil: 117, `fluxer`, `10.0.0.62/24`, GW `10.0.0.1`, DNS `10.0.0.14`, +`vmbr0`, 4 cores, 8192 MiB, 2048 MiB swap, 64 GiB rootfs `local-lvm` (wie CT 100/101/102/103), +unprivileged, `nesting=1,keyctl=1`, onboot. Backup: CT 117 landet im +bestehenden vzdump-Job (im Gegensatz zu CT 114 ist die rootfs klein); zusätzlich +App-level-Backup (Postgres-Dump + SeaweedFS-Daten) als restic-Job auf ghostnet-ki +ist als Ausbaustufe offen (Abschnitt 11). + +## 4. Keycloak-Integration (Befund a) + +- Realm `Ghost.net`, Client `fluxer` (confidential, standard flow, redirect + `https://fluxer.ghostnet.selfhost.eu/auth/sso/callback`), angelegt über + `proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config` + (neuer Block `keycloak_realm_fluxer_client` in defaults + realm spec + + `keycloak_realm_sync.py` Abschnitt 5). +- Client-Secret: Operator liest es im Keycloak-Credentials-Tab und trägt es + im Fluxer-Admin-Panel `/admin` ein (Issuer + `https://auth.ghostnet.selfhost.eu/realms/Ghost.net`). Nie in git. +- Danach in Fluxer: Registrierung deaktivieren / invite-only, damit nur + Freunde Accounts anlegen können. +- Optional später: zweite IAP-Schicht (oauth2-proxy auf CT 103, GNAI-023-Muster) + mit eigenem Client `fluxer-iap`. + +## 5. Ansible-Projekt und Artefakte + +| Artefakt | Pfad | Inhalt | +| --- | --- | --- | +| Provisioning | `proxmox/lxc/ct-117-fluxer/scripts/provision-ct117-fluxer.sh` | pct create + baseline hook (SHA-256-gepinnt) + configfs-Mask; nie destruktiv | +| Ansible | `proxmox/lxc/ct-117-fluxer/ansible/` | `ansible.cfg`, 3 Inventories, `playbooks/{preflight,site}.yml`, Rollen `fluxer_lxc_baseline`, `fluxer_access`, `fluxer_firewall`, `fluxer_stack` + shared `podman_runtime` | +| Stack | Rolle `fluxer_stack` | gepinnte upstream-compose (SHA-256, `3b1eb567`/`1cb102f9…`) als separate `docker-compose.upstream.yml`; aktive `docker-compose.yml` wird nur bei Upstream-Änderung aus der Kopie erzeugt und lokal adaptiert (Abschnitt 5a); `docker-compose.ghostnet.yml` (Caddy-Edge aus, nur app-proxy/LiveKit published, `pull_policy: never`, journald) + `.env` (0600, Secrets einmalig on-guest generiert) + `fluxer-stack.service`; Image-Digests gepinnt | +| NPM | `proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/` | Vhost `fluxer.ghostnet.selfhost.eu` → 10.0.0.62:8080 + `/livekit/` → :7880, LE-Cert, Fail2Ban-Restart; in CT-103-`site.yml` eingehängt | +| Keycloak | `proxmox/lxc/ct-102-keycloak/.../keycloak_realm_config` | Client `fluxer` (Abschnitt 4) | + +**Begründete Abweichung vom Quadlet-Schema:** Upstream liefert eine einzige +compose-Datei für ~21 Services; die wird gepinnt via rootful `podman compose` +unter einer systemd-Unit gefahren statt in per-service-Quadlets geforkt zu +werden. Das bewährte Schema bleibt überall dort erhalten, wo es zählt: +unprivilegierter LXC, rootful Podman unter systemd, digest-gepinnte Images, +`podman.socket`/`podman-auto-update.timer` deaktiviert, nftables default-deny, +drei Inventories. + +### 5a. podman-compose 1.3.0 — dokumentierte Defekte und die Adaption der gepinnten Compose + +Debian 13 liefert podman-compose **1.3.0** (mit podman 5.4.2), das die +upstream-compose nur mit lokal aufgezeichneten, deterministischen +Transformationen fehlerfrei fährt. Die Rolle lädt die Compose SHA-256-verifiziert +nach `docker-compose.upstream.yml` (bleibt pristin und checksummbar), kopiert sie +bei Upstream-Änderung in die aktive `docker-compose.yml` und wendet dort per +`ansible.builtin.replace` diese Adaptionen an (alle Muster backslash-frei und +MULTILINE-verankert — die replace-Action interpretiert Backslash-Escapes in +Loop-Args unzuverlässig): + +1. **seaweedfs-init-Dep-Kanten entfernt** (api/worker/media-proxy): + `service_completed_successfully` wird von podman-compose 1.3.0 nie erfüllt, + und nach Konvertierung auf `service_started` blockt + `podman wait --condition=running` ewig, sobald der Oneshot-Container + `Exited (0)` ist. Die S3-Buckets persistieren im seaweedfs-data-Volume; + auf einem frischen Volume self-healt api/media-proxy per restart-Policy, + während init läuft. +2. **4 verschachtelte `${VAR:-${INNER:-…}}`-Refs geflattet** (FLUXER_REGISTRY, + FLUXER_VAPID_EMAIL, FLUXER_PASSKEY_RP_ID, FLUXER_PASSKEY_ADDITIONAL_ALLOWED_ORIGINS) + — podman-compose zerpflückt nested defaults und lässt Literale wie `}:` + im Container-Env stehen. +3. **`depends_on: caddy` (app-proxy) entfernt** — mit dem per Override-Profil + deaktivierten Caddy-Edge crasht podman-compose mit `KeyError: 'caddy'` + in `check_dep_conditions`; die Override zeigt DISCOVERY_UPSTREAM_URL direkt + auf die api. + +Zusätzlich gilt für die `.env`: **jede** in der Compose referenzierte Variable +muss explizit stehen — auch die mit leerem Upstream-Default (CSP_*, SMTP-Felder, +KLIPY, EMAIL_APP_BASE_URL). podman-compose 1.3.0 hinterlässt fehlende Variablen +als wörtlichen `${VAR:-}`-String im Container-Env (Befund: api „Invalid email +app base URL") bzw. substituiert nicht-leere Defaults als Leerstring (Node-API +lehnt leere Booleans ab). `FLUXER_EMAIL_APP_BASE_URL` wird auf die Public-URL +gesetzt. + +Firewall-DNAT: per netavark gepublishte Ports (app-proxy 8080, LiveKit +7880/7881/7882/3478/50000-50100) werden in PREROUTING auf die Container-IP +destiniert — der Traffic durchläuft die FORWARD-Kette, nicht input. Die +`fluxer_firewall`-Rolle hält daher neben den input-Regeln explizite +forward-Regeln (NPM → app-proxy/LiveKit-Signaling, bei Voice zusätzlich die +WAN-Media-Ports auf das Podman-Subnetz als Ziel); ein reines input-Regelwerk +würde den Traffic lautlos am default forward deny verwerfen (site30-Befund). + +LiveKit: die gepinnte `livekit.yaml` referenziert `webhook.api_key: fluxer` — +LiveKit exittet sofort mit 0, wenn dieser Name nicht in `LIVEKIT_KEYS` +existiert. `LIVEKIT_API_KEY` ist daher ein **Bezeichner** (fix `fluxer`, +Task erzwingt den Wert idempotent), das zufällige `LIVEKIT_API_SECRET` bleibt +der eigentliche Schutz. `rtc.use_external_ip: true` der gepinnten Config +erfordert ausgehenden STUN; die Firewall erlaubt deshalb vollen +Podman-Bridge-Egress im etablierten Homelab-Muster (wie `keycloak_firewall`, +CT 102) — LiveKit (STUN) und unfurl (Link-Previews beliebiger URLs) brauchen +ihn. + +## 6. Phasen und Checkliste (Operator-Schritte hervorgehoben) + +1. **Operator:** PVE-Host-Kapazität prüfen (`free -h`, Summe memory der CTs vs. RAM); ggf. Profil anpassen. **Erledigt 2026-11-27 (Operator): 32 GiB RAM, 25 % belegt — 8 GiB CT-Profil unkritisch.** +2. **Operator (Workstation):** drei CT-117-Keypairs generieren, `.pub` nach `files/ssh/`, SSH-Aliases `ghostnet-ct117-*` in `~/.ssh/config`. **Erledigt 2026-11-29.** +3. **Operator:** upstream-Commit + compose-SHA-256 pinnen (**korrigiert 2026-11-29: `3b1eb567` / `1cb102f9…`** — `872ed5d`/`d5558cd…` war die 404-Seite, main hat die self-hosting-compose nicht mehr); alle 18 Image-Digests via `proxmox/lxc/ct-117-fluxer/scripts/pin-fluxer-images.sh` ermitteln (skopeo, docker.io-vollqualifiziert) und das YAML in die drei `group_vars/fluxer_hosts.yml` eintragen. **Erledigt 2026-11-30.** Hinweis: `fluxer-worker` existiert nicht als eigenes Image — der Worker läuft aus dem `fluxer-api`-Image. +4. **Operator:** Repo-Dateien per `scp` auf den PVE-Host kopieren (siehe `scripts/README.md`), Hook-SHA verifizieren (`111f1b70…`), dann `GHOSTNET_AGENT_UID=1000 GHOSTNET_ADMIN_UID=1001 bash /root/provision-ct117-fluxer.sh`; danach `pct exec 117 -- passwd ghost`, pubkeys in die authorized_keys, Fingerprint pinnen. **Erledigt 2026-11-29 (CT 117 angelegt, local-lvm, 64 GiB; Fingerprint `SHA256:bL5zdRfuXcspX9gRSuPvLgHzyXJsZo+KsU0jdDqIxrA`).** +5. **Agent:** `preflight.yml` auf `agent`-Inventory (read-only) — Identitäts- und Leerstands-Gates. **Erledigt 2026-11-29 (grün nach rootfs-Gate 60 GB).** +6. **Agent (nach Operator-Go):** `site.yml --check --diff` auf `production`, dann autorisierter `site.yml`-Lauf; zweiter Lauf muss `changed=0` liefern. **Erledigt 2026-11-30** (nach den podman-compose-Adaptionen aus Abschnitt 5a; Zweitlauf `changed=0`, failed=0; 23 Services Up, seaweedfs-init `Exited (0)`, api/postgres/valkey healthy, app-proxy HTTP 200). +7. **Agent:** CT-102-`keycloak_realm_config` laufen lassen (legt Client `fluxer` an). **Erledigt 2026-11-30** (Client angelegt, Redirect-URIs nach Domain-Korrektur per Sync-PUT gezogen, Zweitlauf `changed=0`). +8. **Operator:** Keycloak-Credentials-Tab → Secret in Fluxer `/admin` eintragen (Issuer/Client-ID/Secret), Registrierung auf invite-only. +9. **Agent (nach Operator-Go):** CT-103-`site.yml` mit neuer Rolle `reverse_proxy_fluxer_vhost` (legt NPM-Vhost + LE-Cert an). **Erledigt 2026-11-30** (Vhost + LE-Cert live; NPM dabei wie in 1.13 beschrieben auf den gepinnten CVE-Fix-Stand 2.17.1 konvergiert; Zweitlauf `changed=0`). +10. **Operator:** Pi-hole-Split-DNS `fluxer.ghostnet.selfhost.eu → 10.0.0.10` (**erledigt 2026-11-30 via `dns_pihole`-Rolle, live verifiziert**); FRITZ!Box-Portweiterleitung 7881/tcp, 3478/udp, 50000–50100/udp → 10.0.0.62 nur bei D2=ja (**noch offen**); FRITZ!Box-Portweiterleitung 7881/tcp, 3478/udp, 50000–50100/udp → 10.0.0.62 nur bei D2=ja. +11. **Agent:** Abnahmetests (Abschnitt 10). + +## 7. Sicherheitsregeln (verbindlich) + +- CT 117 unprivileged, `nesting=1,keyctl=1`, configfs-Mount maskiert; GNAI-011-Zugriffsmodell (ghost-agent read-only via Wrapper, ghost password-gated sudo, ansible-deploy NOPASSWD), keine Root-SSH, keine Passwort-Logins. +- nftables default-deny; HTTP/WS nur von CT 103 (10.0.0.10/32); keine direkten WAN-HTTP-Ports; Voice-Media-Ports nur bei explizitem D2=ja. +- Images digest-gepinnt, `pull_policy: never`, `podman.socket` aus; Secrets nur on-guest (0600), nie in git/Logs/Inventories. +- TLS nur am NPM-Edge; HSTS, http2, block_exploits, websocket upgrade am Vhost. +- OS-Security-Updates unattended (Debian-Security only); Stack-Updates nur via gepinnte Re-Runs mit `--check --diff`. +- Fluxer-Registrierung invite-only; SSO zwingend über Keycloak (Lokal-Passwort-Login in Fluxer deaktivieren, wenn vom Admin-Panel unterstützt). +- Secrets (Keycloak-Client-Secret, .env) werden nie im Repo abgelegt; preflight + Rollen failen hart bei PENDING-Platzhaltern. + +## 8. Betrieb (SOP, Auszug) + +- Status: `ssh -F ~/.ssh/config ghostnet-ct117-agent 'sudo /usr/local/bin/fluxer-readonly podman ps'`; Logs: `podman logs` / `journalctl -u fluxer-stack`. +- Stack-Neustart nach Pin-Update: `site.yml`-Re-Run (production) oder manuell `systemctl restart fluxer-stack` auf CT 117. +- Backup: vzdump-Job (PVE) deckt CT 117; App-level (Postgres+SeaweedFS) als restic zu ghostnet-ki ist offen (Abschnitt 11). + +## 9. Backup- und Restore-Konzept + +- PVE-vzdump: CT 117 im bestehenden nächtlichen Job (64 GiB rootfs, Daten in compose-Volumes auf rootfs) + Sync nach ghostnet-ki wie die übrigen CTs. +- App-level: upstream empfiehlt Postgres-Dump + SeaweedFS-Volume (see docs); als restic-Job analog CT 114 (Rolle `litecoin_backup`-Muster) nachrüstbar. +- Restore: frischer CT 117 via provision-Skript + Ansible-Rebuild + Restore der Datenvolumes; Keycloak-Client idempotent via realm_config. + +## 10. Abnahmetests (nach Go-Live) + +1. `https://fluxer.ghostnet.selfhost.eu` lädt (LE-Cert, HSTS, HTTP/2), `/_health` der API OK. +2. Keycloak-SSO: Login über `fluxer`-Client, Callback `/auth/sso/callback` erfolgreich; danach invite-only-Registrierung verifizieren (neuer Account nur per Invite). +3. Gateway-WebSocket (`/gateway`) und `/livekit/` signaling durch NPM (WS-Upgrade) OK; bei D2=ja: Voice-Call-Test zwischen zwei Clients über WAN. +4. Firewall: von extern nur 80/443 (via FRITZ!Box→CT 103) und ggf. Voice-Ports erreichbar; `nft list table inet ghostnet_filter` auf CT 117 zeigt die gesetzten Regeln; direkter Zugriff auf 10.0.0.62:8080 nur von 10.0.0.10. +5. Idempotenz: zweiter `site.yml`-Lauf `changed=0`; preflight auf agent-Inventory clean. +6. Unattended-Upgrades: `unattended-upgrades.service` aktiv, Origins-Pattern nur Debian-Security. + +## 11. Offene Punkte / Entscheidungen des Betreibers + +- D1: IAP zusätzlich ja/nein (Default: nein, Fluxer-SSO + invite-only). +- D2: Voice ja/nein (Default in Inventories: ja; ohne FRITZ!Box-Forwarding auf 10.0.0.62 faktisch nein). +- PVE-Host-RAM reicht für 8 GiB CT 117? (Operator prüft vor Anlage.) +- Exakte upstream-env-Namen (`.env.example`) und Servicenamen gegen gepinnte compose verifizieren; `fluxer_stack_service_*` ggf. anpassen — die Rolle failt mit klarer Meldung. +- App-level-Backup (restic) nachrüsten? +- Öffentlicher DNS: Wildcard `*.ghostnet.selfhost.eu` deckt `chat.` ab (wie research/auth) — Operator bestätigt. + +## 12. Implementierungsstand 2026-11-30 (Abend) + +CT 117 produktiv angelegt (local-lvm, 64 GiB, Fingerprint gepinnt); Baseline, +Access, Firewall, Podman-Runtime und der komplette Fluxer-Stack laufen +konvergiert (`changed=0`, 23 Services Up, seaweedfs-init `Exited (0)`, +api/postgres/valkey healthy). **Öffentlicher Pfad live:** +`https://fluxer.ghostnet.selfhost.eu` → NPM-Vhost (LE-Cert, Zweitlauf +`changed=0`) → app-proxy HTTP 200. Keycloak-Client `fluxer` angelegt und +konvergiert (`keycloak_realm_config`, Zweitlauf `changed=0`), Pi-hole-Split- +DNS live (`dns_pihole`, Zweitlauf `changed=0`). + +Offen: Phase 8 (Operator: Client-Secret aus dem Keycloak-Credentials-Tab ins +Fluxer-Admin-Panel `/admin` — Issuer +`https://auth.ghostnet.selfhost.eu/realms/Ghost.net`, Client-ID `fluxer` —, +Registrierung invite-only), FRITZ!Box-Ports für Voice bei D2=ja (Phase 10), +Abnahmetests (Phase 11, Abschnitt 10) und GNAI-006-Doku-Aktualisierung durch +den CT-103-Branch-Eigentümer (Merge liegt im Feature-Branch). diff --git a/llm-server/host/ansible/files/ssh/ct114-restic.pub b/llm-server/host/ansible/files/ssh/ct114-restic.pub new file mode 100644 index 0000000..43127fb --- /dev/null +++ b/llm-server/host/ansible/files/ssh/ct114-restic.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJZAt2wB48lIH1vSWL7djBHufmnpb19zrSoMw18CeIss restic@ct114 diff --git a/llm-server/host/ansible/roles/gn_backup_receiver/README.md b/llm-server/host/ansible/roles/gn_backup_receiver/README.md index 78fe389..7e66250 100644 --- a/llm-server/host/ansible/roles/gn_backup_receiver/README.md +++ b/llm-server/host/ansible/roles/gn_backup_receiver/README.md @@ -12,6 +12,12 @@ PVE host (GNAI-000 section 4, blocker 4). (`files/ssh/pve-backup.pub`, fingerprint `SHA256:tabCXnfrKhWI2+0F8vZgLqg7JtWn1Xt4ifo8o2KuPNc`) restricted with `from="10.0.0.2"` and no forwarding. +- **2026-11-27 (GNAI-024):** zusatzlicher CT-114-restic-Key + (`files/ssh/ct114-restic.pub`, Fingerprint + `SHA256:i4UFMsAmdGdi8s0pJeVnK7Ros1liEqXzJ2IghyBCBiU`), restricted mit + `from="10.0.0.61"` und no forwarding; Zielverzeichnis + `/var/lib/ghostnet-ai-backup/ct114` (restic-Repo der clientseitig + verschluesselten Wallet-Backups aus CT 114). - Home `/var/lib/ghostnet-ai-backup` stays root-owned `0711` (traversable for sshd StrictModes, not writable); the AI backup archives written by the root `gnai-ai-backup` timer stay root-owned. Only `lxc/` and `.ssh/` diff --git a/llm-server/host/ansible/roles/gn_backup_receiver/defaults/main.yml b/llm-server/host/ansible/roles/gn_backup_receiver/defaults/main.yml index 47b6830..7d5313b 100644 --- a/llm-server/host/ansible/roles/gn_backup_receiver/defaults/main.yml +++ b/llm-server/host/ansible/roles/gn_backup_receiver/defaults/main.yml @@ -22,3 +22,11 @@ gn_backup_lxc_dir: /var/lib/ghostnet-ai-backup/lxc # Restrictions for the PVE backup key (public key in files/ssh/pve-backup.pub). gn_backup_ssh_options: 'from="10.0.0.2",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc' gn_backup_pubkey_file: pve-backup.pub + +# Additional source-restricted receiver keys. CT 114 (Litecoin wallet LXC, +# GNAI-024) pushes its client-side encrypted wallet backups (restic over +# sftp) into gn_backup_ct114_dir; the key may only be used from the CT. +gn_backup_additional_keys: + - file: ct114-restic.pub + options: 'from="10.0.0.61",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc' +gn_backup_ct114_dir: /var/lib/ghostnet-ai-backup/ct114 diff --git a/llm-server/host/ansible/roles/gn_backup_receiver/tasks/main.yml b/llm-server/host/ansible/roles/gn_backup_receiver/tasks/main.yml index fa9565d..c890c6d 100644 --- a/llm-server/host/ansible/roles/gn_backup_receiver/tasks/main.yml +++ b/llm-server/host/ansible/roles/gn_backup_receiver/tasks/main.yml @@ -35,9 +35,13 @@ group: gn-backup mode: "0700" -- name: Install the source-restricted PVE backup key +- name: Install the source-restricted receiver keys ansible.builtin.copy: - content: "{{ gn_backup_ssh_options }} {{ lookup('ansible.builtin.file', role_path ~ '/../../files/ssh/' ~ gn_backup_pubkey_file) }}" + content: |- + {{ gn_backup_ssh_options }} {{ lookup('ansible.builtin.file', role_path ~ '/../../files/ssh/' ~ gn_backup_pubkey_file) }} + {% for key in gn_backup_additional_keys %} + {{ key.options }} {{ lookup('ansible.builtin.file', role_path ~ '/../../files/ssh/' ~ key.file) }} + {% endfor %} dest: "{{ gn_backup_account.home }}/.ssh/authorized_keys" owner: "{{ gn_backup_account.name }}" group: gn-backup @@ -50,3 +54,11 @@ owner: "{{ gn_backup_account.name }}" group: gn-backup mode: "0700" + +- name: Create the CT 114 restic target directory + ansible.builtin.file: + path: "{{ gn_backup_ct114_dir }}" + state: directory + owner: "{{ gn_backup_account.name }}" + group: gn-backup + mode: "0700" diff --git a/proxmox/lxc/ct-100-dns/ansible/inventories/agent/group_vars/dns_hosts.yml b/proxmox/lxc/ct-100-dns/ansible/inventories/agent/group_vars/dns_hosts.yml index cb0310e..accda5a 100644 --- a/proxmox/lxc/ct-100-dns/ansible/inventories/agent/group_vars/dns_hosts.yml +++ b/proxmox/lxc/ct-100-dns/ansible/inventories/agent/group_vars/dns_hosts.yml @@ -36,6 +36,9 @@ dns_pihole_hosts_records: - "10.0.0.10 chat.ghostnet.selfhost.eu" # GNAI-023 M8: GPT Researcher via NPM (CT-103) + oauth2-proxy. - "10.0.0.10 research.ghostnet.selfhost.eu" + # GNAI-025: Fluxer-Chat via NPM (CT-103). chat.ghostnet.selfhost.eu bleibt + # OpenWebUI (GNAI-001 M6) vorbehalten. + - "10.0.0.10 fluxer.ghostnet.selfhost.eu" dns_pihole_timezone: Europe/Berlin dns_pihole_database_max_db_days: 30 dns_pihole_secret_name: pihole_web_password diff --git a/proxmox/lxc/ct-100-dns/ansible/inventories/bootstrap/group_vars/dns_hosts.yml b/proxmox/lxc/ct-100-dns/ansible/inventories/bootstrap/group_vars/dns_hosts.yml index cb0310e..accda5a 100644 --- a/proxmox/lxc/ct-100-dns/ansible/inventories/bootstrap/group_vars/dns_hosts.yml +++ b/proxmox/lxc/ct-100-dns/ansible/inventories/bootstrap/group_vars/dns_hosts.yml @@ -36,6 +36,9 @@ dns_pihole_hosts_records: - "10.0.0.10 chat.ghostnet.selfhost.eu" # GNAI-023 M8: GPT Researcher via NPM (CT-103) + oauth2-proxy. - "10.0.0.10 research.ghostnet.selfhost.eu" + # GNAI-025: Fluxer-Chat via NPM (CT-103). chat.ghostnet.selfhost.eu bleibt + # OpenWebUI (GNAI-001 M6) vorbehalten. + - "10.0.0.10 fluxer.ghostnet.selfhost.eu" dns_pihole_timezone: Europe/Berlin dns_pihole_database_max_db_days: 30 dns_pihole_secret_name: pihole_web_password diff --git a/proxmox/lxc/ct-100-dns/ansible/inventories/production/group_vars/dns_hosts.yml b/proxmox/lxc/ct-100-dns/ansible/inventories/production/group_vars/dns_hosts.yml index cb0310e..accda5a 100644 --- a/proxmox/lxc/ct-100-dns/ansible/inventories/production/group_vars/dns_hosts.yml +++ b/proxmox/lxc/ct-100-dns/ansible/inventories/production/group_vars/dns_hosts.yml @@ -36,6 +36,9 @@ dns_pihole_hosts_records: - "10.0.0.10 chat.ghostnet.selfhost.eu" # GNAI-023 M8: GPT Researcher via NPM (CT-103) + oauth2-proxy. - "10.0.0.10 research.ghostnet.selfhost.eu" + # GNAI-025: Fluxer-Chat via NPM (CT-103). chat.ghostnet.selfhost.eu bleibt + # OpenWebUI (GNAI-001 M6) vorbehalten. + - "10.0.0.10 fluxer.ghostnet.selfhost.eu" dns_pihole_timezone: Europe/Berlin dns_pihole_database_max_db_days: 30 dns_pihole_secret_name: pihole_web_password diff --git a/proxmox/lxc/ct-100-dns/ansible/roles/dns_pihole/defaults/main.yml b/proxmox/lxc/ct-100-dns/ansible/roles/dns_pihole/defaults/main.yml index 972ff2f..1cbd2d9 100644 --- a/proxmox/lxc/ct-100-dns/ansible/roles/dns_pihole/defaults/main.yml +++ b/proxmox/lxc/ct-100-dns/ansible/roles/dns_pihole/defaults/main.yml @@ -17,6 +17,9 @@ dns_pihole_hosts_records: - "10.0.0.10 chat.ghostnet.selfhost.eu" # GNAI-023 M8: GPT Researcher via NPM (CT-103) + oauth2-proxy. - "10.0.0.10 research.ghostnet.selfhost.eu" + # GNAI-025: Fluxer-Chat via NPM (CT-103). chat.ghostnet.selfhost.eu bleibt + # OpenWebUI (GNAI-001 M6) vorbehalten. + - "10.0.0.10 fluxer.ghostnet.selfhost.eu" dns_pihole_database_max_db_days: 30 dns_pihole_service_name: pihole.service dns_pihole_quadlet_path: /etc/containers/systemd/pihole.container diff --git a/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/defaults/main.yml b/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/defaults/main.yml index 19ff766..4201bc4 100644 --- a/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/defaults/main.yml +++ b/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/defaults/main.yml @@ -31,3 +31,18 @@ keycloak_realm_research_client: keycloak_realm_research_mapper: name: realm-roles-to-groups claim_name: groups + +# Fluxer-Instanz (GNAI-025, CT 117): OIDC-Client fuer Fluxer-native SSO +# (Admin-Panel /admin: Issuer https://auth.ghostnet.selfhost.eu/realms/Ghost.net, +# clientId `fluxer`, Secret aus dem Keycloak-Credentials-Tab — nie in git). +# Callback-Pfad der Fluxer-App: /auth/sso/callback. +keycloak_realm_fluxer_client: + clientId: fluxer + name: Ghostnet Fluxer (fluxer.ghostnet.selfhost.eu) + rootUrl: https://fluxer.ghostnet.selfhost.eu + redirectUris: + - https://fluxer.ghostnet.selfhost.eu/auth/sso/callback + - https://fluxer.ghostnet.selfhost.eu/auth/sso/callback/* + webOrigins: + - https://fluxer.ghostnet.selfhost.eu + postLogoutRedirectUris: "https://fluxer.ghostnet.selfhost.eu/*" diff --git a/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/files/keycloak_realm_sync.py b/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/files/keycloak_realm_sync.py index 06002fe..a21d0ce 100644 --- a/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/files/keycloak_realm_sync.py +++ b/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/files/keycloak_realm_sync.py @@ -18,6 +18,15 @@ secret = open(secret_file).read().strip() changed = False +def eq(wanted, current): + """Keycloak may reorder list fields (e.g. redirectUris) between PUT and + GET; compare lists order-insensitively so the sync stays idempotent + (GNAI-025 site31-Befund).""" + if isinstance(wanted, list) and isinstance(current, list): + return sorted(map(str, wanted)) == sorted(map(str, current)) + return wanted == current + + def req(method, path, body=None): url = f"{base}{path}" data = None @@ -105,7 +114,7 @@ for k, v in client_body.items(): print(f"DRIFT attributes.{ak}: current={cur_attrs.get(ak)!r} wanted={av!r}", file=sys.stderr) break continue - if current.get(k) != v: + if not eq(v, current.get(k)): drift = True print(f"DRIFT {k}: current={current.get(k)!r} wanted={v!r}", file=sys.stderr) break @@ -157,4 +166,53 @@ if not any(x.get("name") == role_name for x in assigned): assert st == 204, f"role mapping failed: {st}" changed = True +# --- 5) Fluxer OIDC client (GNAI-025, CT 117 chat instance) --- +# Confidential client for Fluxer-native SSO. The client secret is generated +# by Keycloak on creation; the operator reads it in the admin UI (Credentials +# tab) and enters it in the Fluxer admin panel — it never enters git. +fc = spec["fluxer_client"] +fluxer_body = { + "clientId": fc["clientId"], + "name": fc["name"], + "enabled": True, + "protocol": "openid-connect", + "publicClient": False, + "standardFlowEnabled": True, + "directAccessGrantsEnabled": False, + "implicitFlowEnabled": False, + "serviceAccountsEnabled": False, + "rootUrl": fc["rootUrl"], + "redirectUris": fc["redirectUris"], + "webOrigins": fc["webOrigins"], + "attributes": {"post.logout.redirect.uris": fc["postLogoutRedirectUris"]}, +} +st, fclients = req("GET", f"{R}/clients?clientId={urllib.parse.quote(fc['clientId'])}") +assert st == 200, f"fluxer client lookup failed: {st}" +if not fclients: + st, _ = req("POST", f"{R}/clients", fluxer_body) + assert st == 201, f"create fluxer client failed: {st}" + changed = True + st, fclients = req("GET", f"{R}/clients?clientId={urllib.parse.quote(fc['clientId'])}") +ffluxer = fclients[0] +st, fcurrent = req("GET", f"{R}/clients/{ffluxer['id']}") +assert st == 200 +fdrift = False +for k, v in fluxer_body.items(): + if k == "attributes": + cur_attrs = fcurrent.get("attributes") or {} + for ak, av in v.items(): + if cur_attrs.get(ak) != av: + fdrift = True + break + continue + if not eq(v, fcurrent.get(k)): + fdrift = True + break +if fdrift: + fmerged = dict(fcurrent) + fmerged.update(fluxer_body) + st, _ = req("PUT", f"{R}/clients/{ffluxer['id']}", fmerged) + assert st == 204, f"update fluxer client failed: {st}" + changed = True + print("CHANGED" if changed else "UNCHANGED") diff --git a/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/templates/keycloak_realm_spec.json.j2 b/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/templates/keycloak_realm_spec.json.j2 index d360771..d0f4247 100644 --- a/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/templates/keycloak_realm_spec.json.j2 +++ b/proxmox/lxc/ct-102-keycloak/ansible/roles/keycloak_realm_config/templates/keycloak_realm_spec.json.j2 @@ -3,5 +3,6 @@ "research_role": {{ keycloak_realm_research_role | to_json }}, "research_user": {{ keycloak_realm_research_user | to_json }}, "research_client": {{ keycloak_realm_research_client | to_json }}, - "research_mapper": {{ keycloak_realm_research_mapper | to_json }} + "research_mapper": {{ keycloak_realm_research_mapper | to_json }}, + "fluxer_client": {{ keycloak_realm_fluxer_client | to_json }} } diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/README.md b/proxmox/lxc/ct-103-reverse-proxy/ansible/README.md index 0494ba5..0ab1402 100644 --- a/proxmox/lxc/ct-103-reverse-proxy/ansible/README.md +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/README.md @@ -55,6 +55,21 @@ The adoption path mirrors CT 100 and keeps the production proxy intact: The production verifier is read-only. A real `site.yml` run enforces the declared state and therefore requires an explicit change authorization. +## Disk housekeeping (incident 2026-11-26) + +On 2026-11-26 the CT 103 root filesystem filled up: the NPM access logs below +`/opt/nginx-proxy-manager/data/logs` had no logrotate policy, and nginx keeps +deleted inodes open inside the container. NPM then served truncated 0-byte +assets, which surfaced as "Frontend is not initialized" on Gitea (CT 110) and +unstyled Keycloak pages behind the proxy. The `reverse_proxy_disk_housekeeping` +role (part of `site.yml`) declares the countermeasures: a journald size cap, a +`copytruncate` logrotate policy for the NPM logs, and a self-healing guard that +vaciums the journal, purges the NPM proxy cache and restarts NPM whenever the +root headroom drops below `reverse_proxy_minimum_root_available_bytes` +(1 GiB, also asserted by `audit-production.yml` and `verify-production.yml`). +The guard makes every `site.yml` run heal a full root disk reproducibly; once +the headroom is restored, a second run reports `changed=0`. + ## Declared scope and deliberate non-goals - NPM runtime data (SQLite database, keys, Let's Encrypt certificates, diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/agent/group_vars/reverse_proxy_hosts.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/agent/group_vars/reverse_proxy_hosts.yml index 6bb7f4d..e73e423 100644 --- a/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/agent/group_vars/reverse_proxy_hosts.yml +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/agent/group_vars/reverse_proxy_hosts.yml @@ -26,7 +26,7 @@ reverse_proxy_access_source_networks: 10.0.0.0/24 # verify-production.yml can render the templates via lookup and compare them # with the live files (self-contained inventory): reverse_proxy_npm_image: docker.io/jc21/nginx-proxy-manager -reverse_proxy_npm_image_tag: "2.15.1" +reverse_proxy_npm_image_tag: "2.17.1" reverse_proxy_npm_container_name: nginx-proxy-manager reverse_proxy_npm_service_name: nginx-proxy-manager.service reverse_proxy_npm_quadlet_path: /etc/containers/systemd/nginx-proxy-manager.container diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/bootstrap/group_vars/reverse_proxy_hosts.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/bootstrap/group_vars/reverse_proxy_hosts.yml index 6bb7f4d..e73e423 100644 --- a/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/bootstrap/group_vars/reverse_proxy_hosts.yml +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/bootstrap/group_vars/reverse_proxy_hosts.yml @@ -26,7 +26,7 @@ reverse_proxy_access_source_networks: 10.0.0.0/24 # verify-production.yml can render the templates via lookup and compare them # with the live files (self-contained inventory): reverse_proxy_npm_image: docker.io/jc21/nginx-proxy-manager -reverse_proxy_npm_image_tag: "2.15.1" +reverse_proxy_npm_image_tag: "2.17.1" reverse_proxy_npm_container_name: nginx-proxy-manager reverse_proxy_npm_service_name: nginx-proxy-manager.service reverse_proxy_npm_quadlet_path: /etc/containers/systemd/nginx-proxy-manager.container diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/production/group_vars/reverse_proxy_hosts.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/production/group_vars/reverse_proxy_hosts.yml index 6bb7f4d..e73e423 100644 --- a/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/production/group_vars/reverse_proxy_hosts.yml +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/inventories/production/group_vars/reverse_proxy_hosts.yml @@ -26,7 +26,7 @@ reverse_proxy_access_source_networks: 10.0.0.0/24 # verify-production.yml can render the templates via lookup and compare them # with the live files (self-contained inventory): reverse_proxy_npm_image: docker.io/jc21/nginx-proxy-manager -reverse_proxy_npm_image_tag: "2.15.1" +reverse_proxy_npm_image_tag: "2.17.1" reverse_proxy_npm_container_name: nginx-proxy-manager reverse_proxy_npm_service_name: nginx-proxy-manager.service reverse_proxy_npm_quadlet_path: /etc/containers/systemd/nginx-proxy-manager.container diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/disk-housekeeping.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/disk-housekeeping.yml new file mode 100644 index 0000000..36d33eb --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/disk-housekeeping.yml @@ -0,0 +1,13 @@ +--- +- name: Apply the CT 103 disk housekeeping countermeasures + hosts: reverse_proxy_hosts + become: true + gather_facts: true + gather_subset: + - min + - hardware + - network + - virtual + + roles: + - role: reverse_proxy_disk_housekeeping diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/site.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/site.yml index 3eb3e18..ea8a618 100644 --- a/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/site.yml +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/site.yml @@ -25,4 +25,6 @@ - role: reverse_proxy_npm - role: reverse_proxy_oauth2proxy - role: reverse_proxy_research_vhost + - role: reverse_proxy_fluxer_vhost - role: reverse_proxy_fail2ban + - role: reverse_proxy_disk_housekeeping diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/verify-production.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/verify-production.yml index 25b595b..79897fd 100644 --- a/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/verify-production.yml +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/playbooks/verify-production.yml @@ -65,6 +65,33 @@ reverse_proxy_production_services.results | map(attribute='stdout') | unique | list == ['active'] + - name: Require free root filesystem headroom + ansible.builtin.assert: + that: + - >- + ansible_facts['mounts'] | + selectattr('mount', 'equalto', '/') + | map(attribute='block_available') + | map('int') | first * 4096 >= reverse_proxy_minimum_root_available_bytes | int + fail_msg: The root filesystem is low on available bytes. + + - name: Verify the disk housekeeping drop-ins exist + ansible.builtin.stat: + path: "{{ item }}" + loop: + - /etc/systemd/journald.conf.d/99-ghostnet-limits.conf + - /etc/logrotate.d/nginx-proxy-manager + register: reverse_proxy_production_housekeeping_files + + - name: Require the disk housekeeping drop-ins to be present + ansible.builtin.assert: + that: + - reverse_proxy_production_housekeeping_files.results | + map(attribute='stat.exists') | unique | list == [true] + fail_msg: >- + The declared disk housekeeping drop-ins (journald cap, NPM logrotate + policy) are missing. + - name: Require SSH socket activation to be gone ansible.builtin.systemd_service: name: ssh.socket diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/README.md b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/README.md new file mode 100644 index 0000000..b04375d --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/README.md @@ -0,0 +1,24 @@ +# reverse_proxy_disk_housekeeping + +Durable countermeasures for the 2026-11-26 CT 103 incident: the root +filesystem filled up because the NPM access logs below +`/opt/nginx-proxy-manager/data/logs` were not rotated (and nginx keeps +deleted inodes open inside the container), so NPM served truncated 0-byte +assets — visible as "Frontend is not initialized" on Gitea (CT 110) and +unstyled Keycloak pages behind the proxy. + +The role declares: + +- a journald drop-in capping the persistent journal (`SystemMaxUse`, + `MaxRetentionSec`), +- a logrotate policy for the NPM log directory using `copytruncate` (mandatory + because of the open file descriptors in the container), +- a self-healing guard: whenever the available root bytes drop below + `reverse_proxy_minimum_root_available_bytes` (inventory-wide, also asserted + by `audit-production.yml`), the role vaciums the journal, purges the NPM + proxy cache (`/opt/nginx-proxy-manager/data/nginx/cache`) and restarts the + NPM service, then asserts the headroom again. + +The guard is part of `site.yml`, so every convergence run heals a full root +filesystem the same reproducible way; a second run reports `changed=0` once +the headroom is restored. diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/defaults/main.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/defaults/main.yml new file mode 100644 index 0000000..4ce5f0e --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/defaults/main.yml @@ -0,0 +1,26 @@ +--- +# Incident 2026-11-26: the CT 103 root filesystem filled up (NPM access logs +# under /opt/nginx-proxy-manager/data/logs are not covered by logrotate and +# grow unbounded; nginx keeps deleted inodes open inside the container). +# NPM then served truncated 0-byte assets behind the proxy, which surfaced as +# "Frontend is not initialized" on Gitea (CT 110) and unstyled Keycloak pages. +# This role declares the durable countermeasures and a self-healing guard that +# purges the NPM proxy cache and restarts NPM whenever the declared root +# headroom is violated. + +reverse_proxy_housekeeping_journald_dropin: /etc/systemd/journald.conf.d/99-ghostnet-limits.conf +reverse_proxy_housekeeping_journald_system_max_use: 200M +reverse_proxy_housekeeping_journald_max_retention_sec: 7d + +reverse_proxy_housekeeping_logrotate_dropin: /etc/logrotate.d/nginx-proxy-manager +reverse_proxy_housekeeping_npm_logs_directory: >- + {{ reverse_proxy_npm_data_directory | default('/opt/nginx-proxy-manager/data') }}/logs +reverse_proxy_housekeeping_logrotate_rotate: 4 + +reverse_proxy_housekeeping_npm_cache_directory: >- + {{ reverse_proxy_npm_data_directory | default('/opt/nginx-proxy-manager/data') }}/nginx/cache + +# Reuse the inventory-wide threshold so audit-production.yml and this role +# enforce the same headroom. +reverse_proxy_housekeeping_root_min_available_bytes: >- + {{ reverse_proxy_minimum_root_available_bytes | default(1000000000) }} diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/handlers/main.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/handlers/main.yml new file mode 100644 index 0000000..0023f05 --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Restart systemd-journald + ansible.builtin.systemd_service: + name: systemd-journald + state: restarted diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/tasks/main.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/tasks/main.yml new file mode 100644 index 0000000..262e1d3 --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_disk_housekeeping/tasks/main.yml @@ -0,0 +1,200 @@ +--- +# Phase 1: free space first. With a completely full root filesystem not even +# a new directory can be created, so the emergency cleanup must run before +# any configuration file is written. Truncating in place (copytruncate +# semantics) frees blocks without allocating new ones. + +- name: Read the available bytes on the root filesystem + ansible.builtin.command: + argv: + - /usr/bin/df + - --block-size=1 + - --output=avail + - / + check_mode: false + changed_when: false + register: reverse_proxy_housekeeping_df_before + +- name: Compute the available root filesystem bytes + ansible.builtin.set_fact: + reverse_proxy_housekeeping_root_available_bytes: >- + {{ reverse_proxy_housekeeping_df_before.stdout_lines[1] | int }} + +- name: Vacuum the persistent journal when root headroom is low + ansible.builtin.command: + argv: + - /usr/bin/journalctl + - --vacuum-size={{ reverse_proxy_housekeeping_journald_system_max_use }} + changed_when: false + when: >- + reverse_proxy_housekeeping_root_available_bytes | int < + reverse_proxy_housekeeping_root_min_available_bytes | int + +- name: Enumerate NPM log files when root headroom is low + ansible.builtin.find: + paths: "{{ reverse_proxy_housekeeping_npm_logs_directory }}" + file_type: file + patterns: "*.log" + register: reverse_proxy_housekeeping_big_logs + when: >- + reverse_proxy_housekeeping_root_available_bytes | int < + reverse_proxy_housekeeping_root_min_available_bytes | int + +- name: Truncate NPM log files in place when root headroom is low + ansible.builtin.command: + argv: + - /usr/bin/truncate + - -s + - "0" + - "{{ item.path }}" + loop: "{{ reverse_proxy_housekeeping_big_logs.files | default([]) }}" + loop_control: + label: "{{ item.path }}" + when: >- + reverse_proxy_housekeeping_root_available_bytes | int < + reverse_proxy_housekeeping_root_min_available_bytes | int + +- name: Enumerate the NPM proxy cache when root headroom is low + ansible.builtin.find: + paths: "{{ reverse_proxy_housekeeping_npm_cache_directory }}" + recurse: true + register: reverse_proxy_housekeeping_cache_files + when: >- + reverse_proxy_housekeeping_root_available_bytes | int < + reverse_proxy_housekeeping_root_min_available_bytes | int + +- name: Purge the NPM proxy cache when root headroom is low + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: "{{ reverse_proxy_housekeeping_cache_files.files | default([]) }}" + loop_control: + label: "{{ item.path }}" + when: >- + reverse_proxy_housekeeping_root_available_bytes | int < + reverse_proxy_housekeeping_root_min_available_bytes | int + +- name: Restart NPM when root headroom is low + ansible.builtin.systemd_service: + name: "{{ reverse_proxy_npm_service_name }}" + state: restarted + when: >- + reverse_proxy_housekeeping_root_available_bytes | int < + reverse_proxy_housekeeping_root_min_available_bytes | int + +# Phase 2: durable declared state (writable again once phase 1 freed space). + +- name: Create the journald drop-in directory + ansible.builtin.file: + path: "{{ reverse_proxy_housekeeping_journald_dropin | dirname }}" + state: directory + owner: root + group: root + mode: "0755" + +- name: Install the journald size cap for the CT 103 root filesystem + ansible.builtin.copy: + content: | + # Managed by Ansible (reverse_proxy_disk_housekeeping). + # The persistent journal must not be able to fill the 7.8G root disk. + [Journal] + SystemMaxUse={{ reverse_proxy_housekeeping_journald_system_max_use }} + MaxRetentionSec={{ reverse_proxy_housekeeping_journald_max_retention_sec }} + dest: "{{ reverse_proxy_housekeeping_journald_dropin }}" + owner: root + group: root + mode: "0644" + notify: Restart systemd-journald + +- name: Install the logrotate policy for the NPM log directory + ansible.builtin.copy: + content: | + # Managed by Ansible (reverse_proxy_disk_housekeeping). + # NPM writes its access/error logs through the container bind mount, so + # copytruncate is mandatory: nginx keeps the file descriptors open and a + # rename-based rotation would leave the container writing to deleted + # inodes, which never frees disk space. + {{ reverse_proxy_housekeeping_npm_logs_directory }}/*.log { + weekly + rotate {{ reverse_proxy_housekeeping_logrotate_rotate }} + compress + delaycompress + missingok + notifempty + copytruncate + } + dest: "{{ reverse_proxy_housekeeping_logrotate_dropin }}" + owner: root + group: root + mode: "0644" + +- name: Validate the logrotate policy without applying it + ansible.builtin.command: + argv: + - /usr/sbin/logrotate + - --debug + - "{{ reverse_proxy_housekeeping_logrotate_dropin }}" + check_mode: false + changed_when: false + when: not ansible_check_mode + +- name: Enable and start the logrotate timer + ansible.builtin.systemd_service: + name: logrotate.timer + enabled: true + state: started + +- name: Read the failure state of the oneshot units hit by the full disk + ansible.builtin.command: + argv: + - /usr/bin/systemctl + - is-failed + - "{{ item }}" + check_mode: false + changed_when: false + failed_when: false + loop: + - logrotate.service + - man-db.service + register: reverse_proxy_housekeeping_failed_units + +- name: Re-run the failed oneshot units so their failed state clears + ansible.builtin.systemd_service: + name: "{{ item.item }}" + state: started + loop: "{{ reverse_proxy_housekeeping_failed_units.results }}" + loop_control: + label: "{{ item.item }}" + when: item.stdout == "failed" + +- name: Run logrotate once so the new NPM policy applies immediately + ansible.builtin.command: + argv: + - /usr/sbin/logrotate + - /etc/logrotate.conf + changed_when: false + +# Phase 3: verify the headroom after the guard ran. + +- name: Re-read the available bytes on the root filesystem + ansible.builtin.command: + argv: + - /usr/bin/df + - --block-size=1 + - --output=avail + - / + check_mode: false + changed_when: false + register: reverse_proxy_housekeeping_df_after + when: not ansible_check_mode + +- name: Require the declared root filesystem headroom + ansible.builtin.assert: + that: >- + (reverse_proxy_housekeeping_df_after.stdout_lines[1] | int) >= + (reverse_proxy_housekeeping_root_min_available_bytes | int) + fail_msg: >- + The root filesystem is still below the declared headroom of + {{ reverse_proxy_housekeeping_root_min_available_bytes }} bytes after + the housekeeping guard ran. + when: not ansible_check_mode diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/README.md b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/README.md new file mode 100644 index 0000000..78172db --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/README.md @@ -0,0 +1,12 @@ +# reverse_proxy_fluxer_vhost + +NPM proxy host + Let's-Encrypt certificate for the Fluxer instance +`fluxer.ghostnet.selfhost.eu` → `10.0.0.62:8080` (CT 117 app-proxy), with a +`/livekit/` location to `10.0.0.62:7880` and WebSocket/long-timeout settings +for the gateway and LiveKit signaling. Same NPM-API sync pattern as +`reverse_proxy_research_vhost` (GNAI-023 M8-T3), including the Fail2Ban +restart so the new `proxy-host-*.log` joins the jail glob (GNAI-006 SOP). + +No oauth2-proxy IAP in front: Fluxer enforces login itself (Keycloak OIDC, +GNAI-025 Abschnitt 4). The GNAI-023 IAP can be layered later if the instance +should become invite-gated at the proxy layer as well. diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/defaults/main.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/defaults/main.yml new file mode 100644 index 0000000..b1d983e --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/defaults/main.yml @@ -0,0 +1,57 @@ +--- +# NPM proxy host for the Fluxer instance on CT 117 (GNAI-025). Managed +# idempotently via the NPM API (127.0.0.1:81), same pattern as +# reverse_proxy_research_vhost (GNAI-023 M8-T3). +# +# NPM admin credentials are read from this root-only file on CT 103 +# (created once by the operator, never in git): +# /etc/nginx-proxy-manager/api.env mode 0600, content: +# NPM_API_EMAIL=admin@example.com +# NPM_API_PASSWORD=... +reverse_proxy_fluxer_npm_api: http://127.0.0.1:81/api +reverse_proxy_fluxer_api_env_file: /etc/nginx-proxy-manager/api.env + +reverse_proxy_fluxer_domain: fluxer.ghostnet.selfhost.eu +reverse_proxy_fluxer_upstream_host: 10.0.0.62 +reverse_proxy_fluxer_upstream_port: 8080 +reverse_proxy_fluxer_upstream_scheme: http +reverse_proxy_fluxer_livekit_upstream_port: 7880 +reverse_proxy_fluxer_letsencrypt_email: ma-koenig@gmx.net + +# No oauth2-proxy IAP in front of Fluxer: the instance is public like any chat +# service, and access control happens inside Fluxer (Keycloak SSO via the +# `fluxer` client + invite-only registration, GNAI-025 Abschnitt 4). The +# IAP pattern of GNAI-023 can be layered later by adding auth_request blocks. +# +# Host-level advanced config ONLY (NPM 2.15.1 quirk: host-level +# advanced_config AND custom locations together silently break conf +# generation). WebSocket upgrade headers for the gateway and LiveKit +# signaling; long timeouts for long-lived WS connections. +reverse_proxy_fluxer_advanced_config: | + location /livekit/ { + proxy_pass http://{{ reverse_proxy_fluxer_upstream_host }}:{{ reverse_proxy_fluxer_livekit_upstream_port }}; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $http_connection; + proxy_read_timeout 86400s; + proxy_send_timeout 86400s; + } + location / { + proxy_pass http://{{ reverse_proxy_fluxer_upstream_host }}:{{ reverse_proxy_fluxer_upstream_port }}; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $http_connection; + proxy_read_timeout 86400s; + proxy_send_timeout 86400s; + proxy_buffer_size 64k; + proxy_buffers 16 64k; + proxy_busy_buffers_size 128k; + } diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/files/npm_fluxer_vhost.py b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/files/npm_fluxer_vhost.py new file mode 100644 index 0000000..b4cda1d --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/files/npm_fluxer_vhost.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +"""Idempotent NPM proxy-host + LE certificate for fluxer.ghostnet.selfhost.eu +(Fluxer on CT 117, GNAI-025). Usage: + + npm_fluxer_vhost.py + +Prints CHANGED/UNCHANGED. stdlib only. +""" +import json +import sys +import urllib.error +import urllib.parse +import urllib.request + +api, env_file, spec_file = sys.argv[1:4] +spec = json.load(open(spec_file)) + +env = {} +for line in open(env_file): + line = line.strip() + if line and not line.startswith("#") and "=" in line: + k, v = line.split("=", 1) + env[k.strip()] = v.strip() +email = env["NPM_API_EMAIL"] +password = env["NPM_API_PASSWORD"] + +changed = False + + +def req(method, path, body=None, token=None): + url = f"{api}{path}" + data = None + headers = {} + if token: + headers["Authorization"] = f"Bearer {token}" + if body is not None: + data = json.dumps(body).encode() + headers["Content-Type"] = "application/json" + r = urllib.request.Request(url, data=data, headers=headers, method=method) + try: + with urllib.request.urlopen(r, timeout=30) as resp: + raw = resp.read() + return resp.status, json.loads(raw) if raw else None + except urllib.error.HTTPError as e: + raw = e.read() + try: + return e.code, json.loads(raw) if raw else None + except json.JSONDecodeError: + return e.code, raw[:300] + + +st, tok = req("POST", "/tokens", {"identity": email, "secret": password}) +assert st == 200 and tok and tok.get("token"), f"npm token failed: {st} {tok}" +token = tok["token"] + +domain = spec["domain"] + +# --- 1) letsencrypt certificate --- +st, certs = req("GET", "/nginx/certificates", token=token) +assert st == 200, f"cert list failed: {st}" +cert = next((c for c in certs if domain in (c.get("domain_names") or [])), None) +if not cert: + # NPM 2.15.1 rejects letsencrypt_email/agree in meta ("additional + # properties" 400) — empty meta works, LE account email is used. + st, cert = req("POST", "/nginx/certificates", { + "provider": "letsencrypt", + "domain_names": [domain], + "meta": {}, + }, token=token) + assert st == 201, f"cert create failed: {st} {cert}" + changed = True + cert_id = cert["id"] +else: + cert_id = cert["id"] + +# --- 2) proxy host --- +st, hosts = req("GET", "/nginx/proxy-hosts", token=token) +assert st == 200, f"proxy-host list failed: {st}" +host = next((h for h in hosts if domain in (h.get("domain_names") or [])), None) + +host_body = { + "domain_names": [domain], + "forward_scheme": spec["upstream_scheme"], + "forward_host": spec["upstream_host"], + "forward_port": spec["upstream_port"], + "access_list_id": 0, + "certificate_id": cert_id, + "ssl_forced": True, + "hsts_enabled": True, + "http2_support": True, + "block_exploits": True, + "allow_websocket_upgrade": True, + "advanced_config": spec["advanced_config"], + "locations": [], +} + +if not host: + st, host = req("POST", "/nginx/proxy-hosts", host_body, token=token) + assert st == 201, f"proxy-host create failed: {st} {host}" + changed = True +else: + # NPM 2.15.1 quirk: PUT does NOT regenerate the nginx conf (it even + # deletes it) — only POST/create writes proxy_host/.conf. So on drift + # we delete and re-create the host (cert id stays). + drift = any(host.get(k) != v for k, v in host_body.items()) + if drift: + for k, v in host_body.items(): + if host.get(k) != v: + print(f"DRIFT {k}: current={str(host.get(k))[:120]!r} wanted={str(v)[:120]!r}", file=sys.stderr) + if drift: + st, _ = req("DELETE", f"/nginx/proxy-hosts/{host['id']}", token=token) + assert st == 200, f"proxy-host delete failed: {st}" + st, host = req("POST", "/nginx/proxy-hosts", host_body, token=token) + assert st == 201, f"proxy-host recreate failed: {st} {host}" + changed = True + +print("CHANGED" if changed else "UNCHANGED") diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/tasks/main.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/tasks/main.yml new file mode 100644 index 0000000..cf27cef --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/tasks/main.yml @@ -0,0 +1,68 @@ +--- +- name: Check the NPM API credentials file (mode 0600) + ansible.builtin.stat: + path: "{{ reverse_proxy_fluxer_api_env_file }}" + register: fluxer_npm_api_env + +- name: Fail with instructions when NPM API credentials are missing + ansible.builtin.fail: + msg: >- + {{ reverse_proxy_fluxer_api_env_file }} missing or mode != 0600. + Create it once on CT 103 (root) with NPM_API_EMAIL / NPM_API_PASSWORD + of the NPM admin user; never in git. + when: >- + not fluxer_npm_api_env.stat.exists + or fluxer_npm_api_env.stat.mode != '0600' + +- name: Stage the NPM vhost sync script + ansible.builtin.copy: + src: files/npm_fluxer_vhost.py + dest: /tmp/npm_fluxer_vhost.py + mode: "0600" + changed_when: false + when: not ansible_check_mode + +- name: Render the vhost spec + ansible.builtin.template: + src: spec.json.j2 + dest: /tmp/fluxer_vhost_spec.json + mode: "0600" + changed_when: false + when: not ansible_check_mode + +- name: Sync the Fluxer proxy host + LE cert idempotently via the NPM API + ansible.builtin.command: + argv: + - python3 + - /tmp/npm_fluxer_vhost.py + - "{{ reverse_proxy_fluxer_npm_api }}" + - "{{ reverse_proxy_fluxer_api_env_file }}" + - /tmp/fluxer_vhost_spec.json + register: fluxer_vhost_sync + changed_when: fluxer_vhost_sync.stdout_lines | first == 'CHANGED' + when: not ansible_check_mode + no_log: true + +- name: Verify the sync reports UNCHANGED on a second run (idempotence) + ansible.builtin.command: + argv: + - python3 + - /tmp/npm_fluxer_vhost.py + - "{{ reverse_proxy_fluxer_npm_api }}" + - "{{ reverse_proxy_fluxer_api_env_file }}" + - /tmp/fluxer_vhost_spec.json + register: fluxer_vhost_verify + changed_when: false + failed_when: >- + fluxer_vhost_verify.rc != 0 + or (fluxer_vhost_verify.stdout_lines | first) != 'UNCHANGED' + when: not ansible_check_mode + no_log: true + +- name: Restart Fail2Ban so the new proxy-host log file joins the jail glob + ansible.builtin.systemd_service: + name: fail2ban.service + state: restarted + when: + - fluxer_vhost_sync is changed + - not ansible_check_mode diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/templates/spec.json.j2 b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/templates/spec.json.j2 new file mode 100644 index 0000000..d37fdfb --- /dev/null +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_fluxer_vhost/templates/spec.json.j2 @@ -0,0 +1,8 @@ +{ + "domain": {{ reverse_proxy_fluxer_domain | to_json }}, + "upstream_scheme": {{ reverse_proxy_fluxer_upstream_scheme | to_json }}, + "upstream_host": {{ reverse_proxy_fluxer_upstream_host | to_json }}, + "upstream_port": {{ reverse_proxy_fluxer_upstream_port | int }}, + "letsencrypt_email": {{ reverse_proxy_fluxer_letsencrypt_email | to_json }}, + "advanced_config": {{ reverse_proxy_fluxer_advanced_config | to_json }} +} diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_npm/README.md b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_npm/README.md index dd15053..8863f55 100644 --- a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_npm/README.md +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_npm/README.md @@ -3,7 +3,7 @@ Manages the rootful Nginx Proxy Manager Quadlet `/etc/containers/systemd/nginx-proxy-manager.container` exactly as accepted in GNAI-006 section 4.1: tag-pinned image -`docker.io/jc21/nginx-proxy-manager:2.15.1`, host networking, persistent +`docker.io/jc21/nginx-proxy-manager:2.17.1`, host networking, persistent `/opt/nginx-proxy-manager/data` and `/opt/nginx-proxy-manager/letsencrypt`, IPv6 disabled and timezone Europe/Berlin. diff --git a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_npm/defaults/main.yml b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_npm/defaults/main.yml index d076d03..6d653db 100644 --- a/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_npm/defaults/main.yml +++ b/proxmox/lxc/ct-103-reverse-proxy/ansible/roles/reverse_proxy_npm/defaults/main.yml @@ -1,6 +1,6 @@ --- reverse_proxy_npm_image: docker.io/jc21/nginx-proxy-manager -reverse_proxy_npm_image_tag: "2.15.1" +reverse_proxy_npm_image_tag: "2.17.1" reverse_proxy_npm_container_name: nginx-proxy-manager reverse_proxy_npm_service_name: nginx-proxy-manager.service reverse_proxy_npm_quadlet_path: /etc/containers/systemd/nginx-proxy-manager.container diff --git a/proxmox/lxc/ct-114-litecoin-wallet/README.md b/proxmox/lxc/ct-114-litecoin-wallet/README.md new file mode 100644 index 0000000..88f0e02 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/README.md @@ -0,0 +1,20 @@ +# CT 114 – Litecoin wallet node + +Host root for the Litecoin full-node LXC at `10.0.0.61` (`ltc-node`), planned +as a Tor-only cold wallet (GNAI-024). The container does not exist yet; it is +created on the PVE host by the operator with the reviewed helpers in +[`scripts/`](scripts/README.md) and then converged by the self-contained +Ansible project in [`ansible/`](ansible/README.md). + +| Area | Content | +| --- | --- | +| [`ansible/`](ansible/README.md) | inventories (`agent`/`bootstrap`/`production`), playbooks and CT-specific roles | +| [`scripts/`](scripts/README.md) | reviewed PVE provisioning launcher and access bootstrap hook | +| [`../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md`](../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md) | design, review of the research documents, decisions, phases and acceptance tests | +| [`../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-setup.txt`](../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-setup.txt) | original research brief (Auftrag) | +| [`../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-tests.txt`](../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-tests.txt) | original research test plan (Auftrag) | + +Secrets never enter this repository: no wallet passphrase, no seed, no +restic password, no private SSH keys. The wallet passphrase and restic +secret are handled interactively / via the operator's secret store +(Vaultwarden), and only public keys live in `ansible/files/ssh/`. diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/README.md b/proxmox/lxc/ct-114-litecoin-wallet/ansible/README.md new file mode 100644 index 0000000..5e59095 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/README.md @@ -0,0 +1,65 @@ +# CT 114 Litecoin wallet Ansible project + +This self-contained host project manages the CT 114 Litecoin full-node LXC +(`ltc-node`, `10.0.0.61`). It follows the CT 102 Keycloak fresh-rebuild schema +and the CT 100/103 three-inventory convention (`agent`, `bootstrap`, +`production`) and uses the repository-wide pinned control dependency +(`shared/ansible/requirements-control.txt`); all CT 114 inventories, +playbooks, keys and roles remain inside the CT 114 root. + +Create the repository-level control environment once: + +```bash +python3 -m venv .venv +.venv/bin/python -m pip install --upgrade pip +.venv/bin/python -m pip install -r shared/ansible/requirements-control.txt +``` + +Run commands from this directory and always select an inventory explicitly: + +```bash +cd proxmox/lxc/ct-114-litecoin-wallet/ansible +../../../../.venv/bin/ansible-playbook \ + --inventory inventories/production/hosts.yml \ + playbooks/verify-production.yml \ + --private-key ~/.ssh/id_ed25519_ghostnet_ct114_ansible_deploy +``` + +## Commissioning sequence for the new CT 114 + +CT 114 does not exist yet; the LXC is created on the PVE host by the operator +with the reviewed helpers in [`../scripts/`](../scripts/) (Community Scripts +launcher + bootstrap hook), following the CT 102 procedure (GNAI-016 Phase D, +GNAI-024 Abschnitt 6): + +0. Operator, on the workstation: generate the three CT 114 key pairs + (`ghost` interactively with passphrase; `ghost-agent`/`ansible-deploy` + passphrase-less), copy the `.pub` files into `files/ssh/`, fill the + `ADMIN_PUBLIC_KEY` placeholder in the bootstrap hook, then create the + restic backup key and the restic password on the target during bootstrap + (secrets never enter this repository). +1. Operator, as root@pve: install the reviewed hooks and run + `../scripts/provision-ct114-litecoin.sh`. +2. Operator: pin the SSH host-key fingerprint from the Proxmox console into + all three `host_vars/litecoin-ct114.yml` files, and add + `10.0.0.61` to the WireGuard server-admin target list on CT 105 if VPN + management access is wanted. +3. `preflight.yml` on the `agent` inventory (read-only, unprivileged, + `--private-key ~/.ssh/id_ed25519_ghostnet_ct114_agent`) proves identity, + resource gates and the empty state. +4. `verify-deploy-access.yml` on the `production` inventory proves the + `ansible-deploy` boundary. +5. `site.yml --check --diff` on the `production` inventory previews the + convergence. A real `site.yml` run enforces the declared state and + therefore requires explicit operator authorization. +6. `verify-production.yml` plus a second `site.yml` run with `changed=0` + complete the commissioning; `audit-production.yml` is the read-only deep + audit. + +The node is started by `site.yml` only on inventories with +`litecoin_service_start_allowed: true` (production). Wallet creation and +`encryptwallet` are interactive operator/agent steps over SSH exec — never +part of a playbook (GNAI-024 Abschnitt 8). + +Do not store the wallet passphrase, the restic password, the restic SSH +private key, any private SSH key or seed material in this repository. diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/ansible.cfg b/proxmox/lxc/ct-114-litecoin-wallet/ansible/ansible.cfg new file mode 100644 index 0000000..b0d9cb1 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/ansible.cfg @@ -0,0 +1,12 @@ +[defaults] +home = .ansible +host_key_checking = True +interpreter_python = auto_silent +local_tmp = .ansible/tmp +retry_files_enabled = False +roles_path = roles:../../../../shared/ansible/roles +timeout = 15 + +[ssh_connection] +pipelining = True +ssh_args = -o ControlMaster=auto -o ControlPersist=60s diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ansible-deploy.pub b/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ansible-deploy.pub new file mode 100644 index 0000000..4124aec --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ansible-deploy.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILfqlYvqesJK9bhMmfv6tRp5pXPFDu13xmYbV+58fopV ansible-deploy@ghostnet-ct114 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost-agent.pub b/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost-agent.pub new file mode 100644 index 0000000..99d0744 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost-agent.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMvQR56yADYULrpThnXROAa8GxKWfb+xcnIVLVDVX6Yy ghost-agent@ghostnet-ct114 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost.pub b/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost.pub new file mode 100644 index 0000000..a5ebd93 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGUv4INjWuIzgRL9Pw4TqeHirG72AeA6bowsea6fj2OT ghost@ghostnet-ct114 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/group_vars/litecoin_hosts.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/group_vars/litecoin_hosts.yml new file mode 100644 index 0000000..2466eba --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/group_vars/litecoin_hosts.yml @@ -0,0 +1,32 @@ +--- +ansible_become_method: sudo +ansible_python_interpreter: /usr/bin/python3 +ansible_ssh_common_args: >- + -o IdentitiesOnly=yes + -o StrictHostKeyChecking=yes + -o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct114 + +litecoin_expected_distribution: Debian +litecoin_expected_distribution_major_version: "13" +litecoin_expected_hostname: ltc-node +litecoin_expected_virtualization_type: lxc + +litecoin_firewall_management_ipv4: + - 10.0.0.0/24 + - 10.8.0.0/24 +litecoin_firewall_ssh_port: 22 + +litecoin_access_source_networks: 10.0.0.0/24,10.8.0.0/24 + +litecoin_core_version: 0.21.5.8 +litecoin_core_tarball_name: "litecoin-{{ litecoin_core_version }}-x86_64-linux-gnu.tar.gz" +litecoin_core_base_url: "https://download.litecoin.org/litecoin-{{ litecoin_core_version }}/linux" +# SHA-256 aus dem signierten SHA256SUMS.asc von download.litecoin.org +# (Release v0.21.5.8 vom 2026-09-12, enthaelt den 0.21.5.7-Sicherheitsfix), +# am 2026-11-25 gegen den offiziellen Download geprueft (GNAI-024 Abschnitt 2). +litecoin_core_tarball_sha256: >- + 43200c9f9d65ebc126ea5833ca9429e144c4b3273da6bb9f4e89fd7450ab1be9 + +# Read-only access only; the agent inventory must never converge state. +litecoin_service_start_allowed: false +litecoin_service_production_enabled: false diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/host_vars/litecoin-ct114.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/host_vars/litecoin-ct114.yml new file mode 100644 index 0000000..e056e52 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/host_vars/litecoin-ct114.yml @@ -0,0 +1,11 @@ +--- +litecoin_ctid: 114 +litecoin_expected_ipv4: 10.0.0.61 +# Wird nach dem ersten Boot des CT vom Operator aus der Proxmox-Konsole +# uebernommen (ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub via pct exec) +# und hier gepinnt. Der Platzhalter muss vor dem ersten Lauf ersetzt werden. +litecoin_expected_ssh_host_key_fingerprint: "SHA256:nkRMQWpzpBkUaGNOgyCRsEaXK2KhdraTuiL5ihUdXW4" # gepinnt 2026-11-27 aus dem Bootstrap-Hook-Log (pct exec 114) +litecoin_expected_processor_vcpus: 2 +litecoin_minimum_memory_mb: 3800 +litecoin_minimum_root_size_bytes: 150000000000 +litecoin_minimum_root_available_bytes: 20000000000 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/hosts.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/hosts.yml new file mode 100644 index 0000000..48b1d08 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/agent/hosts.yml @@ -0,0 +1,8 @@ +--- +all: + children: + litecoin_hosts: + hosts: + litecoin-ct114: + ansible_host: 10.0.0.61 + ansible_user: ghost-agent diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/group_vars/litecoin_hosts.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/group_vars/litecoin_hosts.yml new file mode 100644 index 0000000..5d8faa7 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/group_vars/litecoin_hosts.yml @@ -0,0 +1,29 @@ +--- +ansible_become_method: sudo +ansible_python_interpreter: /usr/bin/python3 +ansible_ssh_common_args: >- + -o IdentitiesOnly=yes + -o StrictHostKeyChecking=yes + -o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct114 + +litecoin_expected_distribution: Debian +litecoin_expected_distribution_major_version: "13" +litecoin_expected_hostname: ltc-node +litecoin_expected_virtualization_type: lxc + +litecoin_firewall_management_ipv4: + - 10.0.0.0/24 + - 10.8.0.0/24 +litecoin_firewall_ssh_port: 22 + +litecoin_access_source_networks: 10.0.0.0/24,10.8.0.0/24 + +litecoin_core_version: 0.21.5.8 +litecoin_core_tarball_name: "litecoin-{{ litecoin_core_version }}-x86_64-linux-gnu.tar.gz" +litecoin_core_base_url: "https://download.litecoin.org/litecoin-{{ litecoin_core_version }}/linux" +litecoin_core_tarball_sha256: >- + 43200c9f9d65ebc126ea5833ca9429e144c4b3273da6bb9f4e89fd7450ab1be9 + +# Bootstrap converges configuration but must not start the node yet. +litecoin_service_start_allowed: false +litecoin_service_production_enabled: false diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/host_vars/litecoin-ct114.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/host_vars/litecoin-ct114.yml new file mode 100644 index 0000000..a073d2b --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/host_vars/litecoin-ct114.yml @@ -0,0 +1,8 @@ +--- +litecoin_ctid: 114 +litecoin_expected_ipv4: 10.0.0.61 +litecoin_expected_ssh_host_key_fingerprint: "SHA256:nkRMQWpzpBkUaGNOgyCRsEaXK2KhdraTuiL5ihUdXW4" # gepinnt 2026-11-27 aus dem Bootstrap-Hook-Log (pct exec 114) +litecoin_expected_processor_vcpus: 2 +litecoin_minimum_memory_mb: 3800 +litecoin_minimum_root_size_bytes: 150000000000 +litecoin_minimum_root_available_bytes: 20000000000 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/hosts.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/hosts.yml new file mode 100644 index 0000000..c746a6e --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/bootstrap/hosts.yml @@ -0,0 +1,8 @@ +--- +all: + children: + litecoin_hosts: + hosts: + litecoin-ct114: + ansible_host: 10.0.0.61 + ansible_user: ghost diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/group_vars/litecoin_hosts.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/group_vars/litecoin_hosts.yml new file mode 100644 index 0000000..2aded07 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/group_vars/litecoin_hosts.yml @@ -0,0 +1,37 @@ +--- +ansible_become_method: sudo +ansible_python_interpreter: /usr/bin/python3 +ansible_ssh_common_args: >- + -o IdentitiesOnly=yes + -o StrictHostKeyChecking=yes + -o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct114 + +litecoin_expected_distribution: Debian +litecoin_expected_distribution_major_version: "13" +litecoin_expected_hostname: ltc-node +litecoin_expected_virtualization_type: lxc + +litecoin_firewall_management_ipv4: + - 10.0.0.0/24 + - 10.8.0.0/24 +litecoin_firewall_ssh_port: 22 + +litecoin_access_source_networks: 10.0.0.0/24,10.8.0.0/24 + +litecoin_core_version: 0.21.5.8 +litecoin_core_tarball_name: "litecoin-{{ litecoin_core_version }}-x86_64-linux-gnu.tar.gz" +litecoin_core_base_url: "https://download.litecoin.org/litecoin-{{ litecoin_core_version }}/linux" +# SHA-256 aus dem signierten SHA256SUMS.asc von download.litecoin.org +# (Release v0.21.5.8 vom 2026-09-12, enthaelt den 0.21.5.7-Sicherheitsfix), +# am 2026-11-25 gegen den offiziellen Download geprueft (GNAI-024 Abschnitt 2). +litecoin_core_tarball_sha256: >- + 43200c9f9d65ebc126ea5833ca9429e144c4b3273da6bb9f4e89fd7450ab1be9 + +# restic-Ziel auf dem hostunabhaengigen Backup-Ziel ghostnet-ki (10.0.0.90), +# Konto gn-backup; clientseitige Verschluesselung ist restic-Standard. +# Alternativ liefert der Betreiber die Zugangsdaten eines separaten PBS im LAN. +litecoin_backup_repository: "sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic" +litecoin_backup_keep_daily: 30 + +litecoin_service_start_allowed: true +litecoin_service_production_enabled: true diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/host_vars/litecoin-ct114.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/host_vars/litecoin-ct114.yml new file mode 100644 index 0000000..5ec4d17 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/host_vars/litecoin-ct114.yml @@ -0,0 +1,11 @@ +--- +litecoin_ctid: 114 +litecoin_expected_ipv4: 10.0.0.61 +# Wird nach dem ersten Boot des CT vom Operator aus der Proxmox-Konsole +# uebernommen (pct exec 114 -- ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub) +# und hier gepinnt. Der Platzhalter muss vor dem ersten Lauf ersetzt werden. +litecoin_expected_ssh_host_key_fingerprint: "SHA256:nkRMQWpzpBkUaGNOgyCRsEaXK2KhdraTuiL5ihUdXW4" # gepinnt 2026-11-27 aus dem Bootstrap-Hook-Log (pct exec 114) +litecoin_expected_processor_vcpus: 2 +litecoin_minimum_memory_mb: 3800 +litecoin_minimum_root_size_bytes: 150000000000 +litecoin_minimum_root_available_bytes: 20000000000 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/hosts.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/hosts.yml new file mode 100644 index 0000000..7d5815f --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/inventories/production/hosts.yml @@ -0,0 +1,8 @@ +--- +all: + children: + litecoin_hosts: + hosts: + litecoin-ct114: + ansible_host: 10.0.0.61 + ansible_user: ansible-deploy diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/audit-production.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/audit-production.yml new file mode 100644 index 0000000..1fbab26 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/audit-production.yml @@ -0,0 +1,197 @@ +--- +- name: Read-only deep audit of the CT 114 production state + hosts: litecoin_hosts + become: true + gather_facts: true + gather_subset: + - min + - network + - virtual + + tasks: + - name: Require the production inventory safeguards + ansible.builtin.assert: + that: + - litecoin_ctid | int == 114 + - inventory_hostname == "litecoin-ct114" + - >- + litecoin_expected_ssh_host_key_fingerprint is + match('^SHA256:[A-Za-z0-9+/]{43}$') + + - name: Read the account inventory + ansible.builtin.command: + argv: [/usr/bin/getent, passwd] + check_mode: false + changed_when: false + register: litecoin_audit_passwd + + - name: Require exactly the managed accounts with their fixed UIDs + ansible.builtin.assert: + that: + - litecoin_audit_passwd.stdout is search('(?m)^ghost-agent:x:1000:1000:') + - litecoin_audit_passwd.stdout is search('(?m)^ghost:x:1001:1001:') + - litecoin_audit_passwd.stdout is search('(?m)^ansible-deploy:x:1002:1002:') + - litecoin_audit_passwd.stdout is search('(?m)^litecoin:x:1100:1100:') + + - name: Read the password states of the managed accounts + ansible.builtin.command: + argv: [/usr/bin/passwd, -S, "{{ item }}"] + check_mode: false + changed_when: false + register: litecoin_audit_password_states + loop: + - ghost-agent + - ghost + - ansible-deploy + - litecoin + loop_control: + label: "{{ item }}" + + - name: Require locked or password-gated states only + ansible.builtin.assert: + that: + - item.stdout.split()[1] in ["L", "P"] + loop: "{{ litecoin_audit_password_states.results }}" + loop_control: + label: "{{ item.item }}" + + - name: Read the sudoers drop-ins + ansible.builtin.command: + argv: [/usr/bin/cat, /etc/sudoers.d/90-ghostnet-ansible-deploy, /etc/sudoers.d/91-ghostnet-litecoin-readonly] + check_mode: false + changed_when: false + register: litecoin_audit_sudoers + + - name: Require the validated sudo policies + ansible.builtin.assert: + that: + - "litecoin_audit_sudoers.stdout is search('ansible-deploy ALL=\\\\(root\\\\) NOPASSWD: ALL')" + - "litecoin_audit_sudoers.stdout is search('ghost-agent ALL=\\\\(root\\\\) NOPASSWD: /usr/local/bin/ltc-readonly')" + + - name: Verify the sudoers files pass visudo + ansible.builtin.command: + argv: [/usr/sbin/visudo, -c, -f, "{{ item }}"] + check_mode: false + changed_when: false + loop: + - /etc/sudoers.d/90-ghostnet-ansible-deploy + - /etc/sudoers.d/91-ghostnet-litecoin-readonly + loop_control: + label: "{{ item }}" + + - name: Read the effective SSH configuration + ansible.builtin.command: + argv: [/usr/sbin/sshd, -T] + check_mode: false + changed_when: false + register: litecoin_audit_sshd + + - name: Require the GNAI-011 SSH baseline + ansible.builtin.assert: + that: + - litecoin_audit_sshd.stdout is search('(?m)^permitrootlogin no$') + - litecoin_audit_sshd.stdout is search('(?m)^passwordauthentication no$') + - litecoin_audit_sshd.stdout is search('(?m)^kbdinteractiveauthentication no$') + - litecoin_audit_sshd.stdout is search('(?m)^allowtcpforwarding no$') + - litecoin_audit_sshd.stdout is search('(?m)^disableforwarding yes$') + - "litecoin_audit_sshd.stdout is search('(?m)^allowusers ghost-agent$')" + - "litecoin_audit_sshd.stdout is search('(?m)^allowusers ghost$')" + - "litecoin_audit_sshd.stdout is search('(?m)^allowusers ansible-deploy$')" + + - name: Read the fail2ban jail list + ansible.builtin.command: + argv: [/usr/bin/fail2ban-client, status] + check_mode: false + changed_when: false + register: litecoin_audit_fail2ban + + - name: Require the sshd jail + ansible.builtin.assert: + that: + - litecoin_audit_fail2ban.stdout is search('sshd') + + - name: Read the active nftables ruleset + ansible.builtin.command: + argv: [/usr/sbin/nft, list, ruleset] + check_mode: false + changed_when: false + register: litecoin_audit_nft + + - name: Require the Ghostnet filter table in the ruleset + ansible.builtin.assert: + that: + - litecoin_audit_nft.stdout is search('table inet ghostnet_filter') + + - name: Read the Tor client configuration + ansible.builtin.command: + argv: [/usr/bin/tor, --verify-config, -f, /etc/tor/torrc] + check_mode: false + changed_when: false + register: litecoin_audit_tor_config + + - name: Require the Tor config to verify + ansible.builtin.assert: + that: + - litecoin_audit_tor_config.rc == 0 + + - name: Verify Tor-only networking and no inbound peers via the read-only wrapper + become: false + ansible.builtin.shell: | + /usr/bin/sudo -n /usr/local/bin/ltc-readonly getnetworkinfo | /usr/bin/python3 -c ' + import json, sys + data = json.load(sys.stdin) + for n in data["networks"]: + if n.get("proxy") != "127.0.0.1:9050": + sys.exit("network %s is not proxied via Tor: %r" % (n["name"], n.get("proxy"))) + print("all networks proxied via Tor:", [n["name"] for n in data["networks"]]) + ' + /usr/bin/sudo -n /usr/local/bin/ltc-readonly getpeerinfo | /usr/bin/python3 -c ' + import json, sys + peers = json.load(sys.stdin) + inbound = [p for p in peers if p.get("inbound")] + print("peers:", len(peers), "inbound:", len(inbound)) + if inbound: + sys.exit("inbound peers present although listen=0") + ' + args: + executable: /bin/bash + check_mode: false + changed_when: false + register: litecoin_audit_networkinfo + when: + - not ansible_check_mode + - litecoin_service_start_allowed | bool + + - name: Report the Tor-only network state + ansible.builtin.debug: + msg: "{{ litecoin_audit_networkinfo.stdout_lines | default(['check mode or node stopped: skipped']) }}" + when: + - not ansible_check_mode + - litecoin_service_start_allowed | bool + + - name: Read the litecoind datadir usage + ansible.builtin.command: + argv: [/usr/bin/du, -sb, /var/lib/litecoin] + check_mode: false + changed_when: false + register: litecoin_audit_datadir_usage + + - name: Read the wallet backup directory state + ansible.builtin.stat: + path: /var/lib/litecoin/backups + register: litecoin_audit_backup_dir + + - name: Require the protected wallet backup directory + ansible.builtin.assert: + that: + - litecoin_audit_backup_dir.stat.exists + - litecoin_audit_backup_dir.stat.mode == "0700" + - litecoin_audit_backup_dir.stat.pw_name == "litecoin" + + - name: Report the CT 114 audit summary + ansible.builtin.debug: + msg: + ctid: "{{ litecoin_ctid }}" + ssh_fingerprint: "{{ litecoin_expected_ssh_host_key_fingerprint }}" + datadir_bytes: "{{ litecoin_audit_datadir_usage.stdout.split()[0] }}" + fail2ban_jails: "{{ litecoin_audit_fail2ban.stdout_lines }}" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/preflight.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/preflight.yml new file mode 100644 index 0000000..0770359 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/preflight.yml @@ -0,0 +1,175 @@ +--- +- name: Read-only verification of the fresh CT 114 Litecoin LXC + hosts: litecoin_hosts + become: false + gather_facts: true + gather_subset: + - min + - hardware + - network + - virtual + + tasks: + - name: Verify required inventory safeguards are defined + ansible.builtin.assert: + that: + - litecoin_ctid is defined + - litecoin_expected_hostname is defined + - litecoin_expected_ipv4 is defined + - litecoin_expected_ssh_host_key_fingerprint is defined + - litecoin_expected_distribution is defined + - litecoin_expected_distribution_major_version is defined + - litecoin_expected_virtualization_type is defined + - litecoin_minimum_memory_mb is defined + - litecoin_minimum_root_size_bytes is defined + fail_msg: >- + The selected inventory lacks mandatory CT 114 identity safeguards. + Stop before running any configuration playbook. + + - name: Verify the expected guest identity + ansible.builtin.assert: + that: + - inventory_hostname == "litecoin-ct114" + - litecoin_ctid | int == 114 + - ansible_facts["hostname"] == litecoin_expected_hostname + - ansible_facts["distribution"] == litecoin_expected_distribution + - >- + ansible_facts["distribution_major_version"] == + litecoin_expected_distribution_major_version + - >- + ansible_facts["default_ipv4"]["address"] == + litecoin_expected_ipv4 + - >- + ansible_facts["virtualization_type"] == + litecoin_expected_virtualization_type + - ansible_facts["virtualization_role"] == "guest" + - ansible_facts["service_mgr"] == "systemd" + - ansible_facts["python"]["version"]["major"] | int >= 3 + fail_msg: >- + The connected machine is not the expected CT 114 Litecoin LXC. + Stop before using any privileged playbook. + success_msg: The expected Debian 13 CT 114 Litecoin LXC is connected. + + - name: Verify the pinned SSH host key fingerprint + ansible.builtin.assert: + that: + - litecoin_expected_ssh_host_key_fingerprint is + match('^SHA256:[A-Za-z0-9+/]{43}$') + fail_msg: >- + litecoin_expected_ssh_host_key_fingerprint still contains the + PENDING placeholder. Pin the real fingerprint from the Proxmox + console after the first boot (GNAI-024 Abschnitt 6). + + - name: Read the unprivileged SSH identity + ansible.builtin.command: + argv: + - /usr/bin/id + - -un + check_mode: false + changed_when: false + register: litecoin_preflight_ssh_identity + + - name: Verify the agent account was used on the agent inventory + ansible.builtin.assert: + that: + - litecoin_preflight_ssh_identity.stdout == "ghost-agent" + fail_msg: >- + The agent inventory must connect through the unprivileged + ghost-agent account. + when: ansible_user is defined and ansible_user == "ghost-agent" + + - name: Read failed systemd units + ansible.builtin.command: + argv: + - /usr/bin/systemctl + - --failed + - --no-legend + - --plain + check_mode: false + changed_when: false + register: litecoin_preflight_failed_units + + - name: Read the listening TCP ports + ansible.builtin.command: + argv: + - /usr/bin/ss + - -H + - -lnt + check_mode: false + changed_when: false + register: litecoin_preflight_listeners + + - name: Read the effective processor count + ansible.builtin.command: + argv: + - /usr/bin/nproc + check_mode: false + changed_when: false + register: litecoin_preflight_nproc + + - name: Read root filesystem capacity + ansible.builtin.command: + argv: + - /usr/bin/findmnt + - --bytes + - --noheadings + - --output + - SIZE,AVAIL + - --target + - / + check_mode: false + changed_when: false + register: litecoin_preflight_root_capacity + + - name: Check that no Litecoin installation exists yet + ansible.builtin.stat: + path: /opt/litecoin + register: litecoin_preflight_opt_symlink + + - name: Verify the fresh-LXC commissioning gates + ansible.builtin.assert: + that: + - >- + litecoin_preflight_nproc.stdout | int == + litecoin_expected_processor_vcpus | int + - >- + ansible_facts["memtotal_mb"] | int >= + litecoin_minimum_memory_mb | int + - >- + litecoin_preflight_root_capacity.stdout.split()[0] | int >= + litecoin_minimum_root_size_bytes | int + - >- + litecoin_preflight_root_capacity.stdout.split()[1] | int >= + litecoin_minimum_root_available_bytes | int + - litecoin_preflight_failed_units.stdout | trim == "" + - >- + litecoin_preflight_listeners.stdout is search('\\b22\\b') or + litecoin_preflight_listeners.stdout | trim == "" + - not litecoin_preflight_opt_symlink.stat.exists + fail_msg: >- + The target is not the expected healthy, empty CT 114. Stop before + creating configuration, services or wallets. + success_msg: >- + CT 114 is healthy, empty and ready for declarative configuration. + + - name: Report the verified Litecoin commissioning baseline + ansible.builtin.debug: + msg: + inventory_host: "{{ inventory_hostname }}" + ctid: "{{ litecoin_ctid }}" + hostname: "{{ ansible_facts['hostname'] }}" + operating_system: >- + {{ ansible_facts['distribution'] }} + {{ ansible_facts['distribution_version'] }} + default_ipv4: "{{ ansible_facts['default_ipv4']['address'] }}" + virtualization: >- + {{ ansible_facts['virtualization_type'] }} + {{ ansible_facts['virtualization_role'] }} + effective_processor_count: "{{ litecoin_preflight_nproc.stdout }}" + memory_mib: "{{ ansible_facts['memtotal_mb'] }}" + root_size_bytes: >- + {{ litecoin_preflight_root_capacity.stdout.split()[0] }} + root_available_bytes: >- + {{ litecoin_preflight_root_capacity.stdout.split()[1] }} + trusted_ssh_fingerprint: >- + {{ litecoin_expected_ssh_host_key_fingerprint }} diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/site.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/site.yml new file mode 100644 index 0000000..20dec22 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/site.yml @@ -0,0 +1,29 @@ +--- +- name: Converge the CT 114 Litecoin wallet LXC on the declared state + hosts: litecoin_hosts + become: true + gather_facts: true + gather_subset: + - min + - hardware + - network + - virtual + + roles: + - role: litecoin_lxc_baseline + vars: + litecoin_lxc_baseline_expected_hostname: >- + {{ litecoin_expected_hostname }} + litecoin_lxc_baseline_expected_distribution: >- + {{ litecoin_expected_distribution }} + litecoin_lxc_baseline_expected_distribution_major_version: >- + {{ litecoin_expected_distribution_major_version }} + litecoin_lxc_baseline_expected_ipv4: "{{ litecoin_expected_ipv4 }}" + litecoin_lxc_baseline_expected_virtualization_type: >- + {{ litecoin_expected_virtualization_type }} + - role: litecoin_access + - role: litecoin_firewall + - role: litecoin_fail2ban + - role: litecoin_tor + - role: litecoin_core + - role: litecoin_backup diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/verify-deploy-access.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/verify-deploy-access.yml new file mode 100644 index 0000000..c4166fc --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/verify-deploy-access.yml @@ -0,0 +1,43 @@ +--- +- name: Verify the CT 114 Ansible deployment boundary + hosts: litecoin_hosts + become: false + gather_facts: false + + tasks: + - name: Verify Ansible module execution without privilege escalation + ansible.builtin.ping: + + - name: Read the SSH account identity + ansible.builtin.command: + argv: + - /usr/bin/id + - -un + check_mode: false + changed_when: false + register: litecoin_deploy_account_identity + + - name: Verify the expected SSH account + ansible.builtin.assert: + that: + - litecoin_deploy_account_identity.stdout == "ansible-deploy" + fail_msg: The SSH connection did not use ansible-deploy. + + - name: Read the effective identity through sudo + become: true + ansible.builtin.command: + argv: + - /usr/bin/id + - -u + check_mode: false + changed_when: false + register: litecoin_deploy_root_identity + + - name: Verify non-interactive root escalation + ansible.builtin.assert: + that: + - litecoin_deploy_root_identity.stdout == "0" + fail_msg: Non-interactive sudo did not produce effective UID 0. + success_msg: >- + The CT 114 deployment account can connect and escalate privileges + non-interactively. diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/verify-production.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/verify-production.yml new file mode 100644 index 0000000..92924ea --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/playbooks/verify-production.yml @@ -0,0 +1,213 @@ +--- +- name: Read-only verification of the converged CT 114 production state + hosts: litecoin_hosts + become: true + gather_facts: true + gather_subset: + - min + - network + - virtual + + tasks: + - name: Require the production inventory safeguards + ansible.builtin.assert: + that: + - litecoin_ctid | int == 114 + - inventory_hostname == "litecoin-ct114" + - >- + litecoin_expected_ssh_host_key_fingerprint is + match('^SHA256:[A-Za-z0-9+/]{43}$') + + - name: Verify the expected guest identity + ansible.builtin.assert: + that: + - ansible_facts["hostname"] == litecoin_expected_hostname + - ansible_facts["distribution"] == litecoin_expected_distribution + - >- + ansible_facts["distribution_major_version"] == + litecoin_expected_distribution_major_version + - >- + ansible_facts["default_ipv4"]["address"] == + litecoin_expected_ipv4 + - >- + ansible_facts["virtualization_type"] == + litecoin_expected_virtualization_type + - ansible_facts["virtualization_role"] == "guest" + fail_msg: The connected machine is not the declared CT 114. + + - name: Read failed systemd units + ansible.builtin.command: + argv: [/usr/bin/systemctl, --failed, --no-legend, --plain] + check_mode: false + changed_when: false + register: litecoin_production_failed_units + + - name: Require no failed units + ansible.builtin.assert: + that: + - litecoin_production_failed_units.stdout | trim == "" + + - name: Read the deployment account identity + become: false + ansible.builtin.command: + argv: [/usr/bin/id, -un] + check_mode: false + changed_when: false + register: litecoin_production_ssh_identity + + - name: Require the deployment account + ansible.builtin.assert: + that: + - litecoin_production_ssh_identity.stdout == "ansible-deploy" + + - name: Read the required service states + ansible.builtin.command: + argv: + - /usr/bin/systemctl + - is-active + - ssh.service + - nftables.service + - fail2ban.service + - tor.service + - unattended-upgrades.service + check_mode: false + changed_when: false + register: litecoin_production_services + + - name: Require all management services active + ansible.builtin.assert: + that: + - litecoin_production_services.stdout_lines | select('!=', 'active') | list | length == 0 + + - name: Read the litecoind service state + ansible.builtin.command: + argv: [/usr/bin/systemctl, is-active, litecoind.service] + check_mode: false + changed_when: false + register: litecoin_production_litecoind + + - name: Require litecoind active when the inventory allows starting it + ansible.builtin.assert: + that: + - litecoin_production_litecoind.stdout == "active" + when: litecoin_service_start_allowed | bool + + - name: Read the listening TCP sockets + ansible.builtin.command: + argv: [/usr/bin/ss, -H, -lnt] + check_mode: false + changed_when: false + register: litecoin_production_listeners + + - name: Require SSH as the only externally bound listener + ansible.builtin.assert: + that: + - litecoin_production_listeners.stdout is search('0.0.0.0:22\\b|\\[::\\]:22\\b') + - not (litecoin_production_listeners.stdout is search('0.0.0.0:(9332|9333|9050|9051)\\b')) + - not (litecoin_production_listeners.stdout is search('\\[::\\]:(9332|9333|9050|9051)\\b')) + fail_msg: >- + Unexpected externally bound listener. RPC 9332, SOCKS 9050, + ControlPort 9051 and P2P 9333 must be loopback-only or absent. + + - name: Require loopback-only RPC and Tor listeners + ansible.builtin.assert: + that: + - litecoin_production_listeners.stdout is search('127.0.0.1:9332\\b') + - litecoin_production_listeners.stdout is search('127.0.0.1:9050\\b') + - not (litecoin_production_listeners.stdout is search('9333')) + fail_msg: >- + litecoind must bind RPC to 127.0.0.1:9332 only and must not listen + on P2P 9333 (listen=0, onion-only). + + - name: Read the litecoind version + ansible.builtin.command: + argv: [/opt/litecoin/bin/litecoind, --version] + check_mode: false + changed_when: false + register: litecoin_production_version + + - name: Require the pinned Litecoin Core version + ansible.builtin.assert: + that: + - ('Litecoin Core version v' ~ litecoin_core_version) in litecoin_production_version.stdout + fail_msg: "Unexpected litecoind version: {{ litecoin_production_version.stdout }}" + + - name: Read the active Ghostnet nftables table + ansible.builtin.command: + argv: [/usr/sbin/nft, list, table, inet, ghostnet_filter] + check_mode: false + changed_when: false + register: litecoin_production_nft + + - name: Require the default-deny firewall + ansible.builtin.assert: + that: + - litecoin_production_nft.stdout is search('policy drop') + - litecoin_production_nft.stdout is search('SSH management') + - litecoin_production_nft.stdout is search('default input deny') + + - name: Read the effective SSH policy + ansible.builtin.command: + argv: [/usr/sbin/sshd, -T] + check_mode: false + changed_when: false + register: litecoin_production_sshd_effective + + - name: Require the hardened SSH policy + ansible.builtin.assert: + that: + - litecoin_production_sshd_effective.stdout is search('(?m)^permitrootlogin no$') + - litecoin_production_sshd_effective.stdout is search('(?m)^passwordauthentication no$') + - litecoin_production_sshd_effective.stdout is search('(?m)^allowtcpforwarding no$') + - litecoin_production_sshd_effective.stdout is search('(?m)^disableforwarding yes$') + + - name: Read the litecoin.conf permissions + ansible.builtin.stat: + path: /etc/litecoin/litecoin.conf + register: litecoin_production_conf_stat + + - name: Require the protected litecoin.conf + ansible.builtin.assert: + that: + - litecoin_production_conf_stat.stat.mode == "0640" + - litecoin_production_conf_stat.stat.pw_name == "root" + - litecoin_production_conf_stat.stat.gr_name == "litecoin" + + - name: Read the restic password file state without reading its content + ansible.builtin.stat: + path: /etc/litecoin-backup/restic-password + get_checksum: false + register: litecoin_production_restic_password_stat + + - name: Require the operator-provided restic secret with safe permissions + ansible.builtin.assert: + that: + - litecoin_production_restic_password_stat.stat.exists + - litecoin_production_restic_password_stat.stat.mode == "0600" + - litecoin_production_restic_password_stat.stat.pw_name == "root" + fail_msg: >- + /etc/litecoin-backup/restic-password must exist as root:root 0600; + the operator installs it once (GNAI-024 Abschnitt 6 Schritt 0). + + - name: Read the enabled backup timers + ansible.builtin.command: + argv: [/usr/bin/systemctl, list-timers, --no-legend, litecoin-wallet-backup.timer, litecoin-restic-check.timer] + check_mode: false + changed_when: false + register: litecoin_production_timers + + - name: Require both backup timers + ansible.builtin.assert: + that: + - litecoin_production_timers.stdout is search('litecoin-wallet-backup.timer') + - litecoin_production_timers.stdout is search('litecoin-restic-check.timer') + + - name: Report the verified CT 114 production state + ansible.builtin.debug: + msg: + ctid: "{{ litecoin_ctid }}" + ipv4: "{{ ansible_facts['default_ipv4']['address'] }}" + litecoind: "{{ litecoin_production_version.stdout.splitlines()[0] }}" + listeners: "{{ litecoin_production_listeners.stdout_lines }}" + services: "{{ litecoin_production_services.stdout_lines }}" + ssh_fingerprint: "{{ litecoin_expected_ssh_host_key_fingerprint }}" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/README.md b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/README.md new file mode 100644 index 0000000..5cd1428 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/README.md @@ -0,0 +1,18 @@ +# litecoin_access + +Access model for CT 114, mirroring `keycloak_access` / GNAI-011: + +- `ghost-agent` (1000, locked, no groups): `restrict,from="10.0.0.0/24,10.8.0.0/24"` + key plus a NOPASSWD sudo rule limited to `/usr/local/bin/ltc-readonly`, a + wrapper that whitelists read-only `litecoin-cli` calls and runs them as the + `litecoin` user (cookie auth, no stored RPC credentials). +- `ghost` (1001, password-gated sudo): personal admin key with forwarding + restrictions. +- `ansible-deploy` (1002, locked, `NOPASSWD: ALL`): `restrict,from=...` key. +- Root SSH emptied, `PermitRootLogin no`, password auth off, socket activation + off, and `DisableForwarding yes` — therefore no SSH port forwarding; the + Litecoin RPC (127.0.0.1:9332) is only used via SSH exec, never via tunnel. + +All public keys come from `ansible/files/ssh/`; the role fails closed when a +key file is missing (the `ghost` key is generated interactively by the +operator before the first converge — GNAI-024 Abschnitt 6 Schritt 0). diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/defaults/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/defaults/main.yml new file mode 100644 index 0000000..d95e589 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/defaults/main.yml @@ -0,0 +1,37 @@ +--- +litecoin_access_source_networks: 10.0.0.0/24,10.8.0.0/24 +litecoin_access_public_key_root: "{{ playbook_dir }}/../files/ssh" + +litecoin_access_agent_user: ghost-agent +litecoin_access_agent_uid: 1000 +litecoin_access_agent_public_key_file: >- + {{ litecoin_access_public_key_root }}/litecoin-ghost-agent.pub + +litecoin_access_admin_user: ghost +litecoin_access_admin_uid: 1001 +litecoin_access_admin_public_key_file: >- + {{ litecoin_access_public_key_root }}/litecoin-ghost.pub + +litecoin_access_deploy_user: ansible-deploy +litecoin_access_deploy_uid: 1002 +litecoin_access_deploy_public_key_file: >- + {{ litecoin_access_public_key_root }}/litecoin-ansible-deploy.pub + +litecoin_access_ssh_dropin: /etc/ssh/sshd_config.d/99-ghostnet-litecoin.conf +litecoin_access_sudoers_file: /etc/sudoers.d/90-ghostnet-ansible-deploy +litecoin_access_readonly_sudoers_file: /etc/sudoers.d/91-ghostnet-litecoin-readonly +litecoin_access_readonly_wrapper: /usr/local/bin/ltc-readonly + +# Read-only litecoin-cli calls the agent account may run via the wrapper. +# Sending coins is deliberately not in this list; it stays an interactive +# `sudo -u litecoin litecoin-cli ...` action by ghost/ansible-deploy after an +# explicit walletpassphrase unlock (GNAI-024 Abschnitt 8). +litecoin_access_readonly_commands: + - getbalance + - getblockchaininfo + - getblockcount + - getmempoolinfo + - getnetworkinfo + - getpeerinfo + - getwalletinfo + - listtransactions diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/handlers/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/handlers/main.yml new file mode 100644 index 0000000..f67d8e5 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Restart the classic SSH service + ansible.builtin.systemd_service: + name: ssh.service + state: restarted diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/tasks/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/tasks/main.yml new file mode 100644 index 0000000..943475c --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/tasks/main.yml @@ -0,0 +1,229 @@ +--- +- name: Require all three role-specific public keys in files/ssh (control node) + ansible.builtin.stat: + path: "{{ item }}" + delegate_to: localhost + become: false + loop: + - "{{ litecoin_access_agent_public_key_file }}" + - "{{ litecoin_access_admin_public_key_file }}" + - "{{ litecoin_access_deploy_public_key_file }}" + register: litecoin_access_public_keys + +- name: Fail with a clear message when a public key is missing + ansible.builtin.fail: + msg: >- + Missing public key {{ item.item }}. The operator generates the CT 114 + key pairs (the ghost key interactively with passphrase) and copies the + .pub files into ansible/files/ssh/ before converging (GNAI-024 + Abschnitt 6, Schritt 0). + when: not item.stat.exists + loop: "{{ litecoin_access_public_keys.results }}" + loop_control: + label: "{{ item.item }}" + +- name: Validate the public key files are real OpenSSH keys (control node) + ansible.builtin.command: + argv: + - /usr/bin/ssh-keygen + - -l + - -f + - "{{ item }}" + delegate_to: localhost + become: false + check_mode: false + changed_when: false + loop: + - "{{ litecoin_access_agent_public_key_file }}" + - "{{ litecoin_access_admin_public_key_file }}" + - "{{ litecoin_access_deploy_public_key_file }}" + loop_control: + label: "{{ item }}" + +- name: Create fixed primary groups for Litecoin access accounts + ansible.builtin.group: + name: "{{ item.name }}" + gid: "{{ item.uid }}" + state: present + loop: + - name: "{{ litecoin_access_agent_user }}" + uid: "{{ litecoin_access_agent_uid }}" + - name: "{{ litecoin_access_admin_user }}" + uid: "{{ litecoin_access_admin_uid }}" + - name: "{{ litecoin_access_deploy_user }}" + uid: "{{ litecoin_access_deploy_uid }}" + loop_control: + label: "{{ item.name }}" + +- name: Create fixed Litecoin access accounts + ansible.builtin.user: + name: "{{ item.name }}" + uid: "{{ item.uid }}" + group: "{{ item.name }}" + home: "/home/{{ item.name }}" + shell: /bin/bash + create_home: true + state: present + loop: + - name: "{{ litecoin_access_agent_user }}" + uid: "{{ litecoin_access_agent_uid }}" + - name: "{{ litecoin_access_admin_user }}" + uid: "{{ litecoin_access_admin_uid }}" + - name: "{{ litecoin_access_deploy_user }}" + uid: "{{ litecoin_access_deploy_uid }}" + loop_control: + label: "{{ item.name }}" + +- name: Keep the read-only agent outside supplementary groups + ansible.builtin.user: + name: "{{ litecoin_access_agent_user }}" + groups: "" + append: false + password_lock: true + +- name: Keep the deployment account outside supplementary groups + ansible.builtin.user: + name: "{{ litecoin_access_deploy_user }}" + groups: "" + append: false + password_lock: true + +- name: Grant password-gated sudo membership to the administrator + ansible.builtin.user: + name: "{{ litecoin_access_admin_user }}" + groups: + - sudo + append: true + +- name: Create protected SSH directories + ansible.builtin.file: + path: "/home/{{ item }}/.ssh" + state: directory + owner: "{{ item }}" + group: "{{ item }}" + mode: "0700" + loop: + - "{{ litecoin_access_agent_user }}" + - "{{ litecoin_access_admin_user }}" + - "{{ litecoin_access_deploy_user }}" + +- name: Install the restricted read-only agent key + ansible.builtin.copy: + content: | + restrict,from="{{ litecoin_access_source_networks }}" {{ lookup('ansible.builtin.file', litecoin_access_agent_public_key_file) }} + dest: "/home/{{ litecoin_access_agent_user }}/.ssh/authorized_keys" + owner: "{{ litecoin_access_agent_user }}" + group: "{{ litecoin_access_agent_user }}" + mode: "0600" + +- name: Install the restricted personal administrator key + ansible.builtin.copy: + content: | + from="{{ litecoin_access_source_networks }}",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc {{ lookup('ansible.builtin.file', litecoin_access_admin_public_key_file) }} + dest: "/home/{{ litecoin_access_admin_user }}/.ssh/authorized_keys" + owner: "{{ litecoin_access_admin_user }}" + group: "{{ litecoin_access_admin_user }}" + mode: "0600" + +- name: Install the restricted deployment key + ansible.builtin.copy: + content: | + restrict,from="{{ litecoin_access_source_networks }}" {{ lookup('ansible.builtin.file', litecoin_access_deploy_public_key_file) }} + dest: "/home/{{ litecoin_access_deploy_user }}/.ssh/authorized_keys" + owner: "{{ litecoin_access_deploy_user }}" + group: "{{ litecoin_access_deploy_user }}" + mode: "0600" + +- name: Install validated deployment sudo policy + ansible.builtin.copy: + content: | + {{ litecoin_access_deploy_user }} ALL=(root) NOPASSWD: ALL + dest: "{{ litecoin_access_sudoers_file }}" + owner: root + group: root + mode: "0440" + validate: /usr/sbin/visudo -cf %s + +- name: Install the read-only wrapper for the agent account + ansible.builtin.template: + src: ltc-readonly.sh.j2 + dest: "{{ litecoin_access_readonly_wrapper }}" + owner: root + group: root + mode: "0750" + validate: /bin/bash -n %s + +- name: Install validated read-only sudo policy for the agent account + ansible.builtin.copy: + content: | + {{ litecoin_access_agent_user }} ALL=(root) NOPASSWD: {{ litecoin_access_readonly_wrapper }} + dest: "{{ litecoin_access_readonly_sudoers_file }}" + owner: root + group: root + mode: "0440" + validate: /usr/sbin/visudo -cf %s + +- name: Ensure root has no SSH authorization material + ansible.builtin.file: + path: /root/.ssh + state: directory + owner: root + group: root + mode: "0700" + +- name: Keep the root authorized keys file empty + ansible.builtin.copy: + content: "" + dest: /root/.ssh/authorized_keys + owner: root + group: root + mode: "0600" + +- name: Install the hardened SSH policy + ansible.builtin.template: + src: sshd.conf.j2 + dest: "{{ litecoin_access_ssh_dropin }}" + owner: root + group: root + mode: "0600" + validate: /usr/sbin/sshd -t -f %s + notify: Restart the classic SSH service + +- name: Disable SSH socket activation + ansible.builtin.systemd_service: + name: ssh.socket + enabled: false + state: stopped + +- name: Enable the classic SSH service + ansible.builtin.systemd_service: + name: ssh.service + enabled: true + state: started + +- name: Read account password states + ansible.builtin.command: + argv: + - /usr/bin/passwd + - -S + - "{{ item }}" + check_mode: false + changed_when: false + register: litecoin_access_password_states + loop: + - "{{ litecoin_access_agent_user }}" + - "{{ litecoin_access_admin_user }}" + - "{{ litecoin_access_deploy_user }}" + loop_control: + label: "{{ item }}" + +- name: Verify the locked password states + ansible.builtin.assert: + that: + - item.stdout.split()[1] in ["L", "P"] + fail_msg: >- + Account {{ item.item }} has unsafe password state + {{ item.stdout.split()[1] }}. + loop: "{{ litecoin_access_password_states.results }}" + loop_control: + label: "{{ item.item }}" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/templates/ltc-readonly.sh.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/templates/ltc-readonly.sh.j2 new file mode 100644 index 0000000..45ea94a --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/templates/ltc-readonly.sh.j2 @@ -0,0 +1,32 @@ +#!/bin/bash +# Managed by Ansible role litecoin_access. +# Read-only litecoin-cli wrapper for the ghost-agent account (NOPASSWD sudo). +# Whitelists read-only RPC calls and executes them as the litecoin service +# user so the node-local cookie auth is used. No sending, no wallet unlock. +set -Eeuo pipefail + +readonly ALLOWED=( +{% for command in litecoin_access_readonly_commands %} "{{ command }}" +{% endfor %}) + +if [[ $# -lt 1 ]]; then + printf 'usage: ltc-readonly [args...]\nallowed:' >&2 + printf ' %s' "${ALLOWED[@]}" >&2 + printf '\n' >&2 + exit 2 +fi + +allowed=0 +for candidate in "${ALLOWED[@]}"; do + if [[ "$1" == "$candidate" ]]; then + allowed=1 + break + fi +done +if [[ "$allowed" -ne 1 ]]; then + printf 'ltc-readonly: command not allowed: %s\n' "$1" >&2 + exit 2 +fi + +exec /usr/sbin/runuser -u litecoin -- \ + /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf "$@" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/templates/sshd.conf.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/templates/sshd.conf.j2 new file mode 100644 index 0000000..285438b --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_access/templates/sshd.conf.j2 @@ -0,0 +1,18 @@ +# Managed by Ansible role litecoin_access. +# GNAI-011 SSH baseline. TCP forwarding stays disabled on purpose: the +# Litecoin RPC is reached via `ssh ... ltc-readonly` / `sudo -u litecoin +# litecoin-cli`, never via an SSH tunnel (GNAI-024 Abschnitt 2, Befund d). +PermitRootLogin no +PasswordAuthentication no +KbdInteractiveAuthentication no +PubkeyAuthentication yes +AllowUsers {{ litecoin_access_agent_user }} {{ litecoin_access_admin_user }} {{ litecoin_access_deploy_user }} +X11Forwarding no +AllowAgentForwarding no +AllowTcpForwarding no +AllowStreamLocalForwarding no +DisableForwarding yes +PermitTunnel no +MaxAuthTries 3 +LoginGraceTime 30 +LogLevel VERBOSE diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/README.md b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/README.md new file mode 100644 index 0000000..4f6a4f3 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/README.md @@ -0,0 +1,16 @@ +# litecoin_backup + +Daily encrypted wallet backup of CT 114 (GNAI-024 Abschnitt 9): + +- `/usr/local/sbin/litecoin-wallet-backup.sh` runs `backupwallet` as the + `litecoin` user into `/var/lib/litecoin/backups/`, then a restic backup of + `backups/` only (never the chain — a restore re-syncs and then restores + `wallet.dat`), then `forget --keep-daily 30 --prune`. +- restic repository: `sftp:gn-backup@10.0.0.90:...` (host-independent backup + target ghostnet-ki) unless the operator overrides + `litecoin_backup_repository` with a separate PBS. Encryption is + client-side (restic default); the target only sees ciphertext. +- Secrets are never managed here: the restic password file and the dedicated + SSH key are placed by the operator into `/etc/litecoin-backup/` (root-only); + the role only pins the target host key and asserts file modes. The timers + run daily 03:00 (backup) and monthly (restic check). diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/defaults/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/defaults/main.yml new file mode 100644 index 0000000..1ba4783 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/defaults/main.yml @@ -0,0 +1,26 @@ +--- +# restic target on the host-independent backup host ghostnet-ki (10.0.0.90), +# account gn-backup; overridden per inventory (a separate PBS in the LAN is +# equally possible — GNAI-024 Abschnitt 2 Befund g). +litecoin_backup_repository: "sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic" +litecoin_backup_keep_daily: 30 + +litecoin_backup_env_dir: /etc/litecoin-backup +litecoin_backup_password_file: "{{ litecoin_backup_env_dir }}/restic-password" +# Default ssh identity name so restic's sftp backend picks it up via HOME. +litecoin_backup_ssh_key: "{{ litecoin_backup_env_dir }}/.ssh/id_ed25519" +litecoin_backup_known_hosts: "{{ litecoin_backup_env_dir }}/.ssh/known_hosts" +litecoin_backup_ssh_config: "{{ litecoin_backup_env_dir }}/ssh_config" +# ghostnet-ki host key (ed25519), same pin as pve_lxc_backup_sync. +litecoin_backup_target_host: 10.0.0.90 +litecoin_backup_target_user: gn-backup +litecoin_backup_target_host_key_ed25519: >- + ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID1UMrhG0WoKlRfadNadWdZogijlhjCz8uXfWbjvxuf8 +litecoin_backup_script: /usr/local/sbin/litecoin-wallet-backup.sh +litecoin_backup_service: litecoin-wallet-backup.service +litecoin_backup_timer: litecoin-wallet-backup.timer +litecoin_backup_timer_oncalendar: '*-*-* 03:00:00' +litecoin_restic_check_timer: litecoin-restic-check.timer +litecoin_restic_check_oncalendar: '*-*-01 04:00:00' +litecoin_backup_wallet_dir: /var/lib/litecoin/backups +litecoin_backup_logrotate: /etc/logrotate.d/litecoin-backup diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/handlers/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/handlers/main.yml new file mode 100644 index 0000000..0d67cbf --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: Reload systemd for litecoin backup + ansible.builtin.systemd_service: + daemon_reload: true diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/tasks/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/tasks/main.yml new file mode 100644 index 0000000..f71ab52 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/tasks/main.yml @@ -0,0 +1,124 @@ +--- +- name: Create the protected restic environment directory + ansible.builtin.file: + path: "{{ litecoin_backup_env_dir }}" + state: directory + owner: root + group: root + mode: "0700" + +- name: Create the root-only ssh directory for the restic key + ansible.builtin.file: + path: "{{ litecoin_backup_env_dir }}/.ssh" + state: directory + owner: root + group: root + mode: "0700" + +- name: Pin the backup target host key for restic's sftp backend + ansible.builtin.lineinfile: + path: "{{ litecoin_backup_known_hosts }}" + regexp: '^10\.0\.0\.90 ssh-ed25519 ' + line: "10.0.0.90 {{ litecoin_backup_target_host_key_ed25519 }}" + owner: root + group: root + mode: "0600" + create: true + +- name: Install the dedicated ssh client config for the restic sftp backend + ansible.builtin.template: + src: ssh_config.j2 + dest: "{{ litecoin_backup_ssh_config }}" + owner: root + group: root + mode: "0600" + +- name: Require the operator-provided restic SSH key + ansible.builtin.stat: + path: "{{ litecoin_backup_ssh_key }}" + register: litecoin_backup_ssh_key_stat + +- name: Fail with a clear message when the restic SSH key is missing + ansible.builtin.fail: + msg: >- + {{ litecoin_backup_ssh_key }} is missing. The operator creates the + dedicated CT 114 backup key, authorizes it for gn-backup on + ghostnet-ki (source-restricted to 10.0.0.61) and installs the private + key here with mode 0600; the public key never enters the repository + (GNAI-024 Abschnitt 6 Schritt 0). + when: not litecoin_backup_ssh_key_stat.stat.exists + +- name: Verify the restic SSH key permissions + ansible.builtin.stat: + path: "{{ litecoin_backup_ssh_key }}" + register: litecoin_backup_ssh_key_mode + +- name: Assert the restic SSH key is root-only + ansible.builtin.assert: + that: + - litecoin_backup_ssh_key_mode.stat.mode == "0600" + - litecoin_backup_ssh_key_mode.stat.pw_name == "root" + fail_msg: "{{ litecoin_backup_ssh_key }} must be root:root 0600." + +- name: Install the daily wallet backup script + ansible.builtin.template: + src: litecoin-wallet-backup.sh.j2 + dest: "{{ litecoin_backup_script }}" + owner: root + group: root + mode: "0750" + validate: /bin/bash -n %s + +- name: Install the wallet backup systemd service + ansible.builtin.template: + src: litecoin-wallet-backup.service.j2 + dest: "/etc/systemd/system/{{ litecoin_backup_service }}" + owner: root + group: root + mode: "0644" + notify: Reload systemd for litecoin backup + +- name: Install the daily wallet backup timer + ansible.builtin.template: + src: litecoin-wallet-backup.timer.j2 + dest: "/etc/systemd/system/{{ litecoin_backup_timer }}" + owner: root + group: root + mode: "0644" + notify: Reload systemd for litecoin backup + +- name: Install the monthly restic check service + ansible.builtin.template: + src: litecoin-restic-check.service.j2 + dest: /etc/systemd/system/litecoin-restic-check.service + owner: root + group: root + mode: "0644" + notify: Reload systemd for litecoin backup + +- name: Install the monthly restic check timer + ansible.builtin.template: + src: litecoin-restic-check.timer.j2 + dest: "/etc/systemd/system/{{ litecoin_restic_check_timer }}" + owner: root + group: root + mode: "0644" + notify: Reload systemd for litecoin backup + +- name: Install the backup log logrotate policy + ansible.builtin.template: + src: litecoin-backup.logrotate.j2 + dest: "{{ litecoin_backup_logrotate }}" + owner: root + group: root + mode: "0644" + +- name: Enable the backup timers + ansible.builtin.systemd_service: + name: "{{ item }}" + enabled: true + state: started + daemon_reload: true + loop: + - "{{ litecoin_backup_timer }}" + - "{{ litecoin_restic_check_timer }}" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-backup.logrotate.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-backup.logrotate.j2 new file mode 100644 index 0000000..717321a --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-backup.logrotate.j2 @@ -0,0 +1,8 @@ +/var/log/litecoin-backup.log { + weekly + rotate 8 + compress + missingok + notifempty + copytruncate +} diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.service.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.service.j2 new file mode 100644 index 0000000..b9d6896 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.service.j2 @@ -0,0 +1,8 @@ +[Unit] +Description=Monthly restic check of the Litecoin wallet backup repository + +[Service] +Type=oneshot +Environment=SSH_AUTH_SOCK= +ExecStart=/usr/bin/restic check --read-data-subset=5% -r {{ litecoin_backup_repository }} -o sftp.command="ssh -F {{ litecoin_backup_ssh_config }} {{ litecoin_backup_target_user }}@{{ litecoin_backup_target_host }} -s sftp" --password-file {{ litecoin_backup_password_file }} +Nice=10 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.timer.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.timer.j2 new file mode 100644 index 0000000..1cbfc09 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.timer.j2 @@ -0,0 +1,9 @@ +[Unit] +Description=Monthly restic repository check for the Litecoin wallet backups + +[Timer] +OnCalendar={{ litecoin_restic_check_oncalendar }} +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.service.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.service.j2 new file mode 100644 index 0000000..28ab5c1 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.service.j2 @@ -0,0 +1,11 @@ +[Unit] +Description=Encrypted Litecoin wallet backup to the off-host restic repository +After=litecoind.service + +[Service] +Type=oneshot +ExecStart={{ litecoin_backup_script }} +# Runs as root; the script passes the restic SSH key and known_hosts +# explicitly via restic's sftp.command (ssh ignores $HOME for ~). +Environment=SSH_AUTH_SOCK= +Nice=10 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.sh.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.sh.j2 new file mode 100644 index 0000000..92b904e --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.sh.j2 @@ -0,0 +1,34 @@ +#!/bin/bash +# Managed by Ansible role litecoin_backup. +# Daily wallet backup: backupwallet as the litecoin user, then a +# client-side encrypted restic backup of backups/ only (never the chain — +# a restore re-syncs the chain and then restores wallet.dat). Secrets stay +# in {{ litecoin_backup_password_file }} (root-only) and the dedicated SSH key; +# nothing is written to logs or the repository. +set -Eeuo pipefail + +export RESTIC_REPOSITORY="{{ litecoin_backup_repository }}" +export RESTIC_PASSWORD_FILE="{{ litecoin_backup_password_file }}" + +# ssh resolves ~ from the passwd entry, not from $HOME, so the restic sftp +# backend gets a dedicated client config via sftp.command. +# restic 0.18: sftp.command is the COMPLETE ssh invocation (host and +# -s sftp included); restic does not append them when the option is set. +SFTP_COMMAND="ssh -F {{ litecoin_backup_ssh_config }} {{ litecoin_backup_target_user }}@{{ litecoin_backup_target_host }} -s sftp" + +backup_dir="{{ litecoin_backup_wallet_dir }}" +today="$(date +%F)" + +/usr/sbin/runuser -u litecoin -- \ + /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf \ + backupwallet "${backup_dir}/wallet-${today}" + +/usr/bin/restic backup "$backup_dir" \ + -r "$RESTIC_REPOSITORY" \ + -o "sftp.command=$SFTP_COMMAND" \ + --password-file "$RESTIC_PASSWORD_FILE" + +/usr/bin/restic forget --keep-daily {{ litecoin_backup_keep_daily }} --prune \ + -r "$RESTIC_REPOSITORY" \ + -o "sftp.command=$SFTP_COMMAND" \ + --password-file "$RESTIC_PASSWORD_FILE" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.timer.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.timer.j2 new file mode 100644 index 0000000..b5d4f45 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.timer.j2 @@ -0,0 +1,9 @@ +[Unit] +Description=Daily encrypted Litecoin wallet backup (03:00) + +[Timer] +OnCalendar={{ litecoin_backup_timer_oncalendar }} +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/ssh_config.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/ssh_config.j2 new file mode 100644 index 0000000..9b0cca6 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/ssh_config.j2 @@ -0,0 +1,12 @@ +# Managed by Ansible role litecoin_backup. +# Dedicated ssh client config for the restic sftp backend (restic runs +# `ssh -F gn-backup@10.0.0.90 -s sftp`); ssh resolves ~ from +# the passwd entry, so all paths are absolute. +Host {{ litecoin_backup_target_host }} + HostName {{ litecoin_backup_target_host }} + User {{ litecoin_backup_target_user }} + IdentityFile {{ litecoin_backup_ssh_key }} + IdentitiesOnly yes + BatchMode yes + StrictHostKeyChecking yes + UserKnownHostsFile {{ litecoin_backup_known_hosts }} diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/README.md b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/README.md new file mode 100644 index 0000000..423e66c --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/README.md @@ -0,0 +1,16 @@ +# litecoin_core + +Installs the pinned Litecoin Core release into `/opt/litecoin-` with +a stable `/opt/litecoin` symlink. The tarball is fetched over HTTPS from +`download.litecoin.org` and verified fail-closed against the pinned SHA-256 +from the signed `SHA256SUMS.asc` (v0.21.5.8, see GNAI-024 Abschnitt 2 Befund +a); the role then asserts `litecoind --version`. + +`litecoin.conf` is Tor-only (`proxy=127.0.0.1:9050`, `onlynet=onion`, +`listen=0`, no seeds/UPNP/NAT-PMP), RPC on `127.0.0.1:9332` with cookie auth +(no `rpcpassword`, no `rpcauth` material in any file — the node is only ever +administered as the `litecoin` user over SSH exec, GNAI-024 Befund d/e). +`litecoind.service` runs as `litecoin` with systemd hardening; the service is +enabled and started only when the inventory sets +`litecoin_service_start_allowed: true` (production). debug.log is rotated +weekly (copytruncate). diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/defaults/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/defaults/main.yml new file mode 100644 index 0000000..7c1f48c --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/defaults/main.yml @@ -0,0 +1,27 @@ +--- +litecoin_core_version: 0.21.5.8 +litecoin_core_tarball_name: "litecoin-{{ litecoin_core_version }}-x86_64-linux-gnu.tar.gz" +litecoin_core_base_url: "https://download.litecoin.org/litecoin-{{ litecoin_core_version }}/linux" +# SHA-256 from the signed SHA256SUMS.asc (GNAI-024 Abschnitt 2 Befund a). +litecoin_core_tarball_sha256: >- + 43200c9f9d65ebc126ea5833ca9429e144c4b3273da6bb9f4e89fd7450ab1be9 + +litecoin_core_install_root: /opt +litecoin_core_versioned_dir: "{{ litecoin_core_install_root }}/litecoin-{{ litecoin_core_version }}" +litecoin_core_symlink: "{{ litecoin_core_install_root }}/litecoin" +litecoin_core_download_dir: /usr/local/src/litecoin + +litecoin_core_user: litecoin +litecoin_core_group: litecoin +litecoin_core_datadir: /var/lib/litecoin +litecoin_core_config_dir: /etc/litecoin +litecoin_core_config: "{{ litecoin_core_config_dir }}/litecoin.conf" + +# Litecoin mainnet: P2P 9333, RPC 9332 (GNAI-024 Befund c: 8332 ist Bitcoin). +litecoin_core_rpc_port: 9332 +litecoin_core_tor_socks: 127.0.0.1:9050 +litecoin_core_dbcache_mb: 2048 +litecoin_core_fallbackfee: 0.0001 + +litecoin_core_service_name: litecoind.service +litecoin_core_logrotate: /etc/logrotate.d/litecoin diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/handlers/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/handlers/main.yml new file mode 100644 index 0000000..e089550 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/handlers/main.yml @@ -0,0 +1,9 @@ +--- +- name: Reload systemd for litecoind + ansible.builtin.systemd_service: + daemon_reload: true + +- name: Restart litecoind + ansible.builtin.systemd_service: + name: litecoind.service + state: restarted diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/tasks/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/tasks/main.yml new file mode 100644 index 0000000..680e102 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/tasks/main.yml @@ -0,0 +1,91 @@ +--- +- name: Require the pinned Litecoin Core tarball checksum + ansible.builtin.assert: + that: + - litecoin_core_tarball_sha256 is match('^[0-9a-f]{64}$') + - litecoin_core_version is match('^0\\.21\\.5\\.[0-9]+$') + fail_msg: >- + litecoin_core_tarball_sha256 must be a pinned 64-hex SHA-256 from the + signed SHA256SUMS.asc and the version must be in the audited 0.21.5.x + series (GNAI-024 Abschnitt 2 Befund a). + +- name: Download the pinned Litecoin Core release tarball + ansible.builtin.get_url: + url: "{{ litecoin_core_base_url }}/{{ litecoin_core_tarball_name }}" + dest: "{{ litecoin_core_download_dir }}/{{ litecoin_core_tarball_name }}" + checksum: "sha256:{{ litecoin_core_tarball_sha256 }}" + mode: "0644" + owner: root + group: root + timeout: 300 + +- name: Extract the verified Litecoin Core release + ansible.builtin.unarchive: + src: "{{ litecoin_core_download_dir }}/{{ litecoin_core_tarball_name }}" + dest: "{{ litecoin_core_install_root }}" + remote_src: true + creates: "{{ litecoin_core_versioned_dir }}/bin/litecoind" + +- name: Point the stable symlink at the verified version + ansible.builtin.file: + src: "{{ litecoin_core_versioned_dir }}" + dest: "{{ litecoin_core_symlink }}" + state: link + owner: root + group: root + +- name: Verify the installed litecoind binary + ansible.builtin.command: + argv: + - "{{ litecoin_core_symlink }}/bin/litecoind" + - --version + check_mode: false + changed_when: false + register: litecoin_core_version_output + +- name: Assert the expected Litecoin Core version + ansible.builtin.assert: + that: + - "('Litecoin Core version v' ~ litecoin_core_version) in litecoin_core_version_output.stdout" + fail_msg: "Unexpected litecoind version: {{ litecoin_core_version_output.stdout }}" + +- name: Install the managed litecoin.conf + ansible.builtin.template: + src: litecoin.conf.j2 + dest: "{{ litecoin_core_config }}" + owner: root + group: "{{ litecoin_core_group }}" + mode: "0640" + notify: Restart litecoind + +- name: Install the hardened litecoind systemd unit + ansible.builtin.template: + src: litecoind.service.j2 + dest: "/etc/systemd/system/{{ litecoin_core_service_name }}" + owner: root + group: root + mode: "0644" + notify: + - Reload systemd for litecoind + - Restart litecoind + +- name: Install the litecoin debug.log logrotate policy + ansible.builtin.template: + src: litecoin.logrotate.j2 + dest: "{{ litecoin_core_logrotate }}" + owner: root + group: root + mode: "0644" + +- name: Enable litecoind without starting it yet + ansible.builtin.systemd_service: + name: "{{ litecoin_core_service_name }}" + enabled: true + state: "{{ 'started' if litecoin_service_start_allowed | bool else 'stopped' }}" + daemon_reload: true + +- name: Start litecoind when the inventory allows it + ansible.builtin.systemd_service: + name: "{{ litecoin_core_service_name }}" + state: started + when: litecoin_service_start_allowed | bool diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoin.conf.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoin.conf.j2 new file mode 100644 index 0000000..5d2af45 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoin.conf.j2 @@ -0,0 +1,32 @@ +# Managed by Ansible role litecoin_core. No credentials in this file: +# RPC is cookie-authenticated and bound to loopback only (GNAI-024 Befund d/e). + +# --- Network: ALL traffic via Tor (SOCKS5), no inbound, our IP never exposed --- +# GNAI-024 Befund k (2026-11-27): the compiled-in onion seeds of v0.21.5.8 are +# unreachable ("host unreachable" via Tor while clearnet-via-Tor works), so +# onlynet=onion would leave the node peerless forever. With proxy set, DNS +# seeds and clearnet peers are reached through Tor exit relays; listen=0 and +# discover=0 keep the node dial-out only. +proxy={{ litecoin_core_tor_socks }} +listen=0 +discover=0 +upnp=0 +natpmp=0 + +# --- RPC: loopback only, cookie auth, no stored credentials --- +server=1 +rpcbind=127.0.0.1 +rpcallowip=127.0.0.1 +rpcport={{ litecoin_core_rpc_port }} +rpcthreads=4 + +# --- Chain / wallet --- +datadir={{ litecoin_core_datadir }} +dbcache={{ litecoin_core_dbcache_mb }} +txindex=0 +wallet=cold +fallbackfee={{ litecoin_core_fallbackfee }} +# MWEB stays usable locally, but addresses handed to exchanges or services +# (Bitpanda, Rapidgator) must always be legacy/bech32, never ltcmweb1... +# (GNAI-024 Abschnitt 2 Befund f). +prune=0 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoin.logrotate.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoin.logrotate.j2 new file mode 100644 index 0000000..5a7f8f2 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoin.logrotate.j2 @@ -0,0 +1,8 @@ +{{ litecoin_core_datadir }}/debug.log { + weekly + rotate 4 + compress + missingok + notifempty + copytruncate +} diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoind.service.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoind.service.j2 new file mode 100644 index 0000000..de5209d --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_core/templates/litecoind.service.j2 @@ -0,0 +1,34 @@ +[Unit] +Description=Litecoin Core full node (Tor-only cold wallet) +After=network-online.target tor.service +Wants=network-online.target + +[Service] +Type=simple +User={{ litecoin_core_user }} +Group={{ litecoin_core_group }} +ExecStart={{ litecoin_core_symlink }}/bin/litecoind -conf={{ litecoin_core_config }} -datadir={{ litecoin_core_datadir }} +Restart=on-failure +RestartSec=30 +TimeoutStopSec=120 +KillSignal=SIGINT + +# Hardening +NoNewPrivileges=true +ProtectSystem=strict +ProtectHome=true +PrivateTmp=true +PrivateDevices=true +ProtectKernelTunables=true +ProtectKernelModules=true +ProtectControlGroups=true +RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX +RestrictNamespaces=true +LockPersonality=true +MemoryDenyWriteExecute=true +CapabilityBoundingSet= +AmbientCapabilities= +ReadWritePaths={{ litecoin_core_datadir }} + +[Install] +WantedBy=multi-user.target diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/README.md b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/README.md new file mode 100644 index 0000000..39e234f --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/README.md @@ -0,0 +1,7 @@ +# litecoin_fail2ban + +Native fail2ban (apt, no Podman on CT 114) with the sshd jail on the systemd +backend (Debian 13 LXC has no rsyslog), banning via `nftables-multiport`. +Management networks (LAN, WireGuard) are on `ignoreip`; the jail is verified +with `fail2ban-client status sshd`. Mirrors the CT 103 fail2ban abnahme +without the NPM-specific jails. diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/defaults/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/defaults/main.yml new file mode 100644 index 0000000..a054f12 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/defaults/main.yml @@ -0,0 +1,7 @@ +--- +litecoin_fail2ban_jail_dropin: /etc/fail2ban/jail.d/00-ghostnet-litecoin.conf +litecoin_fail2ban_bantime: 1h +litecoin_fail2ban_findtime: 10m +litecoin_fail2ban_maxretry: 3 +# Management networks are trusted; only brute force from elsewhere is banned. +litecoin_fail2ban_ignoreip: 127.0.0.1/8 10.0.0.0/24 10.8.0.0/24 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/handlers/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/handlers/main.yml new file mode 100644 index 0000000..ba2cbac --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Restart fail2ban + ansible.builtin.systemd_service: + name: fail2ban.service + state: restarted diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/tasks/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/tasks/main.yml new file mode 100644 index 0000000..f6f0eee --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/tasks/main.yml @@ -0,0 +1,33 @@ +--- +- name: Install the Ghostnet fail2ban jail drop-in + ansible.builtin.template: + src: jail.local.j2 + dest: "{{ litecoin_fail2ban_jail_dropin }}" + owner: root + group: root + mode: "0644" + notify: Restart fail2ban + +- name: Enable and start fail2ban + ansible.builtin.systemd_service: + name: fail2ban.service + enabled: true + state: started + +- name: Read the fail2ban sshd jail status + ansible.builtin.command: + argv: + - /usr/bin/fail2ban-client + - status + - sshd + check_mode: false + changed_when: false + register: litecoin_fail2ban_sshd_status + when: not ansible_check_mode + +- name: Verify the sshd jail is active + ansible.builtin.assert: + that: + - "litecoin_fail2ban_sshd_status.stdout is search('Status for the jail: sshd')" + - "litecoin_fail2ban_sshd_status.stdout is search('Journal matches')" + when: not ansible_check_mode diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/templates/jail.local.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/templates/jail.local.j2 new file mode 100644 index 0000000..a11736a --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_fail2ban/templates/jail.local.j2 @@ -0,0 +1,15 @@ +# Managed by Ansible role litecoin_fail2ban. +# Debian 13 has no rsyslog in the LXC; the sshd jail reads the journal. +[DEFAULT] +backend = systemd +bantime = {{ litecoin_fail2ban_bantime }} +findtime = {{ litecoin_fail2ban_findtime }} +maxretry = {{ litecoin_fail2ban_maxretry }} +ignoreip = {{ litecoin_fail2ban_ignoreip }} +action = nftables-multiport[port="ssh", protocol=tcp] + +[sshd] +enabled = true +port = ssh +logpath = %(sshd_log)s +backend = systemd diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/README.md b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/README.md new file mode 100644 index 0000000..e55bad7 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/README.md @@ -0,0 +1,9 @@ +# litecoin_firewall + +Native nftables policy for CT 114 (repo convention: nftables, not ufw — +GNAI-024 Abschnitt 2 Befund b): `inet ghostnet_filter` with default-deny +input, loopback and established traffic accepted, ICMP diagnostics, SSH (TCP +22) only from the management networks (`10.0.0.0/24`, `10.8.0.0/24`), output +accepted (the Tor client needs outbound), forward dropped. No port of +litecoind (P2P 9333, RPC 9332) is ever opened; the service override destroys +only the Ghostnet-owned table on service stop. diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/defaults/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/defaults/main.yml new file mode 100644 index 0000000..9e37276 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/defaults/main.yml @@ -0,0 +1,5 @@ +--- +litecoin_firewall_management_ipv4: + - 10.0.0.0/24 + - 10.8.0.0/24 +litecoin_firewall_ssh_port: 22 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/handlers/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/handlers/main.yml new file mode 100644 index 0000000..f6826de --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/handlers/main.yml @@ -0,0 +1,9 @@ +--- +- name: Reload systemd for the Litecoin firewall + ansible.builtin.systemd_service: + daemon_reload: true + +- name: Restart the Litecoin firewall + ansible.builtin.systemd_service: + name: nftables.service + state: restarted diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/tasks/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/tasks/main.yml new file mode 100644 index 0000000..dec9adf --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/tasks/main.yml @@ -0,0 +1,93 @@ +--- +- name: Require a non-empty management allowlist + ansible.builtin.assert: + that: + - litecoin_firewall_management_ipv4 | length > 0 + fail_msg: The firewall management allowlist must be explicit and non-empty. + +- name: Read the active Ansible SSH transport endpoints + become: false + ansible.builtin.command: + argv: + - /usr/bin/printenv + - SSH_CONNECTION + check_mode: false + changed_when: false + register: litecoin_firewall_ssh_connection + +- name: Require the active Ansible SSH source in the management allowlist + ansible.builtin.command: + argv: >- + {{ + [ + '/usr/bin/python3', + '-c', + 'import ipaddress,sys; address=ipaddress.ip_address(sys.argv[1]); raise SystemExit(0 if any(address in ipaddress.ip_network(network) for network in sys.argv[2:]) else 1)', + litecoin_firewall_ssh_connection.stdout.split()[0] + ] + litecoin_firewall_management_ipv4 + }} + check_mode: false + changed_when: false + vars: + ansible_command_timeout: 5 + +- name: Create the nftables service override directory + ansible.builtin.file: + path: /etc/systemd/system/nftables.service.d + state: directory + owner: root + group: root + mode: "0755" + +- name: Install the scoped nftables stop override + ansible.builtin.template: + src: nftables.service-override.conf.j2 + dest: /etc/systemd/system/nftables.service.d/10-ghostnet-preserve.conf + owner: root + group: root + mode: "0644" + notify: + - Reload systemd for the Litecoin firewall + - Restart the Litecoin firewall + +- name: Install and validate the Litecoin nftables policy + ansible.builtin.template: + src: nftables.conf.j2 + dest: /etc/nftables.conf + owner: root + group: root + mode: "0750" + validate: /usr/sbin/nft --check --file %s + notify: Restart the Litecoin firewall + +- name: Flush firewall handlers before verification + ansible.builtin.meta: flush_handlers + +- name: Enable and start the nftables service + ansible.builtin.systemd_service: + name: nftables.service + enabled: true + state: started + daemon_reload: true + +- name: Read the active Ghostnet nftables table + ansible.builtin.command: + argv: + - /usr/sbin/nft + - list + - table + - inet + - ghostnet_filter + check_mode: false + changed_when: false + register: litecoin_firewall_active_table + when: not ansible_check_mode + +- name: Verify the active firewall policy + ansible.builtin.assert: + that: + - litecoin_firewall_active_table.stdout is search('policy drop') + - litecoin_firewall_active_table.stdout is search('SSH management') + - litecoin_firewall_active_table.stdout is search('default input deny') + - litecoin_firewall_active_table.stdout is search('CT 114 forwards nothing') + when: not ansible_check_mode diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/templates/nftables.conf.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/templates/nftables.conf.j2 new file mode 100644 index 0000000..05bfe75 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/templates/nftables.conf.j2 @@ -0,0 +1,43 @@ +#!/usr/sbin/nft -f + +# Managed by Ansible role litecoin_firewall. +# CT 114 runs no public service: default-deny input, SSH from the management +# networks only, no P2P (9333) and no RPC (9332) listener exposed. The node +# reaches the Litecoin network exclusively as a Tor client (outbound only). +destroy table inet ghostnet_filter + +table inet ghostnet_filter { + set management_ipv4 { + type ipv4_addr + flags interval + elements = { {{ litecoin_firewall_management_ipv4 | join(', ') }} } + } + + chain input { + type filter hook input priority 10; policy drop; + + iifname "lo" counter accept comment "local loopback" + ct state established,related counter accept + ct state invalid counter drop + + meta l4proto icmp counter accept comment "IPv4 diagnostics" + meta l4proto ipv6-icmp counter accept comment "IPv6 neighbor discovery" + + ip saddr @management_ipv4 tcp dport {{ litecoin_firewall_ssh_port }} ct state new counter accept comment "SSH management" + + counter drop comment "default input deny" + } + + chain forward { + type filter hook forward priority 10; policy drop; + + ct state invalid counter drop + counter drop comment "CT 114 forwards nothing" + } + + chain output { + type filter hook output priority 10; policy accept; + } +} + +{{ '' }} diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/templates/nftables.service-override.conf.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/templates/nftables.service-override.conf.j2 new file mode 100644 index 0000000..129c56e --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_firewall/templates/nftables.service-override.conf.j2 @@ -0,0 +1,6 @@ +[Service] +# Keep the Ghostnet table across service stops; only the owned table is +# destroyed so a restart does not leave the host unfiltered. +ExecStop= +ExecStop=/usr/sbin/nft destroy table inet ghostnet_filter +{{ '\n' }} diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/README.md b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/README.md new file mode 100644 index 0000000..a7e4c91 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/README.md @@ -0,0 +1,11 @@ +# litecoin_lxc_baseline + +Baseline role for CT 114 (`ltc-node`, 10.0.0.61): identity assertion against +the inventory safeguards, base packages (incl. `tor`, `fail2ban`, `restic`, +`unattended-upgrades`), the locked `litecoin` service account (UID/GID 1100, +`nologin`, no supplementary groups), timezone `Europe/Berlin`, protected +directories and security-only unattended-upgrades. Mirrors +`keycloak_lxc_baseline` / `dns_lxc_baseline`. + +The role never installs keys, secrets or application state; that belongs to +`litecoin_access`, `litecoin_core` and `litecoin_backup`. diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/defaults/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/defaults/main.yml new file mode 100644 index 0000000..c98c135 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/defaults/main.yml @@ -0,0 +1,43 @@ +--- +litecoin_lxc_baseline_timezone: Europe/Berlin + +litecoin_lxc_baseline_packages: + - ca-certificates + - curl + - fail2ban + - gnupg + - logrotate + - nftables + - openssh-server + - python3 + - restic + - sudo + - tor + - unattended-upgrades + +litecoin_lxc_baseline_directories: + - path: /etc/litecoin + owner: root + group: litecoin + mode: "0750" + - path: /etc/litecoin-backup + owner: root + group: root + mode: "0700" + # /opt/litecoin is the versioned symlink managed by litecoin_core, not a + # directory created here. + - path: /usr/local/src/litecoin + owner: root + group: root + mode: "0700" + - path: /var/lib/litecoin + owner: litecoin + group: litecoin + mode: "0700" + - path: /var/lib/litecoin/backups + owner: litecoin + group: litecoin + mode: "0700" + +litecoin_lxc_baseline_unattended_upgrades_allowed_origins: >- + Debian:${distro_codename} ${distro_codename}-security diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/handlers/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/handlers/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/handlers/main.yml @@ -0,0 +1 @@ +--- diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/tasks/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/tasks/main.yml new file mode 100644 index 0000000..62cefae --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_lxc_baseline/tasks/main.yml @@ -0,0 +1,106 @@ +--- +- name: Verify the Litecoin LXC identity before changing baseline state + ansible.builtin.assert: + that: + - ansible_facts["hostname"] == litecoin_lxc_baseline_expected_hostname + - >- + ansible_facts["distribution"] == + litecoin_lxc_baseline_expected_distribution + - >- + ansible_facts["distribution_major_version"] == + litecoin_lxc_baseline_expected_distribution_major_version + - >- + ansible_facts["default_ipv4"]["address"] == + litecoin_lxc_baseline_expected_ipv4 + - >- + ansible_facts["virtualization_type"] == + litecoin_lxc_baseline_expected_virtualization_type + - ansible_facts["virtualization_role"] == "guest" + - ansible_facts["service_mgr"] == "systemd" + fail_msg: >- + The connected system is not the declared CT 114 Litecoin LXC. No + baseline changes may be applied. + +- name: Install baseline administration packages + ansible.builtin.apt: + name: "{{ litecoin_lxc_baseline_packages }}" + state: present + update_cache: true + cache_valid_time: 3600 + install_recommends: false + +- name: Create the fixed primary group for the Litecoin service account + ansible.builtin.group: + name: litecoin + gid: 1100 + state: present + system: true + +- name: Create the locked Litecoin service account without login shell + ansible.builtin.user: + name: litecoin + uid: 1100 + group: litecoin + home: /var/lib/litecoin + shell: /usr/sbin/nologin + create_home: false + state: present + system: true + password_lock: true + +- name: Set the local timezone database link + ansible.builtin.file: + src: "/usr/share/zoneinfo/{{ litecoin_lxc_baseline_timezone }}" + dest: /etc/localtime + state: link + owner: root + group: root + force: true + +- name: Record the configured timezone + ansible.builtin.copy: + content: "{{ litecoin_lxc_baseline_timezone }}\n" + dest: /etc/timezone + owner: root + group: root + mode: "0644" + +- name: Create protected Litecoin configuration and data paths + ansible.builtin.file: + path: "{{ item.path }}" + state: directory + owner: "{{ item.owner }}" + group: "{{ item.group }}" + mode: "{{ item.mode }}" + loop: "{{ litecoin_lxc_baseline_directories }}" + loop_control: + label: "{{ item.path }}" + +- name: Mask LXC-incompatible mount units (CT 114 runs without nesting) + ansible.builtin.systemd_service: + name: "{{ item }}" + masked: true + state: stopped + loop: + - dev-mqueue.mount + - run-lock.mount + - tmp.mount + +- name: Enable and start the unattended-upgrades service (CT 100/102 convention) + ansible.builtin.systemd_service: + name: unattended-upgrades.service + enabled: true + state: started + +- name: Restrict unattended-upgrades to Debian security origins + ansible.builtin.copy: + content: |- + Unattended-Upgrade::Origins-Pattern { + "origin=Debian,codename=${distro_codename},label=Debian-Security"; + }; + Unattended-Upgrade::AutoFixInterruptedDpkg "true"; + Unattended-Upgrade::Remove-Unused-Dependencies "true"; + dest: /etc/apt/apt.conf.d/52ghostnet-unattended-upgrades + owner: root + group: root + mode: "0644" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/README.md b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/README.md new file mode 100644 index 0000000..4778ec0 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/README.md @@ -0,0 +1,8 @@ +# litecoin_tor + +Local-only Tor client in CT 114. `tor` runs as `debian-tor`, client-only +(`ClientOnly 1`, no OR/Dir/Exit), SOCKS on `127.0.0.1:9050` and ControlPort +on `127.0.0.1:9051`, both loopback-only. `litecoind` is configured with +`proxy=127.0.0.1:9050` and `onlynet=onion`, so all P2P traffic leaves via +Tor and the node accepts no inbound connections (`listen=0`). The role +waits for the SOCKS port and reports the bootstrap phase. diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/defaults/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/defaults/main.yml new file mode 100644 index 0000000..f965e5d --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/defaults/main.yml @@ -0,0 +1,6 @@ +--- +litecoin_tor_socks_port: 127.0.0.1:9050 +litecoin_tor_control_port: 127.0.0.1:9051 +litecoin_tor_data_directory: /var/lib/tor +litecoin_tor_config: /etc/tor/torrc +litecoin_tor_log: /var/log/tor/notices.log diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/handlers/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/handlers/main.yml new file mode 100644 index 0000000..f628a62 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Restart tor + ansible.builtin.systemd_service: + name: tor.service + state: restarted diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/tasks/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/tasks/main.yml new file mode 100644 index 0000000..7bc88fd --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/tasks/main.yml @@ -0,0 +1,56 @@ +--- +- name: Create the tor runtime directory + ansible.builtin.file: + path: /run/tor + state: directory + owner: debian-tor + group: debian-tor + mode: "0750" + +- name: Install the managed Tor client configuration + ansible.builtin.template: + src: torrc.j2 + dest: "{{ litecoin_tor_config }}" + owner: debian-tor + group: debian-tor + mode: "0640" + validate: /usr/bin/tor --verify-config -f %s + notify: Restart tor + +- name: Create the tor log directory + ansible.builtin.file: + path: /var/log/tor + state: directory + owner: debian-tor + group: debian-tor + mode: "0750" + +- name: Enable and start the Tor client service + ansible.builtin.systemd_service: + name: tor.service + enabled: true + state: started + +- name: Wait for the Tor SOCKS port on loopback + ansible.builtin.wait_for: + host: 127.0.0.1 + port: 9050 + timeout: 120 + when: not ansible_check_mode + +- name: Read the Tor bootstrap status from the journal (tor@default) + ansible.builtin.shell: | + /usr/bin/journalctl -u tor@default.service --no-pager --output=cat \ + | /usr/bin/grep -E 'Bootstrapped [0-9]+%' | tail -n 1 + args: + executable: /bin/bash + check_mode: false + changed_when: false + failed_when: false + register: litecoin_tor_bootstrap + when: not ansible_check_mode + +- name: Report the Tor bootstrap phase + ansible.builtin.debug: + msg: "{{ litecoin_tor_bootstrap.stdout_lines | default(['check mode: skipped']) | last | default('no bootstrap line in journal', true) }}" + when: not ansible_check_mode diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/templates/torrc.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/templates/torrc.j2 new file mode 100644 index 0000000..aca04d3 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_tor/templates/torrc.j2 @@ -0,0 +1,20 @@ +# Managed by Ansible role litecoin_tor. +# Local-only Tor client for litecoind: SOCKS on loopback, no public relay, +# no directory service exposure beyond what a client needs. +SocksPort {{ litecoin_tor_socks_port }} +ControlPort {{ litecoin_tor_control_port }} +DataDirectory {{ litecoin_tor_data_directory }} +CacheDirectory {{ litecoin_tor_data_directory }} +PidFile /run/tor/tor.pid +# Debian 13 logs via the journal (tor@default); no rsyslog in the LXC. +Log notice syslog +RunAsDaemon 0 +User debian-tor +# Client only: never act as relay, bridge or onion service host. +ClientOnly 1 +ORPort 0 +DirPort 0 +ExitPolicy reject *:* +# Keep bootstrap deterministic; litecoind uses onlynet=onion. +AssumeReachable 0 +NumEntryGuards 4 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/scripts/README.md b/proxmox/lxc/ct-114-litecoin-wallet/scripts/README.md new file mode 100644 index 0000000..3b717cb --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/scripts/README.md @@ -0,0 +1,128 @@ +# Proxmox automation — CT 114 Litecoin wallet + +Reviewed host-side helpers for the reproducible creation of CT 114 +(`ltc-node`, `10.0.0.61`). They contain no password and no private key. + +## CT 114 provisioning profile + +| Setting | CT 114 value | +| --- | --- | +| CT ID / hostname | `114` / `ltc-node` | +| OS | Debian 13, amd64 | +| Container type | unprivileged LXC, **no nesting** (litecoind is a plain systemd service, no Podman) | +| CPU | 2 cores | +| Memory | 4096 MiB | +| Swap | 1024 MiB (set via `pct set` after creation, as with CT 102) | +| Root disk | 150 GiB on `local-lvm` (thin-provisioned, snapshot-capable; chain ~100 GiB + growth) | +| Network | `vmbr0`, `10.0.0.61/24`, gateway `10.0.0.1`, DNS `10.0.0.14` (Pi-hole), IPv6 disabled | +| Boot / protection | start on boot, protection enabled | +| Time zone | `Europe/Berlin` | +| Initial root SSH | not required; the hook installs and hardens OpenSSH | +| Post-install hook | `/usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh` | + +`10.0.0.61` is inside the static server range (up to `.99`, GNAI-007 +Adressplan) and was free in the documented inventory; the DHCP client range +starts at `.100`. + +## Step 0 (workstation, before any PVE step) + +The operator generates the three CT 114 key pairs and installs the public +keys: + +```bash +ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_ghostnet_ct114_ghost -C "ghost@ghostnet-ct114" # interactively, with passphrase +# ghost-agent and ansible-deploy are passphrase-less per AGENTS.md and were +# already generated on 2026-11-25: +# ~/.ssh/id_ed25519_ghostnet_ct114_agent +# ~/.ssh/id_ed25519_ghostnet_ct114_ansible_deploy +cp ~/.ssh/id_ed25519_ghostnet_ct114_*.pub into this repo: + proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost.pub + proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost-agent.pub + proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ansible-deploy.pub +# then replace the ADMIN_PUBLIC_KEY placeholder in +# ghostnet-litecoin-ansible-bootstrap-hook.sh with the exact line from +# litecoin-ghost.pub -- ONLY the assignment line (line 25), never the +# comparison in the guard below it, e.g.: +# sed -i "25s|@GHOSTNET-CT114-GHOST-PUBLIC-KEY@|$(cat ~/.ssh/id_ed25519_ghostnet_ct114_ghost.pub)|" \ +# ghostnet-litecoin-ansible-bootstrap-hook.sh +# recompute the SHA-256 and update POST_INSTALL_HOOK_SHA256 in +# provision-ct114-litecoin.sh. +``` + +Erledigt am 2026-11-27: alle drei `.pub` liegen in `ansible/files/ssh/`, der +Hook-Platzhalter ist ersetzt und die eingebetteten Keys matchen byte-identisch +mit den Repo-Dateien (geprüft). Aktueller Hook-Pin: +`c8d32465c615f522a7581018a9829f437a6176bb781d68ddac5f7a592cff5e9f` +(Vor-Platzhalter-Wert: `a742377a…a359e3`; Zwischenstand `9e1db709…14d69` war +fehlerhaft, weil ein globales sed auch die Guard-Vergleichszeile traf — Hook +wurde 2026-11-27 entsprechend korrigiert). + +The `ghost` key passphrase is an interactive operator step and is never +written down anywhere (AGENTS.md: operator-run secret steps). + +## Step 1 — install the reviewed hooks on the PVE host (operator, root@pve) + +```bash +install -o root -g root -m 0750 \ + proxmox/shared/scripts/ghostnet-lxc-baseline.sh \ + /usr/local/sbin/ghostnet-lxc-baseline.sh +install -o root -g root -m 0700 \ + proxmox/lxc/ct-114-litecoin-wallet/scripts/ghostnet-litecoin-ansible-bootstrap-hook.sh \ + /usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh +sha256sum /usr/local/sbin/ghostnet-lxc-baseline.sh /usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh +# compare with BASELINE_HOOK_SHA256 / POST_INSTALL_HOOK_SHA256 in +# provision-ct114-litecoin.sh (baseline pin: 111f1b70…381b10, audited for CT 102) +``` + +## Step 2 — create the container (operator, root@pve) + +```bash +install -o root -g root -m 0700 \ + proxmox/lxc/ct-114-litecoin-wallet/scripts/provision-ct114-litecoin.sh \ + /usr/local/sbin/provision-ct114-litecoin.sh +/usr/local/sbin/provision-ct114-litecoin.sh +``` + +The launcher pins the Community Scripts `ProxmoxVE` and `core` repositories +to the revisions audited on 2026-11-25 (`c0c9d93d…`, `d1cec878…`), verifies +the downloaded `ct/debian.sh` by SHA-256 +(`8396340f…86187d`), requires free capacity on `local-lvm`, names every +material CT setting explicitly, rejects an occupied CT ID, and never deletes +or replaces an existing container. After Community Scripts returns it sets +1024 MiB swap and verifies the complete PVE configuration, the hook log and +the guest account state. + +## `ghostnet-litecoin-ansible-bootstrap-hook.sh` + +CT-114-specific Community Scripts post-install hook. It calls the generic +baseline hook (`ghostnet-lxc-baseline.sh`) and then establishes only the +transport and privilege boundary needed by Ansible: + +- it refuses any CT ID other than 114, any helper application other than + Debian, a hostname other than `ltc-node`, or a guest without `10.0.0.61`; +- it creates or validates `ghost-agent` 1000:1000, `ghost` 1001:1001 and + `ansible-deploy` 1002:1002; +- it installs the three role-specific public keys, limited to + `10.0.0.0/24,10.8.0.0/24`; the embedded keys must remain identical to + `../ansible/files/ssh/litecoin-{ghost-agent,ghost,ansible-deploy}.pub`; +- it keeps `ghost-agent` and `ansible-deploy` passwords locked, grants only + `ansible-deploy` reviewed `NOPASSWD: ALL`, and leaves `ghost` on Debian's + password-gated `sudo` policy; +- it disables SSH root/password authentication and TCP forwarding, empties + the temporary root `authorized_keys`, and validates SSH and sudo before + returning success. + +The hook does not install Tor, Litecoin Core, nftables, fail2ban or any +wallet state. Those belong to the Ansible roles +([`../ansible/`](../ansible/README.md)). + +## After creation + +1. Record the SSH host-key fingerprint (`pct exec 114 -- ssh-keygen -lf + /etc/ssh/ssh_host_ed25519_key.pub`) and pin it in all three + `host_vars/litecoin-ct114.yml` files. +2. `pct exec 114 -- passwd ghost` (interactive, operator). +3. If VPN management access is wanted, add `10.0.0.61` to the WireGuard + server-admin target set on CT 105 (GNAI-007) — separate change with its + own tests. +4. Run the Ansible commissioning sequence in [`../ansible/README.md`](../ansible/README.md). diff --git a/proxmox/lxc/ct-114-litecoin-wallet/scripts/ghostnet-litecoin-ansible-bootstrap-hook.sh b/proxmox/lxc/ct-114-litecoin-wallet/scripts/ghostnet-litecoin-ansible-bootstrap-hook.sh new file mode 100755 index 0000000..28bafc5 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/scripts/ghostnet-litecoin-ansible-bootstrap-hook.sh @@ -0,0 +1,277 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail +umask 077 + +readonly EXPECTED_CTID="${GHOSTNET_LITECOIN_CTID:-114}" +readonly EXPECTED_HOSTNAME="${GHOSTNET_LITECOIN_HOSTNAME:-ltc-node}" +readonly EXPECTED_IPV4="${GHOSTNET_LITECOIN_IPV4:-10.0.0.61}" +readonly BASELINE_HOOK="${GHOSTNET_BASELINE_HOOK:-/usr/local/sbin/ghostnet-lxc-baseline.sh}" +readonly SSH_SOURCE_NETWORKS="${GHOSTNET_SSH_SOURCE_NETWORKS:-10.0.0.0/24,10.8.0.0/24}" + +readonly AGENT_USER="ghost-agent" +readonly AGENT_UID="1000" +readonly ADMIN_USER="ghost" +readonly ADMIN_UID="1001" +readonly DEPLOY_USER="ansible-deploy" +readonly DEPLOY_UID="1002" + +# Must stay identical to ../ansible/files/ssh/litecoin-*.pub. +# The ADMIN_PUBLIC_KEY placeholder is replaced with the operator-generated +# ghost public key before the hook is installed on the PVE host +# (GNAI-024 Abschnitt 6 Schritt 0); the hook refuses to run while the +# placeholder is present. +readonly AGENT_PUBLIC_KEY='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMvQR56yADYULrpThnXROAa8GxKWfb+xcnIVLVDVX6Yy ghost-agent@ghostnet-ct114' +readonly ADMIN_PUBLIC_KEY='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGUv4INjWuIzgRL9Pw4TqeHirG72AeA6bowsea6fj2OT ghost@ghostnet-ct114' +readonly DEPLOY_PUBLIC_KEY='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILfqlYvqesJK9bhMmfv6tRp5pXPFDu13xmYbV+58fopV ansible-deploy@ghostnet-ct114' + +log() { + printf '[ghostnet-litecoin-bootstrap] %s\n' "$*" +} + +die() { + printf '[ghostnet-litecoin-bootstrap] ERROR: %s\n' "$*" >&2 + exit 1 +} + +[[ "${EUID}" -eq 0 ]] || die "must run as root on the Proxmox host" +command -v pct >/dev/null 2>&1 || die "pct not found; run this hook on Proxmox" +[[ -x "$BASELINE_HOOK" ]] || die "baseline hook is missing or not executable: ${BASELINE_HOOK}" +[[ "$ADMIN_PUBLIC_KEY" != '@GHOSTNET-CT114-GHOST-PUBLIC-KEY@' ]] || + die "ADMIN_PUBLIC_KEY placeholder not replaced; see scripts/README.md step 0" + +ctid="${CTID:-${1:-}}" +[[ "$ctid" =~ ^[0-9]+$ ]] || die "CTID must be supplied by Community Scripts or as the first argument" +[[ "$ctid" == "$EXPECTED_CTID" ]] || die "refusing CT ${ctid}; expected CT ${EXPECTED_CTID}" + +if [[ -n "${APP:-}" ]]; then + [[ "${APP,,}" == "debian" ]] || die "refusing helper application ${APP}; expected Debian" +fi +if [[ -n "${HN:-}" ]]; then + [[ "$HN" == "$EXPECTED_HOSTNAME" ]] || die "refusing helper hostname ${HN}; expected ${EXPECTED_HOSTNAME}" +fi +if [[ -n "${IP:-}" ]]; then + [[ "$IP" == "$EXPECTED_IPV4" || "$IP" == "$EXPECTED_IPV4/"* ]] || + die "refusing helper IPv4 ${IP}; expected ${EXPECTED_IPV4}" +fi + +pct config "$ctid" >/dev/null 2>&1 || die "CT ${ctid} does not exist" +[[ "$(pct status "$ctid")" == 'status: running' ]] || die "CT ${ctid} is not running" + +log "running reviewed generic LXC baseline for CT ${ctid}" +CTID="$ctid" "$BASELINE_HOOK" "$ctid" + +guest_hostname="$(pct exec "$ctid" -- hostname --short)" +[[ "$guest_hostname" == "$EXPECTED_HOSTNAME" ]] || + die "guest hostname is ${guest_hostname}; expected ${EXPECTED_HOSTNAME}" + +pct exec "$ctid" -- ip -o -4 address show scope global | + grep -Eq "[[:space:]]inet[[:space:]]+${EXPECTED_IPV4//./\\.}/" || + die "guest does not own expected IPv4 ${EXPECTED_IPV4}" + +log "installing deterministic CT 114 access bootstrap" +pct exec "$ctid" -- /bin/bash -s -- \ + "$AGENT_USER" "$AGENT_UID" "$ADMIN_USER" "$ADMIN_UID" \ + "$DEPLOY_USER" "$DEPLOY_UID" "$SSH_SOURCE_NETWORKS" \ + "$AGENT_PUBLIC_KEY" "$ADMIN_PUBLIC_KEY" "$DEPLOY_PUBLIC_KEY" <<'GUEST_SCRIPT' +set -Eeuo pipefail +umask 077 + +agent_user="$1" +agent_uid="$2" +admin_user="$3" +admin_uid="$4" +deploy_user="$5" +deploy_uid="$6" +ssh_source_networks="$7" +agent_public_key="$8" +admin_public_key="$9" +deploy_public_key="${10}" + +log() { + printf '[ghostnet-litecoin-bootstrap/guest] %s\n' "$*" +} + +die() { + printf '[ghostnet-litecoin-bootstrap/guest] ERROR: %s\n' "$*" >&2 + exit 1 +} + +[[ "${EUID}" -eq 0 ]] || die "guest stage is not running as root" + +validate_existing_user() { + local user="$1" + local expected_uid="$2" + local actual_uid="" + local actual_gid="" + + getent passwd "$user" >/dev/null || die "baseline account ${user} is missing" + actual_uid="$(id -u "$user")" + actual_gid="$(id -g "$user")" + [[ "$actual_uid" == "$expected_uid" ]] || + die "${user} has UID ${actual_uid}; expected ${expected_uid}" + [[ "$actual_gid" == "$expected_uid" ]] || + die "${user} has GID ${actual_gid}; expected ${expected_uid}" +} + +validate_free_identity_slot() { + local user="$1" + local expected_uid="$2" + local owner_match="" + + if getent passwd "$user" >/dev/null; then + validate_existing_user "$user" "$expected_uid" + return + fi + + getent passwd "$expected_uid" >/dev/null && + die "UID ${expected_uid} is assigned to $(getent passwd "$expected_uid" | cut -d: -f1)" + getent group "$user" >/dev/null && die "group ${user} exists without its user" + getent group "$expected_uid" >/dev/null && + die "GID ${expected_uid} is assigned to $(getent group "$expected_uid" | cut -d: -f1)" + + owner_match="$(find / -xdev \( -uid "$expected_uid" -o -gid "$expected_uid" \) -print -quit 2>/dev/null || true)" + [[ -z "$owner_match" ]] || + die "UID/GID ${expected_uid} already owns guest path ${owner_match}" +} + +validate_existing_user "$agent_user" "$agent_uid" +validate_existing_user "$admin_user" "$admin_uid" +validate_free_identity_slot "$deploy_user" "$deploy_uid" + +if ! getent passwd "$deploy_user" >/dev/null; then + useradd \ + --uid "$deploy_uid" \ + --create-home \ + --shell /bin/bash \ + --user-group \ + "$deploy_user" + passwd --lock "$deploy_user" >/dev/null + log "created locked ${deploy_user} account with UID/GID ${deploy_uid}" +fi + +for user in "$agent_user" "$admin_user" "$deploy_user"; do + [[ "$(getent passwd "$user" | cut -d: -f6)" == "/home/${user}" ]] || + die "unexpected home directory for ${user}" + [[ "$(getent passwd "$user" | cut -d: -f7)" == "/bin/bash" ]] || + die "unexpected shell for ${user}" + [[ ! -L "/home/${user}" ]] || die "home for ${user} is a symlink" + [[ ! -L "/home/${user}/.ssh" ]] || die ".ssh for ${user} is a symlink" + [[ ! -L "/home/${user}/.ssh/authorized_keys" ]] || + die "authorized_keys for ${user} is a symlink" + install -d -o "$user" -g "$user" -m 700 "/home/${user}/.ssh" +done + +install_authorized_key() { + local user="$1" + local options="$2" + local public_key="$3" + local target="/home/${user}/.ssh/authorized_keys" + + install -o "$user" -g "$user" -m 600 /dev/null "$target" + printf '%s %s\n' "$options" "$public_key" >"$target" + chown "$user:$user" "$target" + chmod 600 "$target" + ssh-keygen -l -f "$target" >/dev/null +} + +install_authorized_key \ + "$agent_user" \ + "restrict,from=\"${ssh_source_networks}\"" \ + "$agent_public_key" +install_authorized_key \ + "$admin_user" \ + "from=\"${ssh_source_networks}\",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc" \ + "$admin_public_key" +install_authorized_key \ + "$deploy_user" \ + "restrict,from=\"${ssh_source_networks}\"" \ + "$deploy_public_key" + +passwd --lock "$agent_user" >/dev/null +passwd --lock "$deploy_user" >/dev/null +usermod -aG sudo "$admin_user" + +agent_groups="$(id -Gn "$agent_user")" +deploy_groups="$(id -Gn "$deploy_user")" +[[ "$agent_groups" == "$agent_user" ]] || + die "${agent_user} has unexpected supplementary groups: ${agent_groups}" +[[ "$deploy_groups" == "$deploy_user" ]] || + die "${deploy_user} has unexpected supplementary groups: ${deploy_groups}" + +sudoers_target="/etc/sudoers.d/90-ghostnet-ansible-deploy" +install -o root -g root -m 440 /dev/null "$sudoers_target" +printf '%s ALL=(root) NOPASSWD: ALL\n' "$deploy_user" >"$sudoers_target" +chmod 440 "$sudoers_target" +visudo -cf "$sudoers_target" >/dev/null + +ssh_dropin="/etc/ssh/sshd_config.d/00-ghostnet-bootstrap.conf" +install -o root -g root -m 600 /dev/null "$ssh_dropin" +cat >"$ssh_dropin" </dev/null 2>&1; then + die "${agent_user} unexpectedly has non-interactive sudo" +fi + +agent_password_state="$(passwd -S "$agent_user" | awk '{print $2}')" +admin_password_state="$(passwd -S "$admin_user" | awk '{print $2}')" +deploy_password_state="$(passwd -S "$deploy_user" | awk '{print $2}')" +[[ "$agent_password_state" == "L" ]] || die "${agent_user} password is not locked" +[[ "$deploy_password_state" == "L" ]] || die "${deploy_user} password is not locked" +[[ "$admin_password_state" == "L" || "$admin_password_state" == "P" ]] || + die "${admin_user} has unsafe password state ${admin_password_state}" + +log "SSH host key: $(ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub)" +log "${agent_user}: $(id "$agent_user") / password ${agent_password_state}" +log "${admin_user}: $(id "$admin_user") / password ${admin_password_state}" +log "${deploy_user}: $(id "$deploy_user") / password ${deploy_password_state}" +log "access bootstrap verified; Ansible may connect after independent host-key validation" +GUEST_SCRIPT + +log "CT ${ctid} access bootstrap completed" +log "operator action: set the ${ADMIN_USER} sudo password interactively with 'pct exec ${ctid} -- passwd ${ADMIN_USER}'" +log "do not store that password in this hook, shell history, Ansible inventory, or Git" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/scripts/provision-ct114-litecoin.sh b/proxmox/lxc/ct-114-litecoin-wallet/scripts/provision-ct114-litecoin.sh new file mode 100755 index 0000000..4b7a517 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/scripts/provision-ct114-litecoin.sh @@ -0,0 +1,212 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail +umask 077 + +readonly CTID='114' +readonly HOSTNAME='ltc-node' +readonly IPV4_CIDR='10.0.0.61/24' +readonly GATEWAY='10.0.0.1' +readonly NAMESERVER='10.0.0.14' +readonly BRIDGE='vmbr0' +readonly TEMPLATE_STORAGE='local' +readonly CONTAINER_STORAGE='local-lvm' +readonly ROOT_DISK_GIB='150' +readonly POST_INSTALL_HOOK='/usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh' +readonly BASELINE_HOOK='/usr/local/sbin/ghostnet-lxc-baseline.sh' + +# Audited together on 2026-11-25. Pin both repositories because debian.sh +# loads its execution engine (core/build.func) from community-scripts/core. +readonly PROXMOXVE_COMMIT='c0c9d93d5db1692167efeee2e019f1519af4e0d2' +readonly CORE_COMMIT='d1cec87881d7de053d86434aaf98eb203170c1b9' +readonly DEBIAN_SCRIPT_SHA256='8396340fb3c91142ddf8356eb80904fad181acd6c6ad2c33b22ed4698c86187d' +readonly BASELINE_HOOK_SHA256='111f1b70e47e3a2f6a1bcce22cb0ec50aacd8fbcff37d87fbcf853a318381b10' +# SHA-256 of the hook AFTER the operator replaced the ADMIN_PUBLIC_KEY +# placeholder (only the assignment line!) with the generated ghost public +# key on 2026-11-27 (scripts/README.md step 0). Earlier values: +# a742377a… (pre-placeholder), 9e1db709… (sed hit the check line too). +readonly POST_INSTALL_HOOK_SHA256='c8d32465c615f522a7581018a9829f437a6176bb781d68ddac5f7a592cff5e9f' + +readonly COMMUNITY_SCRIPTS_URL="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/${PROXMOXVE_COMMIT}" +readonly COMMUNITY_SCRIPTS_CORE_URL="https://raw.githubusercontent.com/community-scripts/core/${CORE_COMMIT}" +readonly DEBIAN_SCRIPT_URL="${COMMUNITY_SCRIPTS_URL}/ct/debian.sh" + +log() { + printf '[ghostnet-ct114-provision] %s\n' "$*" +} + +die() { + printf '[ghostnet-ct114-provision] ERROR: %s\n' "$*" >&2 + exit 1 +} + +require_command() { + command -v "$1" >/dev/null 2>&1 || die "required command not found: $1" +} + +require_file_sha256() { + local expected="$1" + local path="$2" + + [[ -f "$path" ]] || die "required file is missing: ${path}" + printf '%s %s\n' "$expected" "$path" | sha256sum --check --status - || + die "SHA-256 mismatch: ${path}" +} + +storage_is_active() { + local storage="$1" + pvesm status | awk -v storage="$storage" ' + $1 == storage && $3 == "active" { found = 1 } + END { exit(found ? 0 : 1) } + ' +} + +storage_has_free() { + local storage="$1" + local required_gib="$2" + # Note: awk `exit` still runs the END block, so the verdict must be + # decided there via flags (same pattern as storage_is_active). + pvesm status | awk -v storage="$storage" -v required="$required_gib" ' + $1 == storage && $3 == "active" { + avail_kib = $6 + if (avail_kib ~ /^[0-9]+$/) { + found = 1 + ok = (avail_kib / 1048576 >= required) + } + } + END { exit(found && ok ? 0 : 1) } + ' +} + +[[ "${EUID}" -eq 0 ]] || die 'must run as root on the Proxmox VE host' +for command_name in awk curl grep pct pvesm pveversion sha256sum; do + require_command "$command_name" +done + +pveversion >/dev/null 2>&1 || die 'this does not appear to be a Proxmox VE host' +[[ ! -e "/etc/pve/lxc/${CTID}.conf" ]] || + die "CT ${CTID} still exists; this script never replaces or destroys a container" +if pct status "$CTID" >/dev/null 2>&1; then + die "CT ${CTID} is still registered" +fi + +storage_is_active "$TEMPLATE_STORAGE" || + die "template storage ${TEMPLATE_STORAGE} is not active" +storage_is_active "$CONTAINER_STORAGE" || + die "container storage ${CONTAINER_STORAGE} is not active" +# The Litecoin chain needs roughly 100 GB plus growth on top of the thin +# 150 GiB rootfs; require headroom for rootfs plus chain before creating. +# (2026-11-27: local-lvm has ~206 GiB free, so +32 GiB headroom is the gate.) +storage_has_free "$CONTAINER_STORAGE" $((ROOT_DISK_GIB + 32)) || + die "container storage ${CONTAINER_STORAGE} has less than $((ROOT_DISK_GIB + 32)) GiB free" + +[[ -x "$BASELINE_HOOK" ]] || die "baseline hook is not executable: ${BASELINE_HOOK}" +[[ -x "$POST_INSTALL_HOOK" ]] || die "post-install hook is not executable: ${POST_INSTALL_HOOK}" +require_file_sha256 "$BASELINE_HOOK_SHA256" "$BASELINE_HOOK" +require_file_sha256 "$POST_INSTALL_HOOK_SHA256" "$POST_INSTALL_HOOK" + +helper_path="$(mktemp /tmp/ghostnet-debian-helper.XXXXXX.sh)" +cleanup() { + rm -f -- "$helper_path" +} +trap cleanup EXIT + +log "downloading pinned Debian helper ${PROXMOXVE_COMMIT}" +curl \ + --fail \ + --silent \ + --show-error \ + --location \ + --proto '=https' \ + --tlsv1.2 \ + --retry 3 \ + --retry-delay 1 \ + --output "$helper_path" \ + "$DEBIAN_SCRIPT_URL" +chmod 0700 "$helper_path" +require_file_sha256 "$DEBIAN_SCRIPT_SHA256" "$helper_path" + +# These are deliberately explicit even where they currently match upstream +# defaults. This keeps the recorded CT profile stable across future rebuilds. +# No nesting and no keyctl: litecoind runs as a plain systemd service under +# the litecoin user, no Podman is involved. +export COMMUNITY_SCRIPTS_URL COMMUNITY_SCRIPTS_CORE_URL +export mode='generated' +export var_cpu='2' +export var_ram='4096' +export var_disk="$ROOT_DISK_GIB" +export var_ctid="$CTID" +export var_hostname="$HOSTNAME" +export var_os='debian' +export var_version='13' +export var_unprivileged='1' +# No nesting/keyctl: litecoind runs as a plain systemd service, no Podman. +export var_nesting='0' +export var_keyctl='0' +export var_brg="$BRIDGE" +export var_net="$IPV4_CIDR" +export var_gateway="$GATEWAY" +export var_ipv6_method='none' +export var_ns="$NAMESERVER" +export var_timezone='Europe/Berlin' +export var_container_storage="$CONTAINER_STORAGE" +export var_template_storage="$TEMPLATE_STORAGE" +export var_protection='yes' +export var_ssh='no' +export var_tags='container;litecoin;wallet;ansible' +export var_post_install="$POST_INSTALL_HOOK" + +log "creating CT ${CTID} with the pinned Community Scripts Debian helper" +bash "$helper_path" + +pct config "$CTID" >/dev/null 2>&1 || + die "helper returned without creating CT ${CTID}" + +# Community Scripts does not currently expose an LXC swap variable. +pct set "$CTID" --swap 1024 + +config="$(pct config "$CTID")" +grep -qx 'cores: 2' <<<"$config" || die 'unexpected CPU allocation' +grep -qx 'memory: 4096' <<<"$config" || die 'unexpected memory allocation' +grep -qx 'swap: 1024' <<<"$config" || die 'unexpected swap allocation' +grep -qx 'hostname: ltc-node' <<<"$config" || die 'unexpected hostname' +grep -qx 'nameserver: 10.0.0.14' <<<"$config" || die 'unexpected nameserver' +grep -qx 'onboot: 1' <<<"$config" || die 'onboot is not enabled' +grep -qx 'protection: 1' <<<"$config" || die 'container protection is not enabled' +grep -qx 'unprivileged: 1' <<<"$config" || die 'container is not unprivileged' +grep -qx 'timezone: Europe/Berlin' <<<"$config" || die 'unexpected timezone' +grep -Eq '^features: .*nesting=0' <<<"$config" || die 'nesting is not disabled' +grep -Eq '^features: .*keyctl=0' <<<"$config" || die 'keyctl is not disabled' +grep -Eq '^rootfs: local-lvm:.*,size=150G(,|$)' <<<"$config" || + die 'unexpected root filesystem allocation' +net0="$(grep '^net0: ' <<<"$config")" +for expected_net_field in \ + 'name=eth0' \ + 'bridge=vmbr0' \ + 'gw=10.0.0.1' \ + 'ip=10.0.0.61/24' \ + 'type=veth'; do + [[ "$net0" == *"$expected_net_field"* ]] || + die "net0 is missing ${expected_net_field}" +done + +[[ "$(pct status "$CTID")" == 'status: running' ]] || die "CT ${CTID} is not running" +hook_log="/var/log/community-scripts/post-install-${CTID}.log" +[[ -f "$hook_log" ]] || die "post-install hook log is missing: ${hook_log}" +grep -Fq "CT ${CTID} access bootstrap completed" "$hook_log" || + die "post-install hook did not report successful completion; inspect ${hook_log}" + +pct exec "$CTID" -- sh -eu -c ' + test "$(hostname --short)" = ltc-node + test "$(. /etc/os-release; printf %s "$ID")" = debian + test "$(. /etc/os-release; printf %s "$VERSION_ID")" = 13 + test "$(id -u ghost-agent)" = 1000 + test "$(id -u ghost)" = 1001 + test "$(id -u ansible-deploy)" = 1002 + test "$(runuser -u ansible-deploy -- sudo -n id -u)" = 0 + systemctl is-active --quiet ssh.service +' + +log "CT ${CTID} provisioning and access bootstrap verified" +log "review ${hook_log}, record the SSH host-key fingerprint, then set the ghost password interactively" +log "command: pct exec ${CTID} -- passwd ghost" diff --git a/proxmox/lxc/ct-117-fluxer/README.md b/proxmox/lxc/ct-117-fluxer/README.md new file mode 100644 index 0000000..8972989 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/README.md @@ -0,0 +1,16 @@ +# CT 117 Fluxer chat server + +Self-hosted Fluxer instance (AGPL chat + VoIP) for the operator's friend +circle, planned as unprivileged Debian 13 LXC `fluxer` (`10.0.0.62`, +4 cores / 8192 MiB / 64 GiB) in the proven Podman LXC schema, publicly +reachable as `https://fluxer.ghostnet.selfhost.eu` via the CT 103 NPM edge, +with Keycloak (CT 102) OIDC SSO. Plan and feasibility study: +`docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md`. + +- `scripts/` — operator-run (root@pve) fresh-state provisioning of CT 117 +- `ansible/` — self-contained Ansible project (agent/bootstrap/production + inventories, preflight + site playbooks, roles `fluxer_lxc_baseline`, + `fluxer_access`, `fluxer_firewall`, `fluxer_stack`) + +Status 2026-11-27: repository artifacts complete; CT 117 not yet created +(operator step, GNAI-025 Abschnitt 6). diff --git a/proxmox/lxc/ct-117-fluxer/ansible/README.md b/proxmox/lxc/ct-117-fluxer/ansible/README.md new file mode 100644 index 0000000..55a11f8 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/README.md @@ -0,0 +1,65 @@ +# CT 117 Fluxer chat server Ansible project + +This self-contained host project manages the CT 117 Fluxer LXC (`fluxer`, +`10.0.0.62`). It follows the CT 102 Keycloak fresh-rebuild schema and the +CT 100/103 three-inventory convention (`agent`, `bootstrap`, `production`) +and uses the repository-wide pinned control dependency +(`shared/ansible/requirements-control.txt`); all CT 117 inventories, +playbooks, keys and roles remain inside the CT 117 root. + +Create the repository-level control environment once: + +```bash +python3 -m venv .venv +.venv/bin/python -m pip install --upgrade pip +.venv/bin/python -m pip install -r shared/ansible/requirements-control.txt +``` + +Run commands from this directory and always select an inventory explicitly: + +```bash +cd proxmox/lxc/ct-117-fluxer/ansible +../../../../.venv/bin/ansible-playbook \ + --inventory inventories/production/hosts.yml \ + playbooks/preflight.yml \ + --private-key ~/.ssh/id_ed25519_ghostnet_ct117_ansible_deploy +``` + +## Commissioning sequence for the new CT 117 (GNAI-025 Abschnitt 6) + +CT 117 does not exist yet; the LXC is created on the PVE host by the operator +with the reviewed helper in [`../scripts/`](../scripts/), following the +CT 101/114 procedure: + +0. Operator, on the workstation: generate the three CT 117 key pairs + (`ghost` interactively with passphrase; `ghost-agent`/`ansible-deploy` + passphrase-less), copy the `.pub` files into `files/ssh/` (see + `files/ssh/README.md`), add the `ghostnet-ct117-*` SSH aliases to + `~/.ssh/config`. Pin the upstream commit + compose SHA-256 and the image + digests in the inventory `group_vars` (see `fluxer_stack` defaults). +1. Operator, as root@pve: install the reviewed baseline hook + (`proxmox/shared/scripts/ghostnet-lxc-baseline.sh`) to + `/usr/local/sbin/ghostnet-lxc-baseline.sh` and run + `../scripts/provision-ct117-fluxer.sh` with `GHOSTNET_AGENT_UID` / + `GHOSTNET_ADMIN_UID` matching `fluxer_access_*_uid` (1000/1001). +2. Operator: `pct exec 117 -- passwd ghost`; install the agent/ghost public + keys into the (empty, protected) authorized_keys files; pin the SSH host + key fingerprint into all three `host_vars/fluxer-ct117.yml` files. +3. `preflight.yml` on the `agent` inventory (read-only, unprivileged, + `--private-key ~/.ssh/id_ed25519_ghostnet_ct117_agent`) proves identity, + resource gates and the empty state. +4. `site.yml --check --diff` on the `production` inventory previews the + convergence. A real `site.yml` run enforces the declared state and + therefore requires explicit operator authorization; a second run must + report `changed=0`. +5. Keycloak: add the `fluxer` OIDC client via the CT 102 + `keycloak_realm_config` role (see GNAI-025 Abschnitt 4), then enter + issuer/client/secret in the Fluxer admin panel (`/admin`) and disable + open registration (invite-only). +6. NPM: converge `reverse_proxy_fluxer_vhost` on CT 103 for + `fluxer.ghostnet.selfhost.eu` → `10.0.0.62:8080`; add the Pi-hole split-DNS + record `fluxer.ghostnet.selfhost.eu → 10.0.0.10`; FRITZ!Box forwards the + LiveKit media ports to `10.0.0.62` iff voice is enabled. + +The stack is started by `site.yml` only on inventories with +`fluxer_stack_start_allowed: true` (production). diff --git a/proxmox/lxc/ct-117-fluxer/ansible/ansible.cfg b/proxmox/lxc/ct-117-fluxer/ansible/ansible.cfg new file mode 100644 index 0000000..78fafa4 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/ansible.cfg @@ -0,0 +1,17 @@ +[defaults] +home = .ansible +host_key_checking = True +interpreter_python = auto_silent +local_tmp = .ansible/tmp +# module payloads must not live in /tmp: the baseline role masks/stops +# tmp.mount, which would unmount /tmp mid-run (GNAI-025, 2026-11-27). +# ~/.ansible/tmp = home of the connecting user (pre-become tmpdir creation +# must be writable by ansible-deploy/ghost-agent, /root is 0700). +remote_tmp = ~/.ansible/tmp +retry_files_enabled = False +roles_path = roles:../../../../shared/ansible/roles +timeout = 15 + +[ssh_connection] +pipelining = True +ssh_args = -o ControlMaster=auto -o ControlPersist=60s diff --git a/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/README.md b/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/README.md new file mode 100644 index 0000000..236dbf9 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/README.md @@ -0,0 +1,19 @@ +# CT 117 SSH public keys + +Only **public** keys belong in this repository (AGENTS.md: private keys never +enter the repo). Before the first Ansible run, the operator generates the three +CT 117 key pairs on the workstation and copies the `.pub` files here: + +```bash +ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_ghostnet_ct117_agent # no passphrase +ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_ghostnet_ct117_ghost # with passphrase +ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_ghostnet_ct117_ansible_deploy # no passphrase +cp ~/.ssh/id_ed25519_ghostnet_ct117_{agent,ghost,ansible_deploy}.pub \ + proxmox/lxc/ct-117-fluxer/ansible/files/ssh/ +# rename to the expected names: +# fluxer-ghost-agent.pub, fluxer-ghost.pub, fluxer-ansible-deploy.pub +``` + +`fluxer_access` fails with a clear message while any of the three files is +missing. The matching `ghostnet-ct117-*` SSH aliases go into the operator's +`~/.ssh/config` (see GNAI-025 Abschnitt 6). diff --git a/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ansible-deploy.pub b/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ansible-deploy.pub new file mode 100644 index 0000000..486c1fc --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ansible-deploy.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHD8z6qqbugDNBsbp4jlJmC91pXy/dowXIOAovs7gdM6 ansible-deploy@ct117 diff --git a/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ghost-agent.pub b/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ghost-agent.pub new file mode 100644 index 0000000..9bdd948 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ghost-agent.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICWv6gvQ+OYMThgnbulGtMUqF4bweu293sI6D1uY11aq ghost-agent@ct117 diff --git a/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ghost.pub b/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ghost.pub new file mode 100644 index 0000000..00db04e --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-ghost.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEUTH32vjpNzGZ7cjXqEyG16sd1NVVS5FBMkrxC5ARek ghost@ct117 diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/group_vars/fluxer_hosts.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/group_vars/fluxer_hosts.yml new file mode 100644 index 0000000..9bd708f --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/group_vars/fluxer_hosts.yml @@ -0,0 +1,59 @@ +--- +ansible_become_method: sudo +ansible_python_interpreter: /usr/bin/python3 +ansible_ssh_common_args: >- + -o IdentitiesOnly=yes + -o StrictHostKeyChecking=yes + -o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct117 + +fluxer_expected_distribution: Debian +fluxer_expected_distribution_major_version: "13" +fluxer_expected_hostname: fluxer +fluxer_expected_virtualization_type: lxc + +fluxer_firewall_management_ipv4: + - 10.0.0.0/24 + - 10.8.0.0/24 +fluxer_firewall_ssh_port: 22 + +fluxer_access_source_networks: 10.0.0.0/24,10.8.0.0/24 + +fluxer_stack_public_domain: fluxer.ghostnet.selfhost.eu +fluxer_stack_public_scheme: https +fluxer_stack_public_port: 443 +fluxer_stack_app_proxy_port: 8080 +fluxer_stack_livekit_signaling_port: 7880 +fluxer_stack_voice_enabled: true +fluxer_stack_livekit_tcp_port: 7881 +fluxer_stack_livekit_udp_port: 7882 +fluxer_stack_livekit_turn_udp_port: 3478 +fluxer_stack_livekit_rtp_port_range: 50000-50100 + +fluxer_stack_upstream_repo: https://github.com/fluxerapp/fluxer +fluxer_stack_upstream_commit: "3b1eb56713d59181823df284b9646c890d2a3cba" # letzter Commit mit deploy/self-hosting/docker-compose.yml (main 872ed5d hat die Datei nicht mehr — rexctl-eject-Umbau); gepinnt 2026-11-27 +fluxer_stack_compose_path: deploy/self-hosting/docker-compose.yml +fluxer_stack_compose_sha256: "1cb102f9799ba8858a1fee71abdd4111085c997bdeddd5d878c0d8f28c85fe50" # compose @ 3b1eb567, sha256sum via Workstation 2026-11-27 (d5558cd… war die SHA-256 der 404-Seite!) +fluxer_stack_registry: ghcr.io/fluxerapp +fluxer_stack_image_tag: v1 +fluxer_stack_images: + - docker.io/chrislusf/seaweedfs:4.34@sha256:6620371e8af8282056685c652d4637265698c9e2c2d59f9594e6ac333ad6c634 + - docker.io/getmeili/meilisearch:v1.12@sha256:c9fac23131cca4db95173d41cc50fd5639121ee381795528fdd7522d7978a7b8 + - docker.io/library/caddy:2.10-alpine@sha256:4c6e91c6ed0e2fa03efd5b44747b625fec79bc9cd06ac5235a779726618e530d + - docker.io/library/nats:2.14-alpine@sha256:311da47e2f31c26e99c623cd78d486a1e8ab039c49b32652770bb91a4f70512e + - docker.io/library/postgres:16-alpine@sha256:f2f98726820d0342055351c6e9d36e705f5bfffb3dd53ff556325114b08afb6d + - docker.io/livekit/livekit-server:v1.12.0@sha256:b1281e66e35e8f9749ffbcf0fe6ab4d40d1438aa00f36c2ea7e6975e5e261e2e + - docker.io/valkey/valkey:8.1-alpine@sha256:9971099af41c36e887aabdfe22b80c0fe45df949163dfc9cb434febc57cfc3fc + - ghcr.io/fluxerapp/fluxer-admin:v1@sha256:836be5b66ffa3bd83bffb15061b362b4fac34e898352eadf4a554a2f763c9c11 + - ghcr.io/fluxerapp/fluxer-api:v1@sha256:9d5e0b2cac35435d724e8bb2d0999a278219a811c68b16d6ac455a5d16948b8f + - ghcr.io/fluxerapp/fluxer-app-proxy-self-hosted:v1@sha256:30cb19c289a2697dd3d80f50ec43da3caab0674fdee96dd24cee7cfbb0e62370 + - ghcr.io/fluxerapp/fluxer-gateway:v1@sha256:462e332783375c13e0044f10177069822eb0f457f966a982f4aa182d1eae9043 + - ghcr.io/fluxerapp/fluxer-gifs:v1@sha256:a7916918e7b42a69dc06fb70349cde457d6fe7226a54bc52105e5ae6aa972c03 + - ghcr.io/fluxerapp/fluxer-media-proxy:v1@sha256:2ff45bbcff172c29a0de45c51505631aba8bd30287c408335921e39a87f14688 + - ghcr.io/fluxerapp/fluxer-messages:v1@sha256:cbdfd2be58aa654d2e599af02de5c1214f0c2b73855f36edfed096a7f92bcca6 + - ghcr.io/fluxerapp/fluxer-snowflakes:v1@sha256:a75ab098ba71139ed78a8512523dc7449392dc52e1bf1ec3318f05d4d83c4096 + - ghcr.io/fluxerapp/fluxer-static:v1@sha256:bb55869686b23046dbfc7730442e382643dd10b5c34be8fae788f4afc53a8f35 + - ghcr.io/fluxerapp/fluxer-unfurl:v1@sha256:0b6ba1e741925727fb09525de7ba3eedfba8b7d728f05f0ba58cd5794a8bf14f + - ghcr.io/fluxerapp/fluxer-users:v1@sha256:22c44aff82785ee31d3e94823fb2775b9fab0845e04179c681a5893f685f5555 + +fluxer_stack_start_allowed: false +fluxer_stack_production_enabled: false diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/host_vars/fluxer-ct117.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/host_vars/fluxer-ct117.yml new file mode 100644 index 0000000..2b47729 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/host_vars/fluxer-ct117.yml @@ -0,0 +1,10 @@ +--- +fluxer_ctid: 117 +fluxer_expected_ipv4: 10.0.0.62 +# Platzhalter; vor dem ersten Lauf durch den echten Fingerprint ersetzen +# (pct exec 117 -- ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub). +fluxer_expected_ssh_host_key_fingerprint: "SHA256:bL5zdRfuXcspX9gRSuPvLgHzyxJsZo+KsU0jdDqIxrA" # gepinnt 2026-11-27 aus dem Bootstrap-Hook-Log (pct exec 117) +fluxer_expected_processor_vcpus: 4 +fluxer_minimum_memory_mb: 7800 +fluxer_minimum_root_size_bytes: 60000000000 # 64-GiB-LV minus ext4-Overhead (~56 GiB nutzbar) +fluxer_minimum_root_available_bytes: 10000000000 diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/hosts.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/hosts.yml new file mode 100644 index 0000000..c79de58 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/agent/hosts.yml @@ -0,0 +1,8 @@ +--- +all: + children: + fluxer_hosts: + hosts: + fluxer-ct117: + ansible_host: 10.0.0.62 + ansible_user: ghost-agent diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/group_vars/fluxer_hosts.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/group_vars/fluxer_hosts.yml new file mode 100644 index 0000000..9bd708f --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/group_vars/fluxer_hosts.yml @@ -0,0 +1,59 @@ +--- +ansible_become_method: sudo +ansible_python_interpreter: /usr/bin/python3 +ansible_ssh_common_args: >- + -o IdentitiesOnly=yes + -o StrictHostKeyChecking=yes + -o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct117 + +fluxer_expected_distribution: Debian +fluxer_expected_distribution_major_version: "13" +fluxer_expected_hostname: fluxer +fluxer_expected_virtualization_type: lxc + +fluxer_firewall_management_ipv4: + - 10.0.0.0/24 + - 10.8.0.0/24 +fluxer_firewall_ssh_port: 22 + +fluxer_access_source_networks: 10.0.0.0/24,10.8.0.0/24 + +fluxer_stack_public_domain: fluxer.ghostnet.selfhost.eu +fluxer_stack_public_scheme: https +fluxer_stack_public_port: 443 +fluxer_stack_app_proxy_port: 8080 +fluxer_stack_livekit_signaling_port: 7880 +fluxer_stack_voice_enabled: true +fluxer_stack_livekit_tcp_port: 7881 +fluxer_stack_livekit_udp_port: 7882 +fluxer_stack_livekit_turn_udp_port: 3478 +fluxer_stack_livekit_rtp_port_range: 50000-50100 + +fluxer_stack_upstream_repo: https://github.com/fluxerapp/fluxer +fluxer_stack_upstream_commit: "3b1eb56713d59181823df284b9646c890d2a3cba" # letzter Commit mit deploy/self-hosting/docker-compose.yml (main 872ed5d hat die Datei nicht mehr — rexctl-eject-Umbau); gepinnt 2026-11-27 +fluxer_stack_compose_path: deploy/self-hosting/docker-compose.yml +fluxer_stack_compose_sha256: "1cb102f9799ba8858a1fee71abdd4111085c997bdeddd5d878c0d8f28c85fe50" # compose @ 3b1eb567, sha256sum via Workstation 2026-11-27 (d5558cd… war die SHA-256 der 404-Seite!) +fluxer_stack_registry: ghcr.io/fluxerapp +fluxer_stack_image_tag: v1 +fluxer_stack_images: + - docker.io/chrislusf/seaweedfs:4.34@sha256:6620371e8af8282056685c652d4637265698c9e2c2d59f9594e6ac333ad6c634 + - docker.io/getmeili/meilisearch:v1.12@sha256:c9fac23131cca4db95173d41cc50fd5639121ee381795528fdd7522d7978a7b8 + - docker.io/library/caddy:2.10-alpine@sha256:4c6e91c6ed0e2fa03efd5b44747b625fec79bc9cd06ac5235a779726618e530d + - docker.io/library/nats:2.14-alpine@sha256:311da47e2f31c26e99c623cd78d486a1e8ab039c49b32652770bb91a4f70512e + - docker.io/library/postgres:16-alpine@sha256:f2f98726820d0342055351c6e9d36e705f5bfffb3dd53ff556325114b08afb6d + - docker.io/livekit/livekit-server:v1.12.0@sha256:b1281e66e35e8f9749ffbcf0fe6ab4d40d1438aa00f36c2ea7e6975e5e261e2e + - docker.io/valkey/valkey:8.1-alpine@sha256:9971099af41c36e887aabdfe22b80c0fe45df949163dfc9cb434febc57cfc3fc + - ghcr.io/fluxerapp/fluxer-admin:v1@sha256:836be5b66ffa3bd83bffb15061b362b4fac34e898352eadf4a554a2f763c9c11 + - ghcr.io/fluxerapp/fluxer-api:v1@sha256:9d5e0b2cac35435d724e8bb2d0999a278219a811c68b16d6ac455a5d16948b8f + - ghcr.io/fluxerapp/fluxer-app-proxy-self-hosted:v1@sha256:30cb19c289a2697dd3d80f50ec43da3caab0674fdee96dd24cee7cfbb0e62370 + - ghcr.io/fluxerapp/fluxer-gateway:v1@sha256:462e332783375c13e0044f10177069822eb0f457f966a982f4aa182d1eae9043 + - ghcr.io/fluxerapp/fluxer-gifs:v1@sha256:a7916918e7b42a69dc06fb70349cde457d6fe7226a54bc52105e5ae6aa972c03 + - ghcr.io/fluxerapp/fluxer-media-proxy:v1@sha256:2ff45bbcff172c29a0de45c51505631aba8bd30287c408335921e39a87f14688 + - ghcr.io/fluxerapp/fluxer-messages:v1@sha256:cbdfd2be58aa654d2e599af02de5c1214f0c2b73855f36edfed096a7f92bcca6 + - ghcr.io/fluxerapp/fluxer-snowflakes:v1@sha256:a75ab098ba71139ed78a8512523dc7449392dc52e1bf1ec3318f05d4d83c4096 + - ghcr.io/fluxerapp/fluxer-static:v1@sha256:bb55869686b23046dbfc7730442e382643dd10b5c34be8fae788f4afc53a8f35 + - ghcr.io/fluxerapp/fluxer-unfurl:v1@sha256:0b6ba1e741925727fb09525de7ba3eedfba8b7d728f05f0ba58cd5794a8bf14f + - ghcr.io/fluxerapp/fluxer-users:v1@sha256:22c44aff82785ee31d3e94823fb2775b9fab0845e04179c681a5893f685f5555 + +fluxer_stack_start_allowed: false +fluxer_stack_production_enabled: false diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/host_vars/fluxer-ct117.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/host_vars/fluxer-ct117.yml new file mode 100644 index 0000000..5fb6f34 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/host_vars/fluxer-ct117.yml @@ -0,0 +1,8 @@ +--- +fluxer_ctid: 117 +fluxer_expected_ipv4: 10.0.0.62 +fluxer_expected_ssh_host_key_fingerprint: "SHA256:bL5zdRfuXcspX9gRSuPvLgHzyxJsZo+KsU0jdDqIxrA" # gepinnt 2026-11-27 aus dem Bootstrap-Hook-Log (pct exec 117) +fluxer_expected_processor_vcpus: 4 +fluxer_minimum_memory_mb: 7800 +fluxer_minimum_root_size_bytes: 60000000000 # 64-GiB-LV minus ext4-Overhead (~56 GiB nutzbar) +fluxer_minimum_root_available_bytes: 10000000000 diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/hosts.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/hosts.yml new file mode 100644 index 0000000..1e626e4 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/bootstrap/hosts.yml @@ -0,0 +1,8 @@ +--- +all: + children: + fluxer_hosts: + hosts: + fluxer-ct117: + ansible_host: 10.0.0.62 + ansible_user: ghost diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/group_vars/fluxer_hosts.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/group_vars/fluxer_hosts.yml new file mode 100644 index 0000000..10c2f68 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/group_vars/fluxer_hosts.yml @@ -0,0 +1,69 @@ +--- +ansible_become_method: sudo +ansible_python_interpreter: /usr/bin/python3 +ansible_ssh_common_args: >- + -o IdentitiesOnly=yes + -o StrictHostKeyChecking=yes + -o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct117 + +fluxer_expected_distribution: Debian +fluxer_expected_distribution_major_version: "13" +fluxer_expected_hostname: fluxer +fluxer_expected_virtualization_type: lxc + +fluxer_firewall_management_ipv4: + - 10.0.0.0/24 + - 10.8.0.0/24 +fluxer_firewall_ssh_port: 22 + +fluxer_access_source_networks: 10.0.0.0/24,10.8.0.0/24 + +# Public identity of the instance (GNAI-025 Abschnitt 3). NPM on CT 103 +# terminates TLS for this domain and proxies to 10.0.0.62:8080 (app-proxy). +fluxer_stack_public_domain: fluxer.ghostnet.selfhost.eu +fluxer_stack_public_scheme: https +fluxer_stack_public_port: 443 +fluxer_stack_app_proxy_port: 8080 +fluxer_stack_livekit_signaling_port: 7880 +# Voice/video media ports published on the CT IP and forwarded by the +# FRITZ!Box (GNAI-025 Befund e); set fluxer_stack_voice_enabled=false to +# run text-only without any WAN-exposed media ports. +fluxer_stack_voice_enabled: true +fluxer_stack_livekit_tcp_port: 7881 +fluxer_stack_livekit_udp_port: 7882 +fluxer_stack_livekit_turn_udp_port: 3478 +fluxer_stack_livekit_rtp_port_range: 50000-50100 + +# Pin the upstream compose source (GNAI-025 Abschnitt 5, Befund c): +# operator downloads deploy/self-hosting/docker-compose.yml at the pinned +# commit, records its SHA-256 in fluxer_stack_compose_sha256 and pins every +# image by digest in fluxer_stack_images after the first pull (CT 102/103 +# convention). Both placeholders must be replaced before the first run. +fluxer_stack_upstream_repo: https://github.com/fluxerapp/fluxer +fluxer_stack_upstream_commit: "3b1eb56713d59181823df284b9646c890d2a3cba" # letzter Commit mit deploy/self-hosting/docker-compose.yml (main 872ed5d hat die Datei nicht mehr — rexctl-eject-Umbau); gepinnt 2026-11-27 +fluxer_stack_compose_path: deploy/self-hosting/docker-compose.yml +fluxer_stack_compose_sha256: "1cb102f9799ba8858a1fee71abdd4111085c997bdeddd5d878c0d8f28c85fe50" # compose @ 3b1eb567, sha256sum via Workstation 2026-11-27 (d5558cd… war die SHA-256 der 404-Seite!) +fluxer_stack_registry: ghcr.io/fluxerapp +fluxer_stack_image_tag: v1 +fluxer_stack_images: + - docker.io/chrislusf/seaweedfs:4.34@sha256:6620371e8af8282056685c652d4637265698c9e2c2d59f9594e6ac333ad6c634 + - docker.io/getmeili/meilisearch:v1.12@sha256:c9fac23131cca4db95173d41cc50fd5639121ee381795528fdd7522d7978a7b8 + - docker.io/library/caddy:2.10-alpine@sha256:4c6e91c6ed0e2fa03efd5b44747b625fec79bc9cd06ac5235a779726618e530d + - docker.io/library/nats:2.14-alpine@sha256:311da47e2f31c26e99c623cd78d486a1e8ab039c49b32652770bb91a4f70512e + - docker.io/library/postgres:16-alpine@sha256:f2f98726820d0342055351c6e9d36e705f5bfffb3dd53ff556325114b08afb6d + - docker.io/livekit/livekit-server:v1.12.0@sha256:b1281e66e35e8f9749ffbcf0fe6ab4d40d1438aa00f36c2ea7e6975e5e261e2e + - docker.io/valkey/valkey:8.1-alpine@sha256:9971099af41c36e887aabdfe22b80c0fe45df949163dfc9cb434febc57cfc3fc + - ghcr.io/fluxerapp/fluxer-admin:v1@sha256:836be5b66ffa3bd83bffb15061b362b4fac34e898352eadf4a554a2f763c9c11 + - ghcr.io/fluxerapp/fluxer-api:v1@sha256:9d5e0b2cac35435d724e8bb2d0999a278219a811c68b16d6ac455a5d16948b8f + - ghcr.io/fluxerapp/fluxer-app-proxy-self-hosted:v1@sha256:30cb19c289a2697dd3d80f50ec43da3caab0674fdee96dd24cee7cfbb0e62370 + - ghcr.io/fluxerapp/fluxer-gateway:v1@sha256:462e332783375c13e0044f10177069822eb0f457f966a982f4aa182d1eae9043 + - ghcr.io/fluxerapp/fluxer-gifs:v1@sha256:a7916918e7b42a69dc06fb70349cde457d6fe7226a54bc52105e5ae6aa972c03 + - ghcr.io/fluxerapp/fluxer-media-proxy:v1@sha256:2ff45bbcff172c29a0de45c51505631aba8bd30287c408335921e39a87f14688 + - ghcr.io/fluxerapp/fluxer-messages:v1@sha256:cbdfd2be58aa654d2e599af02de5c1214f0c2b73855f36edfed096a7f92bcca6 + - ghcr.io/fluxerapp/fluxer-snowflakes:v1@sha256:a75ab098ba71139ed78a8512523dc7449392dc52e1bf1ec3318f05d4d83c4096 + - ghcr.io/fluxerapp/fluxer-static:v1@sha256:bb55869686b23046dbfc7730442e382643dd10b5c34be8fae788f4afc53a8f35 + - ghcr.io/fluxerapp/fluxer-unfurl:v1@sha256:0b6ba1e741925727fb09525de7ba3eedfba8b7d728f05f0ba58cd5794a8bf14f + - ghcr.io/fluxerapp/fluxer-users:v1@sha256:22c44aff82785ee31d3e94823fb2775b9fab0845e04179c681a5893f685f5555 + +fluxer_stack_start_allowed: true +fluxer_stack_production_enabled: true diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/host_vars/fluxer-ct117.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/host_vars/fluxer-ct117.yml new file mode 100644 index 0000000..260a121 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/host_vars/fluxer-ct117.yml @@ -0,0 +1,11 @@ +--- +fluxer_ctid: 117 +fluxer_expected_ipv4: 10.0.0.62 +# Wird nach dem ersten Boot des CT vom Operator aus der Proxmox-Konsole +# uebernommen (pct exec 117 -- ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub) +# und hier gepinnt. Der Platzhalter muss vor dem ersten Lauf ersetzt werden. +fluxer_expected_ssh_host_key_fingerprint: "SHA256:bL5zdRfuXcspX9gRSuPvLgHzyxJsZo+KsU0jdDqIxrA" # gepinnt 2026-11-27 aus dem Bootstrap-Hook-Log (pct exec 117): gepinnt nach erstem Boot (GNAI-025 Abschnitt 6) +fluxer_expected_processor_vcpus: 4 +fluxer_minimum_memory_mb: 7800 +fluxer_minimum_root_size_bytes: 60000000000 # 64-GiB-LV minus ext4-Overhead (~56 GiB nutzbar) +fluxer_minimum_root_available_bytes: 10000000000 diff --git a/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/hosts.yml b/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/hosts.yml new file mode 100644 index 0000000..f098f87 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/inventories/production/hosts.yml @@ -0,0 +1,8 @@ +--- +all: + children: + fluxer_hosts: + hosts: + fluxer-ct117: + ansible_host: 10.0.0.62 + ansible_user: ansible-deploy diff --git a/proxmox/lxc/ct-117-fluxer/ansible/playbooks/preflight.yml b/proxmox/lxc/ct-117-fluxer/ansible/playbooks/preflight.yml new file mode 100644 index 0000000..8d7f44e --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/playbooks/preflight.yml @@ -0,0 +1,177 @@ +--- +- name: Read-only verification of the fresh CT 117 Fluxer LXC + hosts: fluxer_hosts + become: false + gather_facts: true + gather_subset: + - min + - hardware + - network + - virtual + + tasks: + - name: Verify required inventory safeguards are defined + ansible.builtin.assert: + that: + - fluxer_ctid is defined + - fluxer_expected_hostname is defined + - fluxer_expected_ipv4 is defined + - fluxer_expected_ssh_host_key_fingerprint is defined + - fluxer_expected_distribution is defined + - fluxer_expected_distribution_major_version is defined + - fluxer_expected_virtualization_type is defined + - fluxer_minimum_memory_mb is defined + - fluxer_minimum_root_size_bytes is defined + fail_msg: >- + The selected inventory lacks mandatory CT 117 identity safeguards. + Stop before running any configuration playbook. + + - name: Verify the expected guest identity + ansible.builtin.assert: + that: + - inventory_hostname == "fluxer-ct117" + - fluxer_ctid | int == 117 + - ansible_facts["hostname"] == fluxer_expected_hostname + - ansible_facts["distribution"] == fluxer_expected_distribution + - >- + ansible_facts["distribution_major_version"] == + fluxer_expected_distribution_major_version + - >- + ansible_facts["default_ipv4"]["address"] == + fluxer_expected_ipv4 + - >- + ansible_facts["virtualization_type"] == + fluxer_expected_virtualization_type + - ansible_facts["virtualization_role"] == "guest" + - ansible_facts["service_mgr"] == "systemd" + - ansible_facts["python"]["version"]["major"] | int >= 3 + fail_msg: >- + The connected machine is not the expected CT 117 Fluxer LXC. + Stop before using any privileged playbook. + success_msg: The expected Debian 13 CT 117 Fluxer LXC is connected. + + - name: Verify the pinned SSH host key fingerprint + ansible.builtin.assert: + that: + - fluxer_expected_ssh_host_key_fingerprint is + match('^SHA256:[A-Za-z0-9+/]{43}$') + - fluxer_expected_ssh_host_key_fingerprint is not + match('^SHA256:P+$') + fail_msg: >- + fluxer_expected_ssh_host_key_fingerprint still contains the + PENDING placeholder. Pin the real fingerprint from the Proxmox + console after the first boot (GNAI-025 Abschnitt 6). + + - name: Read the unprivileged SSH identity + ansible.builtin.command: + argv: + - /usr/bin/id + - -un + check_mode: false + changed_when: false + register: fluxer_preflight_ssh_identity + + - name: Verify the agent account was used on the agent inventory + ansible.builtin.assert: + that: + - fluxer_preflight_ssh_identity.stdout == "ghost-agent" + fail_msg: >- + The agent inventory must connect through the unprivileged + ghost-agent account. + when: ansible_user is defined and ansible_user == "ghost-agent" + + - name: Read failed systemd units + ansible.builtin.command: + argv: + - /usr/bin/systemctl + - --failed + - --no-legend + - --plain + check_mode: false + changed_when: false + register: fluxer_preflight_failed_units + + - name: Read the listening TCP ports + ansible.builtin.command: + argv: + - /usr/bin/ss + - -H + - -lnt + check_mode: false + changed_when: false + register: fluxer_preflight_listeners + + - name: Read the effective processor count + ansible.builtin.command: + argv: + - /usr/bin/nproc + check_mode: false + changed_when: false + register: fluxer_preflight_nproc + + - name: Read root filesystem capacity + ansible.builtin.command: + argv: + - /usr/bin/findmnt + - --bytes + - --noheadings + - --output + - SIZE,AVAIL + - --target + - / + check_mode: false + changed_when: false + register: fluxer_preflight_root_capacity + + - name: Check that no Fluxer installation exists yet + ansible.builtin.stat: + path: /opt/fluxer + register: fluxer_preflight_opt_dir + + - name: Verify the fresh-LXC commissioning gates + ansible.builtin.assert: + that: + - >- + fluxer_preflight_nproc.stdout | int == + fluxer_expected_processor_vcpus | int + - >- + ansible_facts["memtotal_mb"] | int >= + fluxer_minimum_memory_mb | int + - >- + fluxer_preflight_root_capacity.stdout.split()[0] | int >= + fluxer_minimum_root_size_bytes | int + - >- + fluxer_preflight_root_capacity.stdout.split()[1] | int >= + fluxer_minimum_root_available_bytes | int + - fluxer_preflight_failed_units.stdout | trim == "" + - >- + fluxer_preflight_listeners.stdout is search('\\b22\\b') or + fluxer_preflight_listeners.stdout | trim == "" + - not fluxer_preflight_opt_dir.stat.exists + fail_msg: >- + The target is not the expected healthy, empty CT 117. Stop before + creating configuration, services or containers. + success_msg: >- + CT 117 is healthy, empty and ready for declarative configuration. + + - name: Report the verified Fluxer commissioning baseline + ansible.builtin.debug: + msg: + inventory_host: "{{ inventory_hostname }}" + ctid: "{{ fluxer_ctid }}" + hostname: "{{ ansible_facts['hostname'] }}" + operating_system: >- + {{ ansible_facts['distribution'] }} + {{ ansible_facts['distribution_version'] }} + default_ipv4: "{{ ansible_facts['default_ipv4']['address'] }}" + virtualization: >- + {{ ansible_facts['virtualization_type'] }} + {{ ansible_facts['virtualization_role'] }} + effective_processor_count: "{{ fluxer_preflight_nproc.stdout }}" + memory_mib: "{{ ansible_facts['memtotal_mb'] }}" + root_size_bytes: >- + {{ fluxer_preflight_root_capacity.stdout.split()[0] }} + root_available_bytes: >- + {{ fluxer_preflight_root_capacity.stdout.split()[1] }} + trusted_ssh_fingerprint: >- + {{ fluxer_expected_ssh_host_key_fingerprint }} diff --git a/proxmox/lxc/ct-117-fluxer/ansible/playbooks/site.yml b/proxmox/lxc/ct-117-fluxer/ansible/playbooks/site.yml new file mode 100644 index 0000000..68add4b --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/playbooks/site.yml @@ -0,0 +1,27 @@ +--- +- name: Configure the CT 117 Fluxer LXC foundation + hosts: fluxer_hosts + become: true + gather_facts: true + gather_subset: + - min + - hardware + - network + - virtual + + roles: + - role: fluxer_lxc_baseline + vars: + fluxer_lxc_baseline_expected_hostname: >- + {{ fluxer_expected_hostname }} + fluxer_lxc_baseline_expected_distribution: >- + {{ fluxer_expected_distribution }} + fluxer_lxc_baseline_expected_distribution_major_version: >- + {{ fluxer_expected_distribution_major_version }} + fluxer_lxc_baseline_expected_ipv4: "{{ fluxer_expected_ipv4 }}" + fluxer_lxc_baseline_expected_virtualization_type: >- + {{ fluxer_expected_virtualization_type }} + - role: fluxer_access + - role: podman_runtime + - role: fluxer_firewall + - role: fluxer_stack diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/README.md b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/README.md new file mode 100644 index 0000000..97a3d9e --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/README.md @@ -0,0 +1,11 @@ +# fluxer_access + +GNAI-011 access model for CT 117, identical in structure to the CT 102/114 +`*_access` roles: the three fixed-UID accounts `ghost-agent` (1000, read-only +wrapper), `ghost` (1001, password-gated sudo) and `ansible-deploy` (1002, +NOPASSWD), source-restricted authorized keys from `files/ssh/`, locked +passwords, hardened sshd drop-in (no root, no password, no forwarding) and +no root authorized keys. + +The read-only wrapper whitelists inspection commands only (`podman ps/logs`, +`systemctl status`, `journalctl`, …) — see `defaults/main.yml`. diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/defaults/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/defaults/main.yml new file mode 100644 index 0000000..d6fee45 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/defaults/main.yml @@ -0,0 +1,42 @@ +--- +fluxer_access_source_networks: 10.0.0.0/24,10.8.0.0/24 +fluxer_access_public_key_root: "{{ playbook_dir }}/../files/ssh" + +fluxer_access_agent_user: ghost-agent +fluxer_access_agent_uid: 1000 +fluxer_access_agent_public_key_file: >- + {{ fluxer_access_public_key_root }}/fluxer-ghost-agent.pub + +fluxer_access_admin_user: ghost +fluxer_access_admin_uid: 1001 +fluxer_access_admin_public_key_file: >- + {{ fluxer_access_public_key_root }}/fluxer-ghost.pub + +fluxer_access_deploy_user: ansible-deploy +fluxer_access_deploy_uid: 1002 +fluxer_access_deploy_public_key_file: >- + {{ fluxer_access_public_key_root }}/fluxer-ansible-deploy.pub + +fluxer_access_ssh_dropin: /etc/ssh/sshd_config.d/99-ghostnet-fluxer.conf +fluxer_access_sudoers_file: /etc/sudoers.d/90-ghostnet-ansible-deploy +fluxer_access_readonly_sudoers_file: /etc/sudoers.d/91-ghostnet-fluxer-readonly +fluxer_access_readonly_wrapper: /usr/local/bin/fluxer-readonly + +# Read-only inspection commands the agent account may run via the wrapper. +# Changing the stack is deliberately not in this list; it stays an explicit +# `sudo podman ...` action by ghost/ansible-deploy (GNAI-025 Abschnitt 7). +fluxer_access_readonly_commands: + - podman ps + - podman ps --format json + - podman inspect + - podman logs + - podman healthcheck + - systemctl status + - systemctl is-active + - systemctl is-enabled + - systemctl list-units --failed + - journalctl + - ss -lntup + - df -h + - free -m + - nft list table inet ghostnet_filter diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/handlers/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/handlers/main.yml new file mode 100644 index 0000000..f67d8e5 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Restart the classic SSH service + ansible.builtin.systemd_service: + name: ssh.service + state: restarted diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/tasks/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/tasks/main.yml new file mode 100644 index 0000000..15f4dea --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/tasks/main.yml @@ -0,0 +1,229 @@ +--- +- name: Require all three role-specific public keys in files/ssh (control node) + ansible.builtin.stat: + path: "{{ item }}" + delegate_to: localhost + become: false + loop: + - "{{ fluxer_access_agent_public_key_file }}" + - "{{ fluxer_access_admin_public_key_file }}" + - "{{ fluxer_access_deploy_public_key_file }}" + register: fluxer_access_public_keys + +- name: Fail with a clear message when a public key is missing + ansible.builtin.fail: + msg: >- + Missing public key {{ item.item }}. The operator generates the CT 117 + key pairs (the ghost key interactively with passphrase) and copies the + .pub files into ansible/files/ssh/ before converging (GNAI-025 + Abschnitt 6, Schritt 0). + when: not item.stat.exists + loop: "{{ fluxer_access_public_keys.results }}" + loop_control: + label: "{{ item.item }}" + +- name: Validate the public key files are real OpenSSH keys (control node) + ansible.builtin.command: + argv: + - /usr/bin/ssh-keygen + - -l + - -f + - "{{ item }}" + delegate_to: localhost + become: false + check_mode: false + changed_when: false + loop: + - "{{ fluxer_access_agent_public_key_file }}" + - "{{ fluxer_access_admin_public_key_file }}" + - "{{ fluxer_access_deploy_public_key_file }}" + loop_control: + label: "{{ item.item }}" + +- name: Create fixed primary groups for the Fluxer access accounts + ansible.builtin.group: + name: "{{ item.name }}" + gid: "{{ item.uid }}" + state: present + loop: + - name: "{{ fluxer_access_agent_user }}" + uid: "{{ fluxer_access_agent_uid }}" + - name: "{{ fluxer_access_admin_user }}" + uid: "{{ fluxer_access_admin_uid }}" + - name: "{{ fluxer_access_deploy_user }}" + uid: "{{ fluxer_access_deploy_uid }}" + loop_control: + label: "{{ item.name }}" + +- name: Create fixed Fluxer access accounts + ansible.builtin.user: + name: "{{ item.name }}" + uid: "{{ item.uid }}" + group: "{{ item.name }}" + home: "/home/{{ item.name }}" + shell: /bin/bash + create_home: true + state: present + loop: + - name: "{{ fluxer_access_agent_user }}" + uid: "{{ fluxer_access_agent_uid }}" + - name: "{{ fluxer_access_admin_user }}" + uid: "{{ fluxer_access_admin_uid }}" + - name: "{{ fluxer_access_deploy_user }}" + uid: "{{ fluxer_access_deploy_uid }}" + loop_control: + label: "{{ item.name }}" + +- name: Keep the read-only agent outside supplementary groups + ansible.builtin.user: + name: "{{ fluxer_access_agent_user }}" + groups: "" + append: false + password_lock: true + +- name: Keep the deployment account outside supplementary groups + ansible.builtin.user: + name: "{{ fluxer_access_deploy_user }}" + groups: "" + append: false + password_lock: true + +- name: Grant password-gated sudo membership to the administrator + ansible.builtin.user: + name: "{{ fluxer_access_admin_user }}" + groups: + - sudo + append: true + +- name: Create protected SSH directories + ansible.builtin.file: + path: "/home/{{ item }}/.ssh" + state: directory + owner: "{{ item }}" + group: "{{ item }}" + mode: "0700" + loop: + - "{{ fluxer_access_agent_user }}" + - "{{ fluxer_access_admin_user }}" + - "{{ fluxer_access_deploy_user }}" + +- name: Install the restricted read-only agent key + ansible.builtin.copy: + content: | + restrict,from="{{ fluxer_access_source_networks }}" {{ lookup('ansible.builtin.file', fluxer_access_agent_public_key_file) }} + dest: "/home/{{ fluxer_access_agent_user }}/.ssh/authorized_keys" + owner: "{{ fluxer_access_agent_user }}" + group: "{{ fluxer_access_agent_user }}" + mode: "0600" + +- name: Install the restricted personal administrator key + ansible.builtin.copy: + content: | + from="{{ fluxer_access_source_networks }}",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc {{ lookup('ansible.builtin.file', fluxer_access_admin_public_key_file) }} + dest: "/home/{{ fluxer_access_admin_user }}/.ssh/authorized_keys" + owner: "{{ fluxer_access_admin_user }}" + group: "{{ fluxer_access_admin_user }}" + mode: "0600" + +- name: Install the restricted deployment key + ansible.builtin.copy: + content: | + restrict,from="{{ fluxer_access_source_networks }}" {{ lookup('ansible.builtin.file', fluxer_access_deploy_public_key_file) }} + dest: "/home/{{ fluxer_access_deploy_user }}/.ssh/authorized_keys" + owner: "{{ fluxer_access_deploy_user }}" + group: "{{ fluxer_access_deploy_user }}" + mode: "0600" + +- name: Install validated deployment sudo policy + ansible.builtin.copy: + content: | + {{ fluxer_access_deploy_user }} ALL=(root) NOPASSWD: ALL + dest: "{{ fluxer_access_sudoers_file }}" + owner: root + group: root + mode: "0440" + validate: /usr/sbin/visudo -cf %s + +- name: Install the read-only wrapper for the agent account + ansible.builtin.template: + src: fluxer-readonly.sh.j2 + dest: "{{ fluxer_access_readonly_wrapper }}" + owner: root + group: root + mode: "0750" + validate: /bin/bash -n %s + +- name: Install validated read-only sudo policy for the agent account + ansible.builtin.copy: + content: | + {{ fluxer_access_agent_user }} ALL=(root) NOPASSWD: {{ fluxer_access_readonly_wrapper }} + dest: "{{ fluxer_access_readonly_sudoers_file }}" + owner: root + group: root + mode: "0440" + validate: /usr/sbin/visudo -cf %s + +- name: Ensure root has no SSH authorization material + ansible.builtin.file: + path: /root/.ssh + state: directory + owner: root + group: root + mode: "0700" + +- name: Keep the root authorized keys file empty + ansible.builtin.copy: + content: "" + dest: /root/.ssh/authorized_keys + owner: root + group: root + mode: "0600" + +- name: Install the hardened SSH policy + ansible.builtin.template: + src: sshd.conf.j2 + dest: "{{ fluxer_access_ssh_dropin }}" + owner: root + group: root + mode: "0600" + validate: /usr/sbin/sshd -t -f %s + notify: Restart the classic SSH service + +- name: Disable SSH socket activation + ansible.builtin.systemd_service: + name: ssh.socket + enabled: false + state: stopped + +- name: Enable the classic SSH service + ansible.builtin.systemd_service: + name: ssh.service + enabled: true + state: started + +- name: Read account password states + ansible.builtin.command: + argv: + - /usr/bin/passwd + - -S + - "{{ item }}" + check_mode: false + changed_when: false + register: fluxer_access_password_states + loop: + - "{{ fluxer_access_agent_user }}" + - "{{ fluxer_access_admin_user }}" + - "{{ fluxer_access_deploy_user }}" + loop_control: + label: "{{ item }}" + +- name: Verify the locked password states + ansible.builtin.assert: + that: + - item.stdout.split()[1] in ["L", "P"] + fail_msg: >- + Account {{ item.item }} has unsafe password state + {{ item.stdout.split()[1] }}. + loop: "{{ fluxer_access_password_states.results }}" + loop_control: + label: "{{ item.item }}" diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/templates/fluxer-readonly.sh.j2 b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/templates/fluxer-readonly.sh.j2 new file mode 100644 index 0000000..37d0e94 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/templates/fluxer-readonly.sh.j2 @@ -0,0 +1,28 @@ +#!/bin/bash +# Managed by Ansible role fluxer_access. +# Read-only wrapper for the ghost-agent account (GNAI-011): only whitelisted +# inspection commands run as root; everything else is refused. +set -Eeuo pipefail + +allowed=( +{% for command in fluxer_access_readonly_commands %} + "{{ command }}" +{% endfor %} +) + +if [[ $# -eq 0 ]]; then + echo "usage: fluxer-readonly [args...]" >&2 + echo "allowed commands:" >&2 + printf ' %s\n' "${allowed[@]}" >&2 + exit 1 +fi + +first="$*" +for candidate in "${allowed[@]}"; do + if [[ "$first" == "$candidate" || "$first" == "$candidate "* ]]; then + exec "$@" + fi +done + +echo "fluxer-readonly: command not allowed: $*" >&2 +exit 1 diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/templates/sshd.conf.j2 b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/templates/sshd.conf.j2 new file mode 100644 index 0000000..7e95a0e --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_access/templates/sshd.conf.j2 @@ -0,0 +1,18 @@ +# Managed by Ansible role fluxer_access. +# GNAI-011 SSH baseline. TCP forwarding stays disabled on purpose: the +# Fluxer stack is reached via NPM (CT 103) and the read-only wrapper, never +# via an SSH tunnel. +PermitRootLogin no +PasswordAuthentication no +KbdInteractiveAuthentication no +PubkeyAuthentication yes +AllowUsers {{ fluxer_access_agent_user }} {{ fluxer_access_admin_user }} {{ fluxer_access_deploy_user }} +X11Forwarding no +AllowAgentForwarding no +AllowTcpForwarding no +AllowStreamLocalForwarding no +DisableForwarding yes +PermitTunnel no +MaxAuthTries 3 +LoginGraceTime 30 +LogLevel VERBOSE diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/README.md b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/README.md new file mode 100644 index 0000000..1b7f01a --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/README.md @@ -0,0 +1,15 @@ +# fluxer_firewall + +Default-deny nftables policy for CT 117, following the CT 102/114 +`*_firewall` pattern (scoped `ghostnet_filter` table, systemd stop override +that only destroys the owned table): + +- SSH (22/tcp) only from the management networks (`10.0.0.0/24`, `10.8.0.0/24`), + and the active Ansible SSH source must be inside that allowlist. +- Fluxer app-proxy (8080/tcp) and LiveKit signaling (7880/tcp) only from the + reverse proxy CT 103 (`10.0.0.10/32`) — the stack is never exposed directly. +- LiveKit media (7881/tcp, 3478/udp, 50000-50100/udp) open to the internet + only while `fluxer_stack_voice_enabled=true` (voice/video calls need direct + UDP reachability; GNAI-025 Befund e). Set it to `false` for text-only. +- Forward chain drops everything; output is unrestricted (image pulls, OIDC + calls to Keycloak, STUN). diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/defaults/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/defaults/main.yml new file mode 100644 index 0000000..19c217a --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/defaults/main.yml @@ -0,0 +1,23 @@ +--- +fluxer_firewall_management_ipv4: + - 10.0.0.0/24 + - 10.8.0.0/24 +fluxer_firewall_ssh_port: 22 + +# CT 103 (NPM) is the only host allowed to reach the Fluxer HTTP endpoints. +fluxer_firewall_reverse_proxy_ipv4: 10.0.0.10/32 +# Podman bridge network of the fluxer compose stack (aardvark-dns gateway +# 10.89.0.1:53 + inter-container traffic must pass the CT firewall) +fluxer_firewall_podman_subnet: 10.89.0.0/16 +fluxer_firewall_podman_dns_ip: 10.89.0.1 +fluxer_firewall_app_proxy_port: 8080 +fluxer_firewall_livekit_signaling_port: 7880 + +# Voice/video media (LiveKit) is published on the CT IP and must be reachable +# from the internet; the FRITZ!Box forwards these ports to 10.0.0.62 +# (GNAI-025 Befund e). Set fluxer_stack_voice_enabled=false for text-only. +fluxer_stack_voice_enabled: true +fluxer_firewall_livekit_tcp_port: 7881 +fluxer_firewall_livekit_udp_port: 7882 +fluxer_firewall_livekit_turn_udp_port: 3478 +fluxer_firewall_livekit_rtp_port_range: 50000-50100 diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/handlers/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/handlers/main.yml new file mode 100644 index 0000000..ec2be63 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/handlers/main.yml @@ -0,0 +1,9 @@ +--- +- name: Reload systemd for the Fluxer firewall + ansible.builtin.systemd_service: + daemon_reload: true + +- name: Restart the Fluxer firewall + ansible.builtin.systemd_service: + name: nftables.service + state: restarted diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/tasks/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/tasks/main.yml new file mode 100644 index 0000000..2ce206b --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/tasks/main.yml @@ -0,0 +1,97 @@ +--- +- name: Require a non-empty management allowlist + ansible.builtin.assert: + that: + - fluxer_firewall_management_ipv4 | length > 0 + fail_msg: The firewall management allowlist must be explicit and non-empty. + +- name: Read the active Ansible SSH transport endpoints + become: false + ansible.builtin.command: + argv: + - /usr/bin/printenv + - SSH_CONNECTION + check_mode: false + changed_when: false + register: fluxer_firewall_ssh_connection + +- name: Require the active Ansible SSH source in the management allowlist + ansible.builtin.command: + argv: >- + {{ + [ + '/usr/bin/python3', + '-c', + 'import ipaddress,sys; address=ipaddress.ip_address(sys.argv[1]); raise SystemExit(0 if any(address in ipaddress.ip_network(network) for network in sys.argv[2:]) else 1)', + fluxer_firewall_ssh_connection.stdout.split()[0] + ] + fluxer_firewall_management_ipv4 + }} + check_mode: false + changed_when: false + vars: + ansible_command_timeout: 5 + +- name: Create the nftables service override directory + ansible.builtin.file: + path: /etc/systemd/system/nftables.service.d + state: directory + owner: root + group: root + mode: "0755" + +- name: Install the scoped nftables stop override + ansible.builtin.template: + src: nftables.service-override.conf.j2 + dest: /etc/systemd/system/nftables.service.d/10-ghostnet-preserve.conf + owner: root + group: root + mode: "0644" + notify: + - Reload systemd for the Fluxer firewall + - Restart the Fluxer firewall + +- name: Install and validate the Fluxer nftables policy + ansible.builtin.template: + src: nftables.conf.j2 + dest: /etc/nftables.conf + owner: root + group: root + mode: "0750" + validate: /usr/sbin/nft --check --file %s + notify: Restart the Fluxer firewall + +- name: Flush firewall handlers before verification + ansible.builtin.meta: flush_handlers + +- name: Enable and start the nftables service + ansible.builtin.systemd_service: + name: nftables.service + enabled: true + state: started + daemon_reload: true + +- name: Read the active Ghostnet nftables table + ansible.builtin.command: + argv: + - /usr/sbin/nft + - list + - table + - inet + - ghostnet_filter + check_mode: false + changed_when: false + register: fluxer_firewall_active_table + when: not ansible_check_mode + +- name: Verify the active firewall policy + ansible.builtin.assert: + that: + - fluxer_firewall_active_table.stdout is search('policy drop') + - fluxer_firewall_active_table.stdout is search('SSH management') + - fluxer_firewall_active_table.stdout is search('Fluxer app-proxy via NPM') + - fluxer_firewall_active_table.stdout is search('default input deny') + - fluxer_firewall_active_table.stdout is search('CT 117 forwards nothing else') + - fluxer_firewall_active_table.stdout is search('podman bridge intra-network') + - fluxer_firewall_active_table.stdout is search('NPM to published Fluxer ports') + fail_msg: The active nftables policy does not match the declared CT 117 policy. + when: not ansible_check_mode diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/templates/nftables.conf.j2 b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/templates/nftables.conf.j2 new file mode 100644 index 0000000..a7ae012 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/templates/nftables.conf.j2 @@ -0,0 +1,81 @@ +#!/usr/sbin/nft -f + +# Managed by Ansible role fluxer_firewall. +# CT 117 runs the Fluxer stack behind NPM (CT 103): default-deny input, SSH +# from the management networks only, HTTP/WebSocket from the reverse proxy +# only, LiveKit media ports open to the internet iff voice is enabled. +destroy table inet ghostnet_filter + +table inet ghostnet_filter { + set management_ipv4 { + type ipv4_addr + flags interval + elements = { {{ fluxer_firewall_management_ipv4 | join(', ') }} } + } + + set reverse_proxy_ipv4 { + type ipv4_addr + flags interval + elements = { {{ fluxer_firewall_reverse_proxy_ipv4 }} } + } + + chain input { + type filter hook input priority 10; policy drop; + + iifname "lo" counter accept comment "local loopback" + ct state established,related counter accept + ct state invalid counter drop + + meta l4proto icmp counter accept comment "IPv4 diagnostics" + meta l4proto ipv6-icmp counter accept comment "IPv6 neighbor discovery" + + ip saddr @management_ipv4 tcp dport {{ fluxer_firewall_ssh_port }} ct state new counter accept comment "SSH management" + + ip saddr @reverse_proxy_ipv4 tcp dport {{ fluxer_firewall_app_proxy_port }} ct state new counter accept comment "Fluxer app-proxy via NPM" + ip saddr @reverse_proxy_ipv4 tcp dport {{ fluxer_firewall_livekit_signaling_port }} ct state new counter accept comment "LiveKit signaling via NPM" +{% if fluxer_stack_voice_enabled %} + tcp dport {{ fluxer_firewall_livekit_tcp_port }} ct state new counter accept comment "LiveKit ICE TCP (voice)" + udp dport {{ fluxer_firewall_livekit_udp_port }} counter accept comment "LiveKit UDP (voice)" + udp dport {{ fluxer_firewall_livekit_turn_udp_port }} counter accept comment "LiveKit TURN/STUN UDP (voice)" + udp dport {{ fluxer_firewall_livekit_rtp_port_range }} counter accept comment "LiveKit RTP media range (voice)" +{% endif %} + + ip saddr {{ fluxer_firewall_podman_subnet }} ip daddr {{ fluxer_firewall_podman_dns_ip }} udp dport 53 counter accept comment "podman aardvark-dns" + ip saddr {{ fluxer_firewall_podman_subnet }} ip daddr {{ fluxer_firewall_podman_dns_ip }} tcp dport 53 counter accept comment "podman aardvark-dns tcp" + + counter drop comment "default input deny" + } + + chain forward { + type filter hook forward priority 10; policy drop; + + ct state invalid counter drop + ct state established,related counter accept + ip saddr {{ fluxer_firewall_podman_subnet }} ip daddr {{ fluxer_firewall_podman_subnet }} counter accept comment "podman bridge intra-network" + # Full podman-bridge egress, matching the established homelab pattern + # (keycloak_firewall, CT 102): LiveKit needs outbound STUN for its + # external-IP discovery (rtc.use_external_ip in livekit.yaml), and + # unfurl fetches arbitrary link-preview URLs. Without egress LiveKit + # crash-loops ("could not resolve external IP") and destabilizes the + # whole stack unit. + ip saddr {{ fluxer_firewall_podman_subnet }} counter accept comment "Podman network egress" + # Published ports are DNAT'd by netavark in PREROUTING: by the time + # inbound traffic reaches the forward chain the destination is the + # CONTAINER IP inside the podman subnet (site30-Befund) — the input + # rules above never see it. Allow NPM and (voice) WAN traffic to the + # DNAT'd container destinations here. + ip saddr @reverse_proxy_ipv4 ip daddr {{ fluxer_firewall_podman_subnet }} tcp dport { {{ fluxer_firewall_app_proxy_port }}, {{ fluxer_firewall_livekit_signaling_port }} } ct state new counter accept comment "NPM to published Fluxer ports (app-proxy, livekit signaling)" +{% if fluxer_stack_voice_enabled %} + ip daddr {{ fluxer_firewall_podman_subnet }} tcp dport {{ fluxer_firewall_livekit_tcp_port }} ct state new counter accept comment "LiveKit ICE TCP via DNAT (voice)" + ip daddr {{ fluxer_firewall_podman_subnet }} udp dport { {{ fluxer_firewall_livekit_udp_port }}, {{ fluxer_firewall_livekit_turn_udp_port }} } counter accept comment "LiveKit UDP via DNAT (voice)" + ip daddr {{ fluxer_firewall_podman_subnet }} udp dport {{ fluxer_firewall_livekit_rtp_port_range }} counter accept comment "LiveKit RTP media via DNAT (voice)" +{% endif %} + counter drop comment "CT 117 forwards nothing else" + } + + chain output { + type filter hook output priority 10; policy accept; + } +} + +{{ '' }} diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/templates/nftables.service-override.conf.j2 b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/templates/nftables.service-override.conf.j2 new file mode 100644 index 0000000..129c56e --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_firewall/templates/nftables.service-override.conf.j2 @@ -0,0 +1,6 @@ +[Service] +# Keep the Ghostnet table across service stops; only the owned table is +# destroyed so a restart does not leave the host unfiltered. +ExecStop= +ExecStop=/usr/sbin/nft destroy table inet ghostnet_filter +{{ '\n' }} diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/README.md b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/README.md new file mode 100644 index 0000000..6a09745 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/README.md @@ -0,0 +1,14 @@ +# fluxer_lxc_baseline + +Debian-13 baseline for CT 117 (`fluxer`, `10.0.0.62`): identity assertion +against the inventory-declared CT identity, administration packages +(including `podman-compose` for the upstream compose stack), timezone, +protected `/etc/fluxer`, `/opt/fluxer` and `/var/lib/fluxer` paths, masking +of LXC-incompatible mount units, and **unattended OS security updates** +(`unattended-upgrades` restricted to `Debian-Security` origins — the CT +100/102/103 convention, GNAI-025 Befund b). + +Container image updates are deliberately NOT unattended: images are +digest-pinned and updated by re-running `site.yml` with a new pin +(`podman-auto-update.timer` stays disabled via the shared `podman_runtime` +role), which keeps the CT 102/103 update discipline. diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/defaults/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/defaults/main.yml new file mode 100644 index 0000000..361b614 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/defaults/main.yml @@ -0,0 +1,32 @@ +--- +fluxer_lxc_baseline_timezone: Europe/Berlin + +fluxer_lxc_baseline_packages: + - ca-certificates + - curl + - fail2ban + - gnupg + - logrotate + - nftables + - openssh-server + - podman-compose + - python3 + - sudo + - unattended-upgrades + +fluxer_lxc_baseline_directories: + - path: /etc/fluxer + owner: root + group: root + mode: "0700" + - path: /opt/fluxer + owner: root + group: root + mode: "0750" + - path: /var/lib/fluxer + owner: root + group: root + mode: "0750" + +fluxer_lxc_baseline_unattended_upgrades_allowed_origins: >- + Debian:${distro_codename} ${distro_codename}-security diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/handlers/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/handlers/main.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/handlers/main.yml @@ -0,0 +1 @@ +--- diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/tasks/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/tasks/main.yml new file mode 100644 index 0000000..f47ae76 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_lxc_baseline/tasks/main.yml @@ -0,0 +1,90 @@ +--- +- name: Verify the Fluxer LXC identity before changing baseline state + ansible.builtin.assert: + that: + - ansible_facts["hostname"] == fluxer_lxc_baseline_expected_hostname + - >- + ansible_facts["distribution"] == + fluxer_lxc_baseline_expected_distribution + - >- + ansible_facts["distribution_major_version"] == + fluxer_lxc_baseline_expected_distribution_major_version + - >- + ansible_facts["default_ipv4"]["address"] == + fluxer_lxc_baseline_expected_ipv4 + - >- + ansible_facts["virtualization_type"] == + fluxer_lxc_baseline_expected_virtualization_type + - ansible_facts["virtualization_role"] == "guest" + - ansible_facts["service_mgr"] == "systemd" + fail_msg: >- + The connected system is not the declared CT 117 Fluxer LXC. No + baseline changes may be applied. + +- name: Install baseline administration packages + ansible.builtin.apt: + name: "{{ fluxer_lxc_baseline_packages }}" + state: present + update_cache: true + cache_valid_time: 3600 + install_recommends: false + +- name: Set the local timezone database link + ansible.builtin.file: + src: "/usr/share/zoneinfo/{{ fluxer_lxc_baseline_timezone }}" + dest: /etc/localtime + state: link + owner: root + group: root + force: true + +- name: Record the configured timezone + ansible.builtin.copy: + content: "{{ fluxer_lxc_baseline_timezone }}\n" + dest: /etc/timezone + owner: root + group: root + mode: "0644" + +- name: Create protected Fluxer configuration and data paths + ansible.builtin.file: + path: "{{ item.path }}" + state: directory + owner: "{{ item.owner }}" + group: "{{ item.group }}" + mode: "{{ item.mode }}" + loop: "{{ fluxer_lxc_baseline_directories }}" + loop_control: + label: "{{ item.path }}" + +- name: Mask LXC-incompatible mount units (CT 100/101/102/103 convention) + ansible.builtin.systemd_service: + name: "{{ item }}" + masked: true + state: stopped + loop: + - dev-mqueue.mount + - run-lock.mount + - tmp.mount + - sys-kernel-config.mount + +- name: Enable and start the unattended-upgrades service (CT 100/102 convention) + ansible.builtin.systemd_service: + name: unattended-upgrades.service + enabled: true + state: started + # the unit only exists after the apt task above really installed the package + when: not ansible_check_mode + +- name: Restrict unattended-upgrades to Debian security origins + ansible.builtin.copy: + content: |- + Unattended-Upgrade::Origins-Pattern { + "origin=Debian,codename=${distro_codename},label=Debian-Security"; + }; + Unattended-Upgrade::AutoFixInterruptedDpkg "true"; + Unattended-Upgrade::Remove-Unused-Dependencies "true"; + dest: /etc/apt/apt.conf.d/52ghostnet-unattended-upgrades + owner: root + group: root + mode: "0644" diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/README.md b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/README.md new file mode 100644 index 0000000..2efa117 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/README.md @@ -0,0 +1,39 @@ +# fluxer_stack + +Deploys the Fluxer self-hosting stack on CT 117 (GNAI-025): + +1. Fetches the **pinned upstream compose** + (`deploy/self-hosting/docker-compose.yml` at `fluxer_stack_upstream_commit`, + SHA-256-verified) into `/opt/fluxer`. +2. Installs `docker-compose.ghostnet.yml`: disables the upstream Caddy edge + (NPM on CT 103 is the TLS edge), publishes only app-proxy (8080) and + LiveKit signaling (7880) — plus the LiveKit media ports iff + `fluxer_stack_voice_enabled` — sets `pull_policy: never` and journald + logging. Service names are asserted against the pinned compose. +3. Generates all secrets **once on the guest** in + `/etc/fluxer/fluxer-secrets.env` (0600, never in git) and renders the + compose `.env` from the inventory's public identity + small-instance + memory caps. +4. Pre-pulls every image from `fluxer_stack_images` (digest-pinned refs). +5. Manages `fluxer-stack.service` (oneshot + `podman compose up -d`), + started only on inventories with `fluxer_stack_start_allowed=true` + (production), and verifies all services reach `running`. + +## Why compose and not per-service quadlets + +Upstream ships one compose file for ~21 tightly coupled services. Forking it +into quadlets would drift from upstream on every release; the proven Podman +LXC schema is kept where it matters: unprivileged Debian 13 LXC, rootful +Podman under systemd, digest-pinned images, `podman.socket` and +`podman-auto-update.timer` disabled (shared `podman_runtime` role), nftables +default-deny in front. + +## Updates (GNAI-025 Befund b) + +- OS packages: unattended-upgrades, Debian-Security only (role + `fluxer_lxc_baseline`). +- Images/stack: bump `fluxer_stack_upstream_commit` + + `fluxer_stack_compose_sha256` + digest pins in `fluxer_stack_images`, then + re-run `site.yml` on the production inventory (preview with + `--check --diff` first). Deliberately not `podman auto-update`, matching the + CT 102/103 change discipline. diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/defaults/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/defaults/main.yml new file mode 100644 index 0000000..4f8a7bf --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/defaults/main.yml @@ -0,0 +1,128 @@ +--- +# Fluxer stack deployment (GNAI-025). The upstream project ships ONE docker +# compose file for ~21 services (app-proxy, api, gateway, worker, media-proxy, +# static, admin, snowflakes/users/messages shards, gifs, unfurl, push, +# livekit, postgres, valkey, nats, meilisearch, seaweedfs, caddy edge). We +# deploy that pinned compose via rootful `podman compose` under a systemd +# unit instead of forking it into per-service quadlets (CT 102/103 quadlet +# pattern applies where we own the service definition; here upstream does). +# Podman itself stays exactly on the proven schema: rootful, systemd-managed, +# digest-pinned images, podman.socket and podman-auto-update disabled via the +# shared podman_runtime role. + +fluxer_stack_directory: /opt/fluxer +fluxer_stack_compose_file: "{{ fluxer_stack_directory }}/docker-compose.yml" +# SHA-verified upstream copy; the active compose is adapted locally (below) +fluxer_stack_compose_upstream_file: "{{ fluxer_stack_directory }}/docker-compose.upstream.yml" +fluxer_stack_override_file: "{{ fluxer_stack_directory }}/docker-compose.ghostnet.yml" +fluxer_stack_env_file: "{{ fluxer_stack_directory }}/.env" +fluxer_stack_secrets_file: /etc/fluxer/fluxer-secrets.env +fluxer_stack_service_name: fluxer-stack.service + +# Upstream pin (GNAI-025 Befund c). The operator pins the upstream commit and +# the SHA-256 of deploy/self-hosting/docker-compose.yml at that commit, then +# pins every image by digest in fluxer_stack_images after the first pull +# (CT 102/103 convention). PENDING placeholders fail the role on purpose. +fluxer_stack_upstream_repo: https://github.com/fluxerapp/fluxer +fluxer_stack_upstream_commit: "PENDING-PIN-UPSTREAM-COMMIT" +fluxer_stack_compose_path: deploy/self-hosting/docker-compose.yml +fluxer_stack_compose_sha256: "PENDING-PIN-COMPOSE-SHA256" +fluxer_stack_compose_url: >- + https://raw.githubusercontent.com/{{ fluxer_stack_upstream_repo | urlsplit('path') | trim('/') }}/{{ fluxer_stack_upstream_commit }}/{{ fluxer_stack_compose_path }} +fluxer_stack_registry: ghcr.io/fluxerapp +fluxer_stack_image_tag: v1 +fluxer_stack_images: [] + # Operator fills this with digest-pinned refs after the first pull, e.g.: + # - ghcr.io/fluxerapp/fluxer-api@sha256: + # Pull=never semantics: the override sets pull_policy: never per service. + +# Public identity (NPM on CT 103 terminates TLS and proxies here). +fluxer_stack_public_domain: fluxer.ghostnet.selfhost.eu +fluxer_stack_public_scheme: https +fluxer_stack_public_port: 443 +fluxer_stack_app_proxy_port: 8080 +fluxer_stack_livekit_signaling_port: 7880 +fluxer_stack_voice_enabled: true +fluxer_stack_livekit_tcp_port: 7881 +fluxer_stack_livekit_turn_udp_port: 3478 +fluxer_stack_livekit_rtp_port_range: 50000-50100 + +# Upstream compose service names the ghostnet override touches. The role +# asserts each name exists in the pinned compose file and fails with a clear +# message if upstream renamed a service (then adjust here and in the +# override template). +fluxer_stack_service_images: # service -> digest-gepinntes Image (aus pin-fluxer-images.sh @ 3b1eb567) + caddy: "docker.io/library/caddy:2.10-alpine@sha256:4c6e91c6ed0e2fa03efd5b44747b625fec79bc9cd06ac5235a779726618e530d" + postgres: "docker.io/library/postgres:16-alpine@sha256:f2f98726820d0342055351c6e9d36e705f5bfffb3dd53ff556325114b08afb6d" + valkey: "docker.io/valkey/valkey:8.1-alpine@sha256:9971099af41c36e887aabdfe22b80c0fe45df949163dfc9cb434febc57cfc3fc" + nats: "docker.io/library/nats:2.14-alpine@sha256:311da47e2f31c26e99c623cd78d486a1e8ab039c49b32652770bb91a4f70512e" + meilisearch: "docker.io/getmeili/meilisearch:v1.12@sha256:c9fac23131cca4db95173d41cc50fd5639121ee381795528fdd7522d7978a7b8" + seaweedfs: "docker.io/chrislusf/seaweedfs:4.34@sha256:6620371e8af8282056685c652d4637265698c9e2c2d59f9594e6ac333ad6c634" + seaweedfs-init: "docker.io/chrislusf/seaweedfs:4.34@sha256:6620371e8af8282056685c652d4637265698c9e2c2d59f9594e6ac333ad6c634" + livekit: "docker.io/livekit/livekit-server:v1.12.0@sha256:b1281e66e35e8f9749ffbcf0fe6ab4d40d1438aa00f36c2ea7e6975e5e261e2e" + api: "ghcr.io/fluxerapp/fluxer-api:v1@sha256:9d5e0b2cac35435d724e8bb2d0999a278219a811c68b16d6ac455a5d16948b8f" + worker: "ghcr.io/fluxerapp/fluxer-api:v1@sha256:9d5e0b2cac35435d724e8bb2d0999a278219a811c68b16d6ac455a5d16948b8f" + gateway: "ghcr.io/fluxerapp/fluxer-gateway:v1@sha256:462e332783375c13e0044f10177069822eb0f457f966a982f4aa182d1eae9043" + media-proxy: "ghcr.io/fluxerapp/fluxer-media-proxy:v1@sha256:2ff45bbcff172c29a0de45c51505631aba8bd30287c408335921e39a87f14688" + static-proxy: "ghcr.io/fluxerapp/fluxer-static:v1@sha256:bb55869686b23046dbfc7730442e382643dd10b5c34be8fae788f4afc53a8f35" + app-proxy: "ghcr.io/fluxerapp/fluxer-app-proxy-self-hosted:v1@sha256:30cb19c289a2697dd3d80f50ec43da3caab0674fdee96dd24cee7cfbb0e62370" + admin: "ghcr.io/fluxerapp/fluxer-admin:v1@sha256:836be5b66ffa3bd83bffb15061b362b4fac34e898352eadf4a554a2f763c9c11" + snowflakes: "ghcr.io/fluxerapp/fluxer-snowflakes:v1@sha256:a75ab098ba71139ed78a8512523dc7449392dc52e1bf1ec3318f05d4d83c4096" + snowflakes-shard: "ghcr.io/fluxerapp/fluxer-snowflakes:v1@sha256:a75ab098ba71139ed78a8512523dc7449392dc52e1bf1ec3318f05d4d83c4096" + users: "ghcr.io/fluxerapp/fluxer-users:v1@sha256:22c44aff82785ee31d3e94823fb2775b9fab0845e04179c681a5893f685f5555" + users-shard: "ghcr.io/fluxerapp/fluxer-users:v1@sha256:22c44aff82785ee31d3e94823fb2775b9fab0845e04179c681a5893f685f5555" + messages: "ghcr.io/fluxerapp/fluxer-messages:v1@sha256:cbdfd2be58aa654d2e599af02de5c1214f0c2b73855f36edfed096a7f92bcca6" + messages-shard: "ghcr.io/fluxerapp/fluxer-messages:v1@sha256:cbdfd2be58aa654d2e599af02de5c1214f0c2b73855f36edfed096a7f92bcca6" + gifs: "ghcr.io/fluxerapp/fluxer-gifs:v1@sha256:a7916918e7b42a69dc06fb70349cde457d6fe7226a54bc52105e5ae6aa972c03" + gifs-shard: "ghcr.io/fluxerapp/fluxer-gifs:v1@sha256:a7916918e7b42a69dc06fb70349cde457d6fe7226a54bc52105e5ae6aa972c03" + unfurl: "ghcr.io/fluxerapp/fluxer-unfurl:v1@sha256:0b6ba1e741925727fb09525de7ba3eedfba8b7d728f05f0ba58cd5794a8bf14f" + unfurl-shard: "ghcr.io/fluxerapp/fluxer-unfurl:v1@sha256:0b6ba1e741925727fb09525de7ba3eedfba8b7d728f05f0ba58cd5794a8bf14f" + +fluxer_stack_service_edge: caddy +fluxer_stack_service_app_proxy: app-proxy +fluxer_stack_service_livekit: livekit + +# Required secrets of the pinned compose (all ${VAR:?} refs at 3b1eb567), +# generated once on the guest (never in git): name -> hex bytes. +# Plus FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SECRET_BASE64 (base64) and the +# FLUXER_VAPID_* P-256 keypair, both generated in the same one-time task. +fluxer_stack_secret_specs: + FLUXER_CONNECTION_INITIATION_SECRET: 32 + FLUXER_GATEWAY_RPC_AUTH_TOKEN: 32 + FLUXER_ERLANG_COOKIE: 32 # runtime-required by the gateway image (not a ${:?}) + FLUXER_PROFILE_PSEUDONYM_SECRET: 32 # runtime-required by the shard services + FLUXER_SUDO_MODE_SECRET: 32 + FLUXER_ADMIN_SECRET_KEY_BASE: 32 + FLUXER_ADMIN_OAUTH_CLIENT_SECRET: 32 + FLUXER_MEDIA_PROXY_SECRET_KEY: 32 + FLUXER_S3_ACCESS_KEY: 16 + FLUXER_S3_SECRET_KEY: 32 + POSTGRES_PASSWORD: 24 + MEILI_MASTER_KEY: 32 + # LIVEKIT_API_KEY is NOT here: it is a key *name* (identifier, not secret) + # and must be the literal "fluxer" — the pinned upstream livekit.yaml + # references webhook.api_key: fluxer, and livekit exits (0) at startup + # when that name has no matching entry in LIVEKIT_KEYS (site19-Befund). + # The task block enforces it; only LIVEKIT_API_SECRET is random. + LIVEKIT_API_SECRET: 32 + +# Extra pinned files from the same upstream commit (bind-mounted by the +# compose: ./livekit.yaml, ./Caddyfile). SHA-256 vom Operator pinnen. +fluxer_stack_livekit_path: deploy/self-hosting/livekit.yaml +fluxer_stack_livekit_sha256: "8d3f13591038ffb483f9f827c73e36732082c51ff1bb247d4782360c55af0b5a" # livekit.yaml @ 3b1eb567, Operator 2026-11-27 +fluxer_stack_caddyfile_path: deploy/self-hosting/Caddyfile +fluxer_stack_caddyfile_sha256: "1b76e5d72717bdd83a253cd0f4b9a1da432e4fd29ad7ccebbfa93234d2101d2f" # Caddyfile @ 3b1eb567, Operator 2026-11-27 + +# Small-instance memory caps via upstream's own FLUXER_*_MEMORY_LIMIT knobs +# (GNAI-025 Befund d). Sum stays well below the 8 GiB CT limit. +fluxer_stack_memory_limits: + FLUXER_API_MEMORY_LIMIT: 1536mb + FLUXER_GATEWAY_MEMORY_LIMIT: 512mb + FLUXER_WORKER_MEMORY_LIMIT: 1536mb + FLUXER_MEDIA_PROXY_MEMORY_LIMIT: 512mb + FLUXER_LIVEKIT_MEMORY_LIMIT: 512mb + FLUXER_NATS_MEMORY_LIMIT: 256mb + FLUXER_POSTGRES_MEMORY_LIMIT: 1024mb + +fluxer_stack_start_allowed: false +fluxer_stack_production_enabled: false diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/handlers/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/handlers/main.yml new file mode 100644 index 0000000..7c33ad1 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/handlers/main.yml @@ -0,0 +1,11 @@ +--- +- name: Reload systemd for the Fluxer stack + ansible.builtin.systemd_service: + daemon_reload: true + when: not ansible_check_mode + +- name: Restart the Fluxer stack + ansible.builtin.systemd_service: + name: "{{ fluxer_stack_service_name }}" + state: restarted + when: not ansible_check_mode diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/tasks/main.yml b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/tasks/main.yml new file mode 100644 index 0000000..3af0305 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/tasks/main.yml @@ -0,0 +1,362 @@ +--- +- name: Require production enablement only with an open start gate + ansible.builtin.assert: + that: + - >- + not fluxer_stack_production_enabled or + fluxer_stack_start_allowed + fail_msg: >- + Production enablement requires an explicitly open Fluxer start gate. + +- name: Require the pinned upstream commit and compose checksum + ansible.builtin.assert: + that: + - fluxer_stack_upstream_commit is not match('PENDING.*') + - fluxer_stack_compose_sha256 is not match('PENDING.*') + - fluxer_stack_compose_sha256 is match('^[0-9a-f]{64}$') + - fluxer_stack_livekit_sha256 is match('^[0-9a-f]{64}$') + - fluxer_stack_caddyfile_sha256 is match('^[0-9a-f]{64}$') + - fluxer_stack_images | length > 0 + fail_msg: >- + fluxer_stack_upstream_commit / fluxer_stack_compose_sha256 / + fluxer_stack_livekit_sha256 / fluxer_stack_caddyfile_sha256 / + fluxer_stack_images still contain PENDING placeholders. Pin the + upstream commit, the file SHA-256s and every image by digest first + (GNAI-025 Abschnitt 5, Befund c). + +- name: Create the Fluxer stack directory + ansible.builtin.file: + path: "{{ fluxer_stack_directory }}" + state: directory + owner: root + group: root + mode: "0750" + +- name: Fetch the pinned upstream compose file (SHA-256-verifiziert) + # fetched to a separate upstream copy so the checksum stays verifiable: + # the active docker-compose.yml is locally adapted below and would + # re-download (and restart the stack) on every run otherwise + ansible.builtin.get_url: + url: "{{ fluxer_stack_compose_url }}" + dest: "{{ fluxer_stack_compose_upstream_file }}" + owner: root + group: root + mode: "0644" + checksum: "sha256:{{ fluxer_stack_compose_sha256 }}" + timeout: 60 + register: fluxer_stack_compose_download + # in check mode the stack directory is not created yet, so the fetch is + # only previewed; the real run verifies the checksum + when: not ansible_check_mode + +- name: Check the active compose file + ansible.builtin.stat: + path: "{{ fluxer_stack_compose_file }}" + register: fluxer_stack_compose_stat + +- name: Copy the verified upstream compose into place (only on upstream change) + # NOT a plain content comparison: the active compose is locally adapted + # and therefore always differs from the pristine upstream copy. Refresh it + # only when the upstream download actually changed or the file is missing; + # the adapt task below then re-applies the recorded transformations. + ansible.builtin.copy: + remote_src: true + src: "{{ fluxer_stack_compose_upstream_file }}" + dest: "{{ fluxer_stack_compose_file }}" + owner: root + group: root + mode: "0644" + notify: + - Restart the Fluxer stack + when: + - not ansible_check_mode + - fluxer_stack_compose_download is changed or not fluxer_stack_compose_stat.stat.exists + +- name: Note the deferred compose fetch in check mode + ansible.builtin.debug: + msg: >- + check mode: compose fetch ({{ fluxer_stack_compose_url }}, + sha256 {{ fluxer_stack_compose_sha256 }}) is verified on the real run + when: ansible_check_mode + +- name: Adapt the pinned compose for podman-compose 1.3.0 (recorded local transformation) + # podman-compose 1.3.0 cannot satisfy `service_completed_successfully` — + # api/worker/admin stay "Created" forever although seaweedfs-init exited 0. + # The S3 buckets persist in the seaweedfs-data volume; on a truly fresh + # volume the api self-heals via restart: unless-stopped while init runs. + ansible.builtin.replace: + path: "{{ fluxer_stack_compose_file }}" + replace: "{{ item.replace }}" + regexp: "{{ item.regexp }}" + loop: + # 1. remove the seaweedfs-init depends_on edges entirely: podman-compose + # 1.3.0 never satisfies `service_completed_successfully` AND, after + # converting the condition to service_started, blocks forever in + # `podman wait --condition=running` once the oneshot init container + # has exited (0) (site20-Befund). The S3 buckets persist in the + # seaweedfs-data volume; on a truly fresh volume api/media-proxy + # self-heal via restart: unless-stopped while init runs. + - regexp: '^ seaweedfs-init: .*service_completed.*$' + replace: '' + # 2. nested ${VAR:-${INNER:-default}} refs get mangled (leftover "}:" in + # the container env); flatten so our explicit .env values pass through + - regexp: '\$\{FLUXER_REGISTRY:-ghcr\.io/\$\{FLUXER_REGISTRY_OWNER:-fluxerapp\}\}' + replace: '${FLUXER_REGISTRY}' + - regexp: '\$\{FLUXER_VAPID_EMAIL:-admin@\$\{FLUXER_DOMAIN\}\}' + replace: '${FLUXER_VAPID_EMAIL}' + - regexp: '\$\{FLUXER_PASSKEY_RP_ID:-\$\{FLUXER_DOMAIN\}\}' + replace: '${FLUXER_PASSKEY_RP_ID}' + - regexp: '\$\{FLUXER_PASSKEY_ADDITIONAL_ALLOWED_ORIGINS:-\$\{FLUXER_PUBLIC_SCHEME:-https\}://\$\{FLUXER_DOMAIN\}\}' + replace: '${FLUXER_PASSKEY_ADDITIONAL_ALLOWED_ORIGINS}' + # 3. app-proxy depends_on caddy; with caddy disabled via the override + # profile, podman-compose 1.3.0 crashes with KeyError: 'caddy' in + # check_dep_conditions (site17-Befund). The override points + # DISCOVERY_UPSTREAM_URL directly at the api, so the edge is dead. + - regexp: '^ caddy: .*condition: service_started.*$' + replace: '' + when: not ansible_check_mode + notify: + - Restart the Fluxer stack + +- name: Fetch the pinned upstream livekit.yaml (SHA-256-verifiziert) + ansible.builtin.get_url: + url: "{{ fluxer_stack_compose_url | dirname }}/{{ fluxer_stack_livekit_path | basename }}" + dest: "{{ fluxer_stack_directory }}/livekit.yaml" + owner: root + group: root + mode: "0644" + checksum: "sha256:{{ fluxer_stack_livekit_sha256 }}" + timeout: 60 + when: not ansible_check_mode + +- name: Fetch the pinned upstream Caddyfile (SHA-256-verifiziert; caddy edge disabled, file nur für compose-Vollständigkeit) + ansible.builtin.get_url: + url: "{{ fluxer_stack_compose_url | dirname }}/{{ fluxer_stack_caddyfile_path | basename }}" + dest: "{{ fluxer_stack_directory }}/Caddyfile" + owner: root + group: root + mode: "0644" + checksum: "sha256:{{ fluxer_stack_caddyfile_sha256 }}" + timeout: 60 + when: not ansible_check_mode + +- name: Read the pinned compose for the service-name assertions + ansible.builtin.slurp: + src: "{{ fluxer_stack_compose_file }}" + register: fluxer_stack_compose_content + when: not ansible_check_mode + +- name: Assert the override service names exist in the pinned compose + ansible.builtin.assert: + that: + - >- + fluxer_stack_compose_content.content | b64decode is + search('(?m)^ ' ~ item ~ ':') + fail_msg: >- + Upstream compose does not define service '{{ item }}'. Adjust + fluxer_stack_service_* in the inventory/role defaults and the override + template for the pinned upstream commit. + loop: "{{ fluxer_stack_service_images.keys() | list }}" + when: not ansible_check_mode + +- name: Allow docker.io as unqualified-search registry (upstream compose uses short names) + ansible.builtin.copy: + dest: /etc/containers/registries.conf.d/99-ghostnet-dockerio.conf + content: | + unqualified-search-registries = ["docker.io"] + owner: root + group: root + mode: "0644" + +- name: Install the ghostnet compose override + ansible.builtin.template: + src: docker-compose.ghostnet.yml.j2 + dest: "{{ fluxer_stack_override_file }}" + owner: root + group: root + mode: "0644" + validate: /usr/bin/python3 -c 'import sys,yaml; yaml.safe_load(open(sys.argv[1]))' %s + notify: + - Restart the Fluxer stack + +- name: Ensure all Fluxer secrets exist on the guest (idempotent append, never in git) + ansible.builtin.shell: | + set -Eeuo pipefail + umask 077 + f="{{ fluxer_stack_secrets_file }}" + touch "$f" + {% for name, nbytes in fluxer_stack_secret_specs.items() %} + grep -q "^{{ name }}=" "$f" || printf '%s=%s\n' '{{ name }}' "$(/usr/bin/openssl rand -hex {{ nbytes }})" >> "$f" + {% endfor %} + # LIVEKIT_API_KEY is an identifier, not a secret: the pinned upstream + # livekit.yaml hardcodes webhook.api_key: fluxer, and livekit exits (0) + # at startup when that name is missing from LIVEKIT_KEYS. Enforce the + # literal value; keep the (random) LIVEKIT_API_SECRET as the real secret. + grep -q '^LIVEKIT_API_KEY=fluxer$' "$f" || { sed -i '/^LIVEKIT_API_KEY=/d' "$f"; printf 'LIVEKIT_API_KEY=fluxer\n' >> "$f"; } + grep -q '^FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SECRET_BASE64=' "$f" \ + || printf 'FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SECRET_BASE64=%s\n' "$(/usr/bin/openssl rand -base64 36)" >> "$f" + if ! grep -qE '^FLUXER_VAPID_PRIVATE_KEY=[A-Za-z0-9_-]{43}$' "$f" || ! grep -qE '^FLUXER_VAPID_PUBLIC_KEY=[A-Za-z0-9_-]{86,87}$' "$f"; then + # VAPID web-push keypair: Fluxer verlangt base64url OHNE Padding des + # rohen 32-Byte-Scalars (privat) bzw. 65-Byte-Punkts (public) — nicht + # DER/PKCS8. Alte, falsch formatierte Werte werden ersetzt. + sed -i '/^FLUXER_VAPID_\(PRIVATE\|PUBLIC\)_KEY=/d' "$f" + /usr/bin/openssl ecparam -name prime256v1 -genkey -noout -out "$f.vapid.pem" + priv_hex=$(/usr/bin/openssl ec -in "$f.vapid.pem" -noout -text | /usr/bin/awk '/priv:/{f=1;next}/pub:/{f=0}f' | /usr/bin/tr -d ' :\n') + priv=$(printf '%b' "$(printf '%s' "$priv_hex" | /usr/bin/sed 's/../\\x&/g')" | /usr/bin/base64 -w0 | /usr/bin/tr '+/' '-_' | /usr/bin/tr -d '=') + pub=$(/usr/bin/openssl ec -in "$f.vapid.pem" -pubout -outform DER | /usr/bin/tail -c 65 | /usr/bin/base64 -w0 | /usr/bin/tr '+/' '-_' | /usr/bin/tr -d '=') + printf 'FLUXER_VAPID_PRIVATE_KEY=%s\n' "$priv" >> "$f" + printf 'FLUXER_VAPID_PUBLIC_KEY=%s\n' "$pub" >> "$f" + rm -f "$f.vapid.pem" + fi + args: + executable: /bin/bash + # guarded by grep: on a converged guest every branch is a no-op + changed_when: false + when: not ansible_check_mode + +- name: Enforce root-only permissions on the secrets file + ansible.builtin.file: + path: "{{ fluxer_stack_secrets_file }}" + owner: root + group: root + mode: "0600" + when: not ansible_check_mode # file is created by the generate task above + +- name: Read the persisted secrets + ansible.builtin.slurp: + src: "{{ fluxer_stack_secrets_file }}" + register: fluxer_stack_secrets_content + no_log: true + when: not ansible_check_mode + +- name: Expose the secret lines to the .env template + ansible.builtin.set_fact: + fluxer_stack_secret_lines: >- + {{ fluxer_stack_secrets_content.content | b64decode | trim }} + no_log: true + when: not ansible_check_mode + +- name: Render the compose .env (root-only) + ansible.builtin.template: + src: fluxer.env.j2 + dest: "{{ fluxer_stack_env_file }}" + owner: root + group: root + mode: "0600" + notify: + - Restart the Fluxer stack + no_log: true + when: not ansible_check_mode + +- name: Check a pinned image locally + ansible.builtin.command: + argv: + - /usr/bin/podman + - image + - exists + - "{{ item }}" + check_mode: false + changed_when: false + failed_when: false + register: fluxer_stack_image_exists + loop: "{{ fluxer_stack_images }}" + loop_control: + label: "{{ item }}" + +- name: Pull the pinned Fluxer images + ansible.builtin.command: + argv: + - /usr/bin/podman + - pull + - "{{ item.item }}" + changed_when: true + when: + - not ansible_check_mode + - item.rc != 0 + loop: "{{ fluxer_stack_image_exists.results }}" + loop_control: + label: "{{ item.item }}" + +- name: Install the Fluxer stack systemd unit + ansible.builtin.template: + src: fluxer-stack.service.j2 + dest: "/etc/systemd/system/{{ fluxer_stack_service_name }}" + owner: root + group: root + mode: "0644" + notify: + - Reload systemd for the Fluxer stack + +- name: Flush stack handlers before enablement + ansible.builtin.meta: flush_handlers + +- name: Enable and start the Fluxer stack (production only) + ansible.builtin.systemd_service: + name: "{{ fluxer_stack_service_name }}" + enabled: true + state: started + daemon_reload: true + when: + - fluxer_stack_start_allowed + - not ansible_check_mode + +- name: Keep the Fluxer stack stopped outside the start gate + ansible.builtin.systemd_service: + name: "{{ fluxer_stack_service_name }}" + enabled: false + state: stopped + daemon_reload: true + when: + - not fluxer_stack_start_allowed + - not ansible_check_mode + +- name: Read the compose project state + ansible.builtin.command: + argv: + - /usr/bin/podman-compose + - --project-name + - fluxer + - -f + - "{{ fluxer_stack_compose_file }}" + - -f + - "{{ fluxer_stack_override_file }}" + - ps + - --format + - json + args: + chdir: "{{ fluxer_stack_directory }}" + check_mode: false + changed_when: false + register: fluxer_stack_ps + when: + - fluxer_stack_start_allowed + - not ansible_check_mode + +- name: Verify every compose service is running (seaweedfs-init may have exited 0) + # seaweedfs-init is a oneshot S3 bucket bootstrap container: its healthy + # terminal state is Exited (0), not running (site21-Befund). + ansible.builtin.assert: + that: + - >- + fluxer_stack_ps.stdout | from_json | + selectattr('State', 'defined') | list | length > 0 + - >- + (fluxer_stack_ps.stdout | from_json | + rejectattr('State', 'equalto', 'running') | + map(attribute='Names') | map('join', ' ') | list) | + difference( + fluxer_stack_ps.stdout | from_json | + rejectattr('State', 'equalto', 'running') | + selectattr('ExitCode', 'equalto', 0) | + map(attribute='Names') | map('join', ' ') | + select('search', 'seaweedfs-init') | list) | + length == 0 + fail_msg: >- + Not all Fluxer compose services are running (seaweedfs-init may be + Exited (0), nothing else). Inspect with + `podman-compose -f docker-compose.yml -f docker-compose.ghostnet.yml ps` + and `podman logs ` on CT 117. + + when: + - fluxer_stack_start_allowed + - not ansible_check_mode diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/docker-compose.ghostnet.yml.j2 b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/docker-compose.ghostnet.yml.j2 new file mode 100644 index 0000000..5a5ed8a --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/docker-compose.ghostnet.yml.j2 @@ -0,0 +1,49 @@ +# Managed by Ansible role fluxer_stack (GNAI-025). +# Ghostnet override for the pinned upstream compose (@ 3b1eb567): +# - EVERY service gets its digest-pinned image + pull_policy: never + +# journald logging (CT 102/103 pinning convention; images are pre-pulled +# by the role from fluxer_stack_images); +# - the upstream Caddy edge is disabled (NPM on CT 103 is the TLS edge); +# - only app-proxy (8080) and LiveKit (7880 signaling + media ports) are +# published on the CT IP; the firewall allows 8080/7880 only from CT 103; +# - app-proxy discovery points at the api (caddy edge is disabled). +# Service names are asserted against the pinned compose by the role. +x-ghostnet-defaults: &ghostnet-defaults + pull_policy: never + logging: + driver: journald + +services: +{% for svc, image in fluxer_stack_service_images.items() | sort %} + {{ svc }}: + <<: *ghostnet-defaults + image: {{ image }} + environment: +{% if 'fluxerapp' in image %} + # runtime-required by the fluxer images but not wired in the upstream + # compose anchor at 3b1eb567 — injected here explicitly + FLUXER_PROFILE_PSEUDONYM_SECRET: ${FLUXER_PROFILE_PSEUDONYM_SECRET:?set in .env} +{% endif %} +{% if svc == 'gateway' %} + FLUXER_ERLANG_COOKIE: ${FLUXER_ERLANG_COOKIE:?set in .env} +{% endif %} +{% if svc == fluxer_stack_service_edge %} + profiles: + - ghostnet-disabled-edge + ports: [] +{% elif svc == fluxer_stack_service_app_proxy %} + environment: + DISCOVERY_UPSTREAM_URL: http://api:8080/api/.well-known/fluxer + ports: + - "{{ fluxer_stack_app_proxy_port }}:{{ fluxer_stack_app_proxy_port }}" +{% elif svc == fluxer_stack_service_livekit %} + ports: + - "{{ fluxer_stack_livekit_signaling_port }}:7880" + - "{{ fluxer_stack_livekit_tcp_port }}:{{ fluxer_stack_livekit_tcp_port }}/tcp" + - "{{ fluxer_stack_livekit_udp_port }}:{{ fluxer_stack_livekit_udp_port }}/udp" +{% if fluxer_stack_voice_enabled %} + - "{{ fluxer_stack_livekit_turn_udp_port }}:{{ fluxer_stack_livekit_turn_udp_port }}/udp" + - "{{ fluxer_stack_livekit_rtp_port_range }}:{{ fluxer_stack_livekit_rtp_port_range }}/udp" +{% endif %} +{% endif %} +{% endfor %} diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/fluxer-stack.service.j2 b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/fluxer-stack.service.j2 new file mode 100644 index 0000000..06e75d9 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/fluxer-stack.service.j2 @@ -0,0 +1,23 @@ +[Unit] +Description=Ghostnet Fluxer stack (pinned upstream compose via podman compose) +Documentation=https://docs.fluxer.com/operator/ +After=network-online.target nftables.service +Wants=network-online.target +Requires=nftables.service +# The start gate is enforced by the role: on agent/bootstrap inventories the +# unit stays disabled (fluxer_stack_start_allowed=false). +ConditionPathExists={{ fluxer_stack_directory }}/docker-compose.ghostnet.yml + +[Service] +Type=oneshot +RemainAfterExit=yes +WorkingDirectory={{ fluxer_stack_directory }} +# --force-recreate: podman-compose does not reliably recreate containers on +# .env changes, so force it to converge env/config on every start +ExecStart=/usr/bin/podman-compose --project-name fluxer -f {{ fluxer_stack_compose_file }} -f {{ fluxer_stack_override_file }} up -d --force-recreate +ExecStop=/usr/bin/podman-compose --project-name fluxer -f {{ fluxer_stack_compose_file }} -f {{ fluxer_stack_override_file }} down +TimeoutStartSec=1800 +TimeoutStopSec=180 + +[Install] +WantedBy=multi-user.target diff --git a/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/fluxer.env.j2 b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/fluxer.env.j2 new file mode 100644 index 0000000..dd2c5f4 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/roles/fluxer_stack/templates/fluxer.env.j2 @@ -0,0 +1,81 @@ +# Managed by Ansible role fluxer_stack (GNAI-025). Root-only (0600). +# Non-secret public identity + small-instance tuning from the inventory; +# secret lines are injected from /etc/fluxer/fluxer-secrets.env (generated +# once on this guest, never in git). Verify the variable names against the +# pinned upstream .env.example when bumping fluxer_stack_upstream_commit. +FLUXER_DOMAIN={{ fluxer_stack_public_domain }} +# required by the compose even with the caddy edge disabled (GNAI-025): +FLUXER_CADDY_SITE_ADDRESS={{ fluxer_stack_public_scheme }}://{{ fluxer_stack_public_domain }} +FLUXER_LIVEKIT_ENABLED={{ 'true' if fluxer_stack_voice_enabled else 'false' }} +# podman-compose 1.3.0 liefert bei manchen ${VAR:-default}-Refs einen Leerstring +# durch (hier beobachtet: SSO_ALLOW_PRIVATE_ADDRESSES) — daher explizit gesetzt: +# Explizite compose-Defaults: podman-compose 1.3.0 ersetzt ${VAR:-default} +# durch Leerstrings, wenn VAR nicht im .env steht — die Node-API lehnt leere +# Boolean-Werte ab. Alle nicht-leeren Defaults aus der gepinnten Compose +# (3b1eb567) daher explizit gesetzt. +# Wichtig: auch die Defaults mit LEEREM Wert (CSP_*, SMTP-Felder, KLIPY) +# müssen hier (leer) stehen — fehlt die Variable komplett, lässt +# podman-compose 1.3.0 das Literal "${VAR:-}" im Container-Env stehen und +# die api stirbt an "Invalid email app base URL" (site15-Befund): +FLUXER_SSO_ALLOW_PRIVATE_ADDRESSES=false +FLUXER_DISCOVERY_ENABLED=true +FLUXER_EMAIL_ENABLED=false +FLUXER_EMAIL_PROVIDER=none +FLUXER_EMAIL_FROM_EMAIL=noreply@localhost +FLUXER_EMAIL_FROM_NAME=Fluxer +FLUXER_EMAIL_APP_BASE_URL={{ fluxer_stack_public_scheme }}://{{ fluxer_stack_public_domain }} +FLUXER_EMAIL_SMTP_HOST= +FLUXER_EMAIL_SMTP_PORT=587 +FLUXER_EMAIL_SMTP_SECURE=true +FLUXER_EMAIL_SMTP_USERNAME= +FLUXER_EMAIL_SMTP_PASSWORD= +FLUXER_KLIPY_API_KEY= +FLUXER_CSP_EXTRA_CONNECT_SRC= +FLUXER_CSP_EXTRA_DEFAULT_SRC= +FLUXER_CSP_EXTRA_FONT_SRC= +FLUXER_CSP_EXTRA_FRAME_SRC= +FLUXER_CSP_EXTRA_IMG_SRC= +FLUXER_CSP_EXTRA_MANIFEST_SRC= +FLUXER_CSP_EXTRA_MEDIA_SRC= +FLUXER_CSP_EXTRA_SCRIPT_SRC= +FLUXER_CSP_EXTRA_STYLE_SRC= +FLUXER_CSP_EXTRA_WORKER_SRC= +FLUXER_CSP_REPORT_URI= +FLUXER_CAPTCHA_ENABLED=false +FLUXER_CAPTCHA_PROVIDER=none +FLUXER_PASSKEY_RP_ID={{ fluxer_stack_public_domain }} +FLUXER_PASSKEY_RP_NAME=Fluxer +FLUXER_PASSKEY_ADDITIONAL_ALLOWED_ORIGINS={{ fluxer_stack_public_scheme }}://{{ fluxer_stack_public_domain }} +FLUXER_VAPID_EMAIL=admin@{{ fluxer_stack_public_domain }} +FLUXER_LIVEKIT_TCP_PORT={{ fluxer_stack_livekit_tcp_port }} +FLUXER_LIVEKIT_UDP_PORT={{ fluxer_stack_livekit_udp_port }} +FLUXER_BASE_DOMAIN={{ fluxer_stack_public_domain }} +FLUXER_PUBLIC_SCHEME={{ fluxer_stack_public_scheme }} +FLUXER_PUBLIC_PORT={{ fluxer_stack_public_port }} +{% if fluxer_stack_public_port | int == 443 %} +FLUXER_PUBLIC_ORIGIN={{ fluxer_stack_public_scheme }}://{{ fluxer_stack_public_domain }} +{% else %} +FLUXER_PUBLIC_ORIGIN={{ fluxer_stack_public_scheme }}://{{ fluxer_stack_public_domain }}:{{ fluxer_stack_public_port }} +{% endif %} +FLUXER_IMAGE_TAG={{ fluxer_stack_image_tag }} +# voll expandiert setzen: podman-compose loest verschachtelte ${VAR:-${VAR2:-..}} +# nicht auf — ohne explizites FLUXER_REGISTRY bleibt der Literal-String stehen +FLUXER_REGISTRY=ghcr.io/fluxerapp + +# Internal service endpoints stay on the compose network (service DNS names). +FLUXER_KV_URL=redis://valkey:6379/0 +FLUXER_NATS_URL=nats://nats:4222 +FLUXER_NATS_JETSTREAM_URL=nats://nats:4222 +FLUXER_SVC_NATS_URL=nats://nats:4222 +FLUXER_SVC_SHARD_COUNT="1" +FLUXER_SEARCH_ENGINE=meilisearch +FLUXER_SEARCH_URL=http://meilisearch:7700 +FLUXER_S3_ENDPOINT=http://seaweedfs:8333 + +# Small-instance memory caps (upstream FLUXER_*_MEMORY_LIMIT knobs). +{% for key, value in fluxer_stack_memory_limits.items() %} +{{ key }}={{ value }} +{% endfor %} + +# Secrets (injected from {{ fluxer_stack_secrets_file }}): +{{ fluxer_stack_secret_lines }} diff --git a/proxmox/lxc/ct-117-fluxer/scripts/README.md b/proxmox/lxc/ct-117-fluxer/scripts/README.md new file mode 100644 index 0000000..66a93c6 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/scripts/README.md @@ -0,0 +1,46 @@ +# CT 117 Fluxer — PVE bootstrap scripts + +One-time, operator-run scripts that run **as root on the Proxmox VE host** +(`root@pve`); the agent workstation has no `pct` access (AGENTS.md). + +- `provision-ct117-fluxer.sh` — fresh-state creation of CT 117 (`fluxer`, + `10.0.0.62/24`) from the newest cached Debian 13 template with the recorded + profile (4 cores, 8192 MiB RAM, 2048 MiB swap, 64 GiB rootfs on `local-lvm`, + unprivileged, `nesting=1,keyctl=1`), then the reviewed generic baseline hook + (`proxmox/shared/scripts/ghostnet-lxc-baseline.sh`, SHA-256-pinned) and the + configfs mask. The script never replaces or destroys an existing CT 117 and + contains no secrets. + +The full commissioning sequence (key generation, SSH aliases, fingerprint +pinning, Ansible rebuild) is documented in +`docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md` +Abschnitt 6 and `../ansible/README.md`. + +- `pin-fluxer-images.sh` — workstation-side, one-time, **no passwords**: + downloads the pinned upstream compose (SHA-256-verified), expands every + `image:` ref (incl. `${FLUXER_*:-default}` templates) and resolves each to + its registry digest via `skopeo`, printing a ready-to-paste + `fluxer_stack_images:` YAML block for the three + `ansible/inventories/*/group_vars/fluxer_hosts.yml` (GNAI-025 Abschnitt 6, + Schritt 3). Requires `skopeo` and the repo control venv (`.venv`). + +## Transfer auf den PVE-Host (von der Workstation) + +Die Skripte liegen nur im Repo auf der Workstation; der PVE-Host hat keinen +Repo-Checkout. Einmalig dorthin kopieren (als Operator mit root@pve-Zugang): + +```bash +R=/home/ghost/source/repos/ghost.net/infrastructure +scp "$R/proxmox/shared/scripts/ghostnet-lxc-baseline.sh" root@pve:/usr/local/sbin/ghostnet-lxc-baseline.sh +scp "$R/proxmox/lxc/ct-117-fluxer/scripts/provision-ct117-fluxer.sh" root@pve:/root/provision-ct117-fluxer.sh +scp "$R"/proxmox/lxc/ct-117-fluxer/ansible/files/ssh/fluxer-*.pub root@pve:/root/ +``` + +Auf dem PVE-Host (root@pve) vor dem Lauf verifizieren: + +```bash +chmod 0755 /usr/local/sbin/ghostnet-lxc-baseline.sh /root/provision-ct117-fluxer.sh +sha256sum /usr/local/sbin/ghostnet-lxc-baseline.sh +# muss sein: 111f1b70e47e3a2f6a1bcce22cb0ec50aacd8fbcff37d87fbcf853a318381b10 +GHOSTNET_AGENT_UID=1000 GHOSTNET_ADMIN_UID=1001 bash /root/provision-ct117-fluxer.sh +``` diff --git a/proxmox/lxc/ct-117-fluxer/scripts/pin-fluxer-images.sh b/proxmox/lxc/ct-117-fluxer/scripts/pin-fluxer-images.sh new file mode 100755 index 0000000..ce787a1 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/scripts/pin-fluxer-images.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +# Resolve every container image referenced by the pinned upstream Fluxer +# compose to its registry digest and print a ready-to-paste +# `fluxer_stack_images:` YAML block for the three inventories +# (inventories/*/group_vars/fluxer_hosts.yml). Run ONCE on the workstation +# (no passwords involved); requires: curl, sha256sum, skopeo, and the +# repository control venv (.venv, see ansible/README.md). +# +# Usage: +# sudo apt install -y skopeo # once +# bash proxmox/lxc/ct-117-fluxer/scripts/pin-fluxer-images.sh [commit] +# +# GNAI-025 Abschnitt 6, Schritt 3. + +set -Eeuo pipefail +umask 077 + +readonly COMMIT="${1:-3b1eb56713d59181823df284b9646c890d2a3cba}" +readonly EXPECTED_SHA256='1cb102f9799ba8858a1fee71abdd4111085c997bdeddd5d878c0d8f28c85fe50' +readonly COMPOSE_PATH='deploy/self-hosting/docker-compose.yml' +readonly COMPOSE_URL="https://raw.githubusercontent.com/fluxerapp/fluxer/${COMMIT}/${COMPOSE_PATH}" + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd)" +readonly PY="${REPO_ROOT}/.venv/bin/python" + +[[ -x "$PY" ]] || { echo "missing $PY — build the control venv first (ansible/README.md)" >&2; exit 1; } +command -v curl >/dev/null || { echo 'curl missing' >&2; exit 1; } +command -v sha256sum >/dev/null || { echo 'sha256sum missing' >&2; exit 1; } +command -v skopeo >/dev/null || { echo 'skopeo missing — sudo apt install -y skopeo' >&2; exit 1; } + +tmp="$(mktemp)" +trap 'rm -f "$tmp" "$tmp.refs"' EXIT + +curl -fsSL "$COMPOSE_URL" -o "$tmp" +printf '%s %s\n' "$EXPECTED_SHA256" "$tmp" | sha256sum --check --status - \ + || { echo "SHA-256 mismatch for compose @ ${COMMIT} — do not pin from this file" >&2; exit 1; } + +# Extract image refs (with ${VAR:-default} expansion) from the compose. +"$PY" - "$tmp" "$tmp.refs" <<'PYEOF' +import re, sys +import yaml + +compose_file, out_file = sys.argv[1], sys.argv[2] +# Pure compose semantics: every ${VAR:-default} in the pinned compose carries +# its own default (FLUXER_REGISTRY defaults to ghcr.io/${OWNER:-fluxerapp}), +# so no variable is preset here — the expansion must match the untouched compose. +defaults = {} + +def expand(value: str) -> str: + # innermost-first so nested defaults like ${A:-ghcr.io/${B:-fluxerapp}} resolve fully + pattern = re.compile(r"\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^{}]*))?\}") + for _ in range(10): + new = pattern.sub( + lambda m: defaults.get(m.group(1), m.group(2) if m.group(2) is not None else ""), + value, + ) + if new == value: + if "${" in new: + raise SystemExit(f"could not fully expand: {value}") + return new + value = new + raise SystemExit(f"could not fully expand: {value}") + +doc = yaml.safe_load(open(compose_file)) +refs = set() +for service in (doc.get("services") or {}).values(): + image = service.get("image") + if image: + ref = expand(str(image)) + # podman has no unqualified-search registries: normalize to docker.io + name = ref.split("/")[0].split(":")[0] # registry = first path component, tag stripped + if "." not in name: + if "/" in ref: + ref = "docker.io/" + ref # chrislusf/seaweedfs etc. + else: + ref = "docker.io/library/" + ref # official images: postgres, nats, caddy + refs.add(ref) + +with open(out_file, "w") as f: + for ref in sorted(refs): + f.write(ref + "\n") +print(f"{len(refs)} image refs in compose @ {sys.argv[1]}", file=sys.stderr) +PYEOF + +echo "fluxer_stack_images:" >&2 +while IFS= read -r ref; do + digest="$(skopeo inspect "docker://${ref}" --format '{{.Digest}}')" + printf ' - %s@%s\n' "$ref" "$digest" +done < "$tmp.refs" diff --git a/proxmox/lxc/ct-117-fluxer/scripts/provision-ct117-fluxer.sh b/proxmox/lxc/ct-117-fluxer/scripts/provision-ct117-fluxer.sh new file mode 100755 index 0000000..9e4194e --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/scripts/provision-ct117-fluxer.sh @@ -0,0 +1,253 @@ +#!/usr/bin/env bash + +# Fresh-state rebuild of CT 117 (Fluxer chat server) on the Proxmox VE host. +# Creates the container from a Debian 13 template with the recorded profile +# and runs the reviewed generic LXC baseline hook with the recorded account +# UIDs. It then masks the configfs mount unit (configfs is unavailable in +# unprivileged LXC; CT 100/101/102/103 convention) and clears a stale failed +# state. No lxc.seccomp.profile change (GNAI-019 decision 2). +# +# The script never replaces or destroys an existing CT 117. It contains no +# password, private key or Fluxer secret. All Fluxer secrets are generated +# on the guest by the fluxer_stack Ansible role (GNAI-025). +# +# Run as root@pve: bash provision-ct117-fluxer.sh +# See docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md +# Abschnitt 6 for the full commissioning sequence. + +set -Eeuo pipefail +umask 077 + +readonly CTID='117' +readonly HOSTNAME="${GHOSTNET_CT117_HOSTNAME:-fluxer}" +readonly IPV4_CIDR='10.0.0.62/24' +readonly GATEWAY='10.0.0.1' +readonly NAMESERVER='10.0.0.14' +readonly BRIDGE='vmbr0' +readonly TEMPLATE_STORAGE='local' +# Default local-lvm like CT 100/101/102/103. The 2026-11-27 CT 117 run failed +# extracting the template into the fresh LV mountpoint (tar permission denied +# under lxc-usernsexec) — root cause under investigation, see GNAI-025 1.3. +# Fallback: GHOSTNET_CT117_CONTAINER_STORAGE=daten4 (btrfs dir storage, CT 114). +readonly CONTAINER_STORAGE="${GHOSTNET_CT117_CONTAINER_STORAGE:-local-lvm}" +readonly BASELINE_HOOK="${GHOSTNET_BASELINE_HOOK:-/usr/local/sbin/ghostnet-lxc-baseline.sh}" +# Reviewed repository copy of proxmox/shared/scripts/ghostnet-lxc-baseline.sh: +readonly BASELINE_HOOK_SHA256='111f1b70e47e3a2f6a1bcce22cb0ec50aacd8fbcff37d87fbcf853a318381b10' +# CT 117 profile (GNAI-025 Abschnitt 3): Fluxer full stack needs real RAM; +# the per-service limits in the ghostnet compose override sum to <= 6 GiB. +readonly CORES="${GHOSTNET_CT117_CORES:-4}" +readonly MEMORY_MB="${GHOSTNET_CT117_MEMORY_MB:-8192}" +readonly ROOTFS_GB="${GHOSTNET_CT117_ROOTFS_GB:-64}" +readonly SWAP_MB="${GHOSTNET_CT117_SWAP_MB:-2048}" +# Empty: auto-detect the newest debian-13 amd64 template in the local cache. +readonly OS_TEMPLATE="${GHOSTNET_OS_TEMPLATE:-}" +# The recorded account UIDs must match fluxer_access_agent_uid and +# fluxer_access_admin_uid in the Ansible inventory. +readonly AGENT_UID="${GHOSTNET_AGENT_UID:-}" +readonly ADMIN_UID="${GHOSTNET_ADMIN_UID:-}" + +log() { + printf '[ghostnet-ct117-provision] %s\n' "$*" +} + +die() { + printf '[ghostnet-ct117-provision] ERROR: %s\n' "$*" >&2 + exit 1 +} + +require_command() { + command -v "$1" >/dev/null 2>&1 || die "required command not found: $1" +} + +require_file_sha256() { + local expected="$1" + local path="$2" + + [[ -f "$path" ]] || die "required file is missing: ${path}" + printf '%s %s\n' "$expected" "$path" | sha256sum --check --status - || + die "SHA-256 mismatch: ${path}" +} + +storage_is_active() { + local storage="$1" + pvesm status | awk -v storage="$storage" ' + $1 == storage && $3 == "active" { found = 1 } + END { exit(found ? 0 : 1) } + ' +} + +require_numeric() { + local name="$1" + local value="$2" + + [[ "$value" =~ ^[0-9]+$ ]] || die "${name} must be numeric (got: ${value:-})" +} + +[[ "${EUID}" -eq 0 ]] || die 'must run as root on the Proxmox VE host' +for command_name in awk grep ls pct pvesm pveversion seq sha256sum sort; do + require_command "$command_name" +done + +pveversion >/dev/null 2>&1 || die 'this does not appear to be a Proxmox VE host' +[[ ! -e "/etc/pve/lxc/${CTID}.conf" ]] || + die "CT ${CTID} still exists; this script never replaces or destroys a container" +if pct status "$CTID" >/dev/null 2>&1; then + die "CT ${CTID} is still registered" +fi + +[[ "$HOSTNAME" =~ ^[A-Za-z0-9][A-Za-z0-9-]*$ ]] || + die "invalid hostname: ${HOSTNAME}" +require_numeric GHOSTNET_CT117_CORES "$CORES" +require_numeric GHOSTNET_CT117_MEMORY_MB "$MEMORY_MB" +require_numeric GHOSTNET_CT117_ROOTFS_GB "$ROOTFS_GB" +require_numeric GHOSTNET_CT117_SWAP_MB "$SWAP_MB" +require_numeric GHOSTNET_AGENT_UID "$AGENT_UID" +require_numeric GHOSTNET_ADMIN_UID "$ADMIN_UID" +[[ "$AGENT_UID" != "$ADMIN_UID" ]] || + die 'GHOSTNET_AGENT_UID and GHOSTNET_ADMIN_UID must differ' + +storage_is_active "$TEMPLATE_STORAGE" || + die "template storage ${TEMPLATE_STORAGE} is not active" +storage_is_active "$CONTAINER_STORAGE" || + die "container storage ${CONTAINER_STORAGE} is not active" + +[[ -x "$BASELINE_HOOK" ]] || die "baseline hook is not executable: ${BASELINE_HOOK}" +require_file_sha256 "$BASELINE_HOOK_SHA256" "$BASELINE_HOOK" + +resolved_template="$OS_TEMPLATE" +if [[ -z "$resolved_template" ]]; then + [[ "$TEMPLATE_STORAGE" == 'local' ]] || + die 'template auto-detection requires the local template storage; set GHOSTNET_OS_TEMPLATE' + template_cache='/var/lib/vz/template/cache' + resolved_template="$( + ls -1 "${template_cache}"/debian-13-*amd64*.tar.* 2>/dev/null | sort -V | tail -n 1 || true + )" + [[ -n "$resolved_template" ]] || + die "no debian-13 amd64 template in ${template_cache}; set GHOSTNET_OS_TEMPLATE" + resolved_template="${TEMPLATE_STORAGE}:vztmpl/$(basename "$resolved_template")" +fi +[[ "$resolved_template" =~ ^[A-Za-z0-9_.-]+:vztmpl/.+\.tar\.(zst|gz|xz)$ ]] || + die "GHOSTNET_OS_TEMPLATE must be a template volume ID like local:vztmpl/debian-13-standard_13.1-1_amd64.tar.zst (got: ${resolved_template})" +template_storage="${resolved_template%%:*}" +storage_is_active "$template_storage" || + die "template storage ${template_storage} is not active" +pvesm list "$template_storage" | awk '{print $1}' | + grep -qx "$resolved_template" || + die "template not found in storage ${template_storage}: ${resolved_template}" + +# pct create must run with a permissive umask: with umask 077 the rootfs +# mountpoint is created 0700 root-owned and the lxc-usernsexec tar extraction +# fails with "Permission denied" (reproduced 2026-11-27, GNAI-025 1.5). +umask 022 + +log "creating CT ${CTID} (${HOSTNAME}, ${IPV4_CIDR}) from ${resolved_template}" +log "profile: ${CORES} cores, ${MEMORY_MB} MiB RAM, ${SWAP_MB} MiB swap, ${ROOTFS_GB} GiB rootfs on ${CONTAINER_STORAGE}" +pct create "$CTID" "$resolved_template" \ + --hostname "$HOSTNAME" \ + --cores "$CORES" \ + --memory "$MEMORY_MB" \ + --swap "$SWAP_MB" \ + --rootfs "${CONTAINER_STORAGE}:${ROOTFS_GB}" \ + --net0 "name=eth0,bridge=${BRIDGE},gw=${GATEWAY},ip=${IPV4_CIDR},type=veth" \ + --nameserver "$NAMESERVER" \ + --timezone 'Europe/Berlin' \ + --ostype debian \ + --unprivileged 1 \ + --onboot 1 \ + --features 'nesting=1,keyctl=1' || + die 'pct create failed' + +config="$(pct config "$CTID")" +grep -qx "cores: ${CORES}" <<<"$config" || die 'unexpected CPU allocation' +grep -qx "memory: ${MEMORY_MB}" <<<"$config" || die 'unexpected memory allocation' +grep -qx "swap: ${SWAP_MB}" <<<"$config" || die 'unexpected swap allocation' +grep -qx "hostname: ${HOSTNAME}" <<<"$config" || die 'unexpected hostname' +grep -qx "nameserver: ${NAMESERVER}" <<<"$config" || die 'unexpected nameserver' +grep -qx 'onboot: 1' <<<"$config" || die 'onboot is not enabled' +grep -qx 'unprivileged: 1' <<<"$config" || die 'container is not unprivileged' +grep -qx 'ostype: debian' <<<"$config" || die 'unexpected os type' +grep -qx 'timezone: Europe/Berlin' <<<"$config" || die 'unexpected timezone' +grep -Eq '^features: .*nesting=1' <<<"$config" || die 'nesting is not enabled' +grep -Eq '^features: .*keyctl=1' <<<"$config" || die 'keyctl is not enabled' +grep -Eq "^rootfs: ${CONTAINER_STORAGE}:.*,size=${ROOTFS_GB}G(,|$)" <<<"$config" || + die 'unexpected root filesystem allocation' +net0="$(grep '^net0: ' <<<"$config")" +for expected_net_field in \ + 'name=eth0' \ + "bridge=${BRIDGE}" \ + "gw=${GATEWAY}" \ + "ip=${IPV4_CIDR}" \ + 'type=veth'; do + [[ "$net0" == *"$expected_net_field"* ]] || + die "net0 is missing ${expected_net_field}" +done + +log "starting CT ${CTID}" +pct start "$CTID" || die 'pct start failed' +responsive='no' +for _ in $(seq 1 60); do + if pct exec "$CTID" -- /bin/true 2>/dev/null; then + responsive='yes' + break + fi + sleep 2 +done +[[ "$responsive" == 'yes' ]] || die "CT ${CTID} did not become responsive after start" + +log 'running the reviewed generic LXC baseline with the recorded account UIDs' +GHOSTNET_AGENT_UID="$AGENT_UID" GHOSTNET_ADMIN_UID="$ADMIN_UID" \ + "$BASELINE_HOOK" "$CTID" || + die 'the baseline hook failed; inspect the output above before any rerun' + +log 'masking the configfs mount unit (configfs is unavailable in unprivileged LXC)' +pct exec "$CTID" -- systemctl mask sys-kernel-config.mount +pct exec "$CTID" -- systemctl reset-failed sys-kernel-config.mount + +pct exec "$CTID" -- /bin/bash -s -- \ + "$HOSTNAME" "${IPV4_CIDR%/*}" "$AGENT_UID" "$ADMIN_UID" <<'GUEST_VERIFY' || + die 'guest verification failed' +set -Eeuo pipefail + +log() { + printf '[ghostnet-ct117-provision/guest] %s\n' "$*" +} + +die() { + printf '[ghostnet-ct117-provision/guest] ERROR: %s\n' "$*" >&2 + exit 1 +} + +hostname="$1" +ipv4="$2" +agent_uid="$3" +admin_uid="$4" + +# shellcheck disable=SC1091 +source /etc/os-release +[[ "${ID:-}" == 'debian' ]] || die "unsupported guest OS: ${ID:-unknown}" +[[ "${VERSION_ID:-}" == '13' ]] || + die "guest is Debian ${VERSION_ID:-unknown}, expected 13 (trixie)" +test "$(hostname --short)" = "$hostname" +ip -o -4 address show scope global | grep -Eq "[[:space:]]inet[[:space:]]+${ipv4//./\\.}/" +test "$(id -u ghost-agent)" = "$agent_uid" +test "$(id -u ghost)" = "$admin_uid" +systemctl is-active --quiet ssh.service +if systemctl --failed --no-legend --plain | grep -q .; then + die 'failed systemd units are present after the baseline' +fi +log "guest: $(hostname), Debian ${VERSION_ID}, $(systemd-detect-virt)" +log "ghost-agent UID ${agent_uid}, ghost UID ${admin_uid}, ssh.service active" +GUEST_VERIFY + +log "CT ${CTID} fresh-state provisioning completed and verified" +log 'operator actions before the Ansible rebuild sequence (GNAI-025 Abschnitt 6):' +log " 1. set the ghost sudo password: pct exec ${CTID} -- passwd ghost" +log ' 2. install the agent and ghost public keys from ansible/files/ssh/ into' +log ' /home/ghost-agent/.ssh/authorized_keys and /home/ghost/.ssh/authorized_keys' +log ' (the baseline hook created both files empty and protected)' +log ' 3. on the workstation: add the ssh aliases ghostnet-ct117-agent / -ghost /' +log ' -ansible-deploy and seed known_hosts_ghostnet_ct117' +log ' 4. fill every PENDING placeholder in the Ansible inventory (preflight.yml' +log ' reports the missing values on the agent inventory)' +log ' 5. run the rebuild sequence from ansible/README.md (preflight, then site.yml' +log ' --check --diff, then the authorized site.yml run)' diff --git a/proxmox/pve-host/README.md b/proxmox/pve-host/README.md index 89e012f..aa21df9 100644 --- a/proxmox/pve-host/README.md +++ b/proxmox/pve-host/README.md @@ -38,6 +38,15 @@ Aktuell verwaltete Host-State: `/root/.ssh/known_hosts` gepinnt. Log: `/var/log/ghostnet-lxc-backup-sync.log`. Eingerichtet am 10.11.2026 (GNAI-000 Abschnitt 4 Punkt 4; erster Lauf und Restore-Test bestanden). +- **Tägliche Snapshots für CT 114 (Litecoin Wallet)**: Rolle + `pve_lxc_snapshot` — Skript + `/usr/local/sbin/ghostnet-lxc-snapshot-ct114.sh` plus Timer + `ghostnet-lxc-snapshot-ct114.timer` (täglich 04:00) erzeugen + `pct snapshot 114 ghostnet-daily-` und prunen auf die 7 + neuesten Snapshots. CT 114 ist bewusst nicht Teil des vzdump-Backup-Jobs + (150 GiB Chain ist re-syncbar; `wallet.dat` wird clientseitig + verschlüsselt via restic aus dem CT heraus gesichert). Log: + `/var/log/ghostnet-lxc-snapshot-ct114.log` (GNAI-024 Abschnitt 9). Die CT-Lebenszyklus-Skripte (`proxmox/lxc//scripts/`: `pct create`, Dist-Upgrade) bleiben Bootstrap-Skripte und laufen einmalig manuell als diff --git a/proxmox/pve-host/ansible/playbooks/site.yml b/proxmox/pve-host/ansible/playbooks/site.yml index 535b723..ce30edb 100644 --- a/proxmox/pve-host/ansible/playbooks/site.yml +++ b/proxmox/pve-host/ansible/playbooks/site.yml @@ -9,3 +9,4 @@ - role: pve_media_cron - role: pve_nfs_export - role: pve_lxc_backup_sync + - role: pve_lxc_snapshot diff --git a/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/README.md b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/README.md new file mode 100644 index 0000000..7f0d7ce --- /dev/null +++ b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/README.md @@ -0,0 +1,12 @@ +# pve_lxc_snapshot + +Daily snapshot of CT 114 (Litecoin wallet LXC) on the PVE host, GNAI-024 +Abschnitt 9: `pct snapshot 114 ghostnet-daily-` every night at +04:00, retention of the newest 7 snapshots (`pct listsnapshot` / +`pct delsnapshot`), log at `/var/log/ghostnet-lxc-snapshot-ct114.log`. + +CT 114 is deliberately not part of the vzdump backup job: the 150 GiB chain +is re-syncable on restore, and `wallet.dat` is covered by the client-side +encrypted restic backups from inside the CT plus these snapshots. The +snapshots require snapshot-capable storage (`local-lvm` / ZFS), which the +provisioning script preflights. diff --git a/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/defaults/main.yml b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/defaults/main.yml new file mode 100644 index 0000000..93aa61c --- /dev/null +++ b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/defaults/main.yml @@ -0,0 +1,11 @@ +--- +# Daily LXC snapshots for CT 114 (Litecoin wallet node, GNAI-024 Abschnitt 9). +# CT 114 is deliberately excluded from the vzdump backup job (150 GiB chain is +# re-syncable; wallet.dat is covered by encrypted restic backups and these +# snapshots), so local-lvm snapshots are its container-level recovery layer. +pve_lxc_snapshot_ctid: 114 +pve_lxc_snapshot_name_prefix: ghostnet-daily +pve_lxc_snapshot_keep: 7 +pve_lxc_snapshot_script: /usr/local/sbin/ghostnet-lxc-snapshot-ct114.sh +pve_lxc_snapshot_log: /var/log/ghostnet-lxc-snapshot-ct114.log +pve_lxc_snapshot_timer_oncalendar: '*-*-* 04:00:00' diff --git a/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/handlers/main.yml b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/handlers/main.yml new file mode 100644 index 0000000..8f99013 --- /dev/null +++ b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: Reload systemd daemon + ansible.builtin.systemd_service: + daemon_reload: true diff --git a/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/tasks/main.yml b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/tasks/main.yml new file mode 100644 index 0000000..8fa7c1a --- /dev/null +++ b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/tasks/main.yml @@ -0,0 +1,44 @@ +--- +- name: Install the CT 114 snapshot script + ansible.builtin.template: + src: ghostnet-lxc-snapshot-ct114.sh.j2 + dest: "{{ pve_lxc_snapshot_script }}" + owner: root + group: root + mode: "0750" + validate: /bin/bash -n %s + +- name: Install the CT 114 snapshot systemd service + ansible.builtin.template: + src: ghostnet-lxc-snapshot-ct114.service.j2 + dest: /etc/systemd/system/ghostnet-lxc-snapshot-ct114.service + owner: root + group: root + mode: "0644" + notify: Reload systemd daemon + +- name: Install the CT 114 snapshot systemd timer + ansible.builtin.template: + src: ghostnet-lxc-snapshot-ct114.timer.j2 + dest: /etc/systemd/system/ghostnet-lxc-snapshot-ct114.timer + owner: root + group: root + mode: "0644" + notify: Reload systemd daemon + +- name: Create the snapshot log file + ansible.builtin.file: + path: "{{ pve_lxc_snapshot_log }}" + state: touch + owner: root + group: root + mode: "0640" + modification_time: preserve + access_time: preserve + +- name: Enable and start the CT 114 snapshot timer + ansible.builtin.systemd_service: + name: ghostnet-lxc-snapshot-ct114.timer + enabled: true + state: started + daemon_reload: true diff --git a/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.service.j2 b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.service.j2 new file mode 100644 index 0000000..7649c4d --- /dev/null +++ b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.service.j2 @@ -0,0 +1,7 @@ +[Unit] +Description=Ghostnet daily snapshot of CT 114 (Litecoin wallet LXC) + +[Service] +Type=oneshot +ExecStart={{ pve_lxc_snapshot_script }} +# Runs as root: pct snapshot requires host root. diff --git a/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.sh.j2 b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.sh.j2 new file mode 100644 index 0000000..980740a --- /dev/null +++ b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.sh.j2 @@ -0,0 +1,31 @@ +#!/bin/bash +# {{ ansible_managed }} +# Daily snapshot of CT 114 with retention, installed by role pve_lxc_snapshot +# (GNAI-024 Abschnitt 9). Snapshots protect against container-level +# corruption; they do not replace the encrypted wallet backup. +set -euo pipefail + +CTID="{{ pve_lxc_snapshot_ctid }}" +PREFIX="{{ pve_lxc_snapshot_name_prefix }}" +KEEP="{{ pve_lxc_snapshot_keep }}" +LOG="{{ pve_lxc_snapshot_log }}" + +log() { echo "$(date -u +%FT%TZ) $*" >> "$LOG"; } + +pct config "$CTID" >/dev/null 2>&1 || { log "FAIL CT $CTID does not exist"; exit 1; } + +name="${PREFIX}-$(date +%Y%m%d-%H%M%S)" +pct snapshot "$CTID" "$name" --description "ghostnet daily snapshot (keep ${KEEP})" \ + || { log "FAIL pct snapshot $CTID $name"; exit 1; } +log "OK created snapshot $name for CT $CTID" + +# Retention: keep the newest KEEP snapshots of this prefix, delete older ones. +pct listsnapshot "$CTID" \ + | awk -v prefix="$PREFIX" '$1 == prefix || $1 ~ "^"prefix"-" { print $1 }' \ + | sort -r \ + | tail -n +"$((KEEP + 1))" \ + | while read -r old; do + pct delsnapshot "$CTID" "$old" && log "OK pruned snapshot $old" || log "FAIL prune $old" + done + +log "DONE CT $CTID snapshot run" diff --git a/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.timer.j2 b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.timer.j2 new file mode 100644 index 0000000..b3a5388 --- /dev/null +++ b/proxmox/pve-host/ansible/roles/pve_lxc_snapshot/templates/ghostnet-lxc-snapshot-ct114.timer.j2 @@ -0,0 +1,9 @@ +[Unit] +Description=Daily snapshot of CT 114 (Litecoin wallet LXC) + +[Timer] +OnCalendar={{ pve_lxc_snapshot_timer_oncalendar }} +Persistent=true + +[Install] +WantedBy=timers.target