GNAI-025: Fluxer-Chat-LXC CT 117 geplant — Machbarkeitsprüfung, Ansible-Projekt, NPM-Vhost, Keycloak-Client
ci-static / secret-scan (push) Successful in 44s
ci-static / yamllint (push) Successful in 1m12s
ci-static / ansible-syntax (push) Successful in 1m7s
ci-static / markdown-links (push) Successful in 43s

- Doku GNAI-025 (Plan/Machbarkeit/Operator-Phasen), Index-Einträge
- proxmox/lxc/ct-117-fluxer: PVE-Provisioning-Skript + Ansible-Projekt
  (agent/bootstrap/production; Rollen fluxer_lxc_baseline, fluxer_access,
  fluxer_firewall, fluxer_stack mit gepinnter upstream-compose via podman
  compose, digest-gepinnten Images, on-guest Secrets 0600)
- CT 103: Rolle reverse_proxy_fluxer_vhost (chat.ghostnet.selfhost.eu ->
  10.0.0.62:8080 + /livekit/), in site.yml eingehängt
- CT 102: Keycloak-OIDC-Client 'fluxer' in keycloak_realm_config
- CT 117 noch nicht angelegt; PENDING-Platzhalter (Commit/Compose-SHA/Digests/
  Host-Key-Fingerprint/pubkeys) müssen vor dem ersten Lauf ersetzt werden

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-11-28 05:51:41 +01:00
parent 18eaa64e5f
commit 3da719dec4
52 changed files with 2365 additions and 1 deletions
+1
View File
@@ -42,6 +42,7 @@ jeweiligen Fachdokumenten. Die priorisierte weitere Umsetzung beschreibt der
| [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) | geplanter Fluxer-Chat-LXC `fluxer` (`10.0.0.62`): Machbarkeitsprüfung (Keycloak-OIDC, Unattended Updates, Performance), Podman-LXC-Schema, Ansible-Projekt, NPM-Vhost und Keycloak-Client — CT noch nicht angelegt (Plan 27.11.2026) |
### KI und Deployment
+2
View File
@@ -21,6 +21,8 @@ Hypervisors selbst.
| [CT-101-Automation](../../../proxmox/lxc/ct-101-samba/README.md) | produktives Samba-Ansible-Projekt und CT-spezifische PVE-Helfer |
| [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
@@ -0,0 +1,156 @@
# Fluxer Chat LXC (CT 117) – Plan, Machbarkeitsprüfung und Umsetzungsstand
**Stand:** 2026-11-27
**Status:** Plan + Repo-Artefakte vollständig vorbereitet (Ansible-Projekt, PVE-Provisioning-Skript, NPM-Vhost-Rolle, Keycloak-Client); CT 117 ist **noch nicht angelegt** — Anlage und produktive Ansible-Läufe sind Operator-Schritte (Abschnitt 6).
## Änderungsverlauf
| Datum | Version | Autor | Änderung |
| --- | --- | --- | --- |
| 2026-11-27 | 1.0 | Mistral Vibe | Erstfassung: Machbarkeitsprüfung (Abschnitt 2), Zielarchitektur, Repo-Artefakte, Operator-Phasen |
## 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://chat.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://chat.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-<service>: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: chat.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 chat.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`,
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://chat.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) + `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 `chat.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.
## 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.
2. **Operator (Workstation):** drei CT-117-Keypairs generieren, `.pub` nach `files/ssh/`, SSH-Aliases `ghostnet-ct117-*` in `~/.ssh/config`.
3. **Operator:** upstream-Commit pinnen, compose-SHA-256 ermitteln, Image-Digests nach erstem Pull pinnen (`PENDING-*` in den Inventories ersetzen); SSH-Host-Key-Fingerprint-Platzhalter vormerken.
4. **Operator (root@pve):** `provision-ct117-fluxer.sh` ausführen (legt CT 117 an, GHOSTNET_AGENT_UID=1000 GHOSTNET_ADMIN_UID=1001), dann `pct exec 117 -- passwd ghost`, pubkeys in die authorized_keys, Fingerprint pinnen.
5. **Agent:** `preflight.yml` auf `agent`-Inventory (read-only) — Identitäts- und Leerstands-Gates.
6. **Agent (nach Operator-Go):** `site.yml --check --diff` auf `production`, dann autorisierter `site.yml`-Lauf; zweiter Lauf muss `changed=0` liefern.
7. **Agent:** CT-102-`keycloak_realm_config` laufen lassen (legt Client `fluxer` an).
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).
10. **Operator:** Pi-hole-Split-DNS `chat.ghostnet.selfhost.eu → 10.0.0.10`; 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://chat.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-27
Repo-Artefakte vollständig (Abschnitt 5); CT 117 nicht angelegt; keine
produktiven Läufe. Nächster Schritt: Operator-Phasen 1–4 (Abschnitt 6).
@@ -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 (chat.ghostnet.selfhost.eu)
rootUrl: https://chat.ghostnet.selfhost.eu
redirectUris:
- https://chat.ghostnet.selfhost.eu/auth/sso/callback
- https://chat.ghostnet.selfhost.eu/auth/sso/callback/*
webOrigins:
- https://chat.ghostnet.selfhost.eu
postLogoutRedirectUris: "https://chat.ghostnet.selfhost.eu/*"
@@ -157,4 +157,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 fcurrent.get(k) != v:
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")
@@ -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 }}
}
@@ -25,4 +25,5 @@
- role: reverse_proxy_npm
- role: reverse_proxy_oauth2proxy
- role: reverse_proxy_research_vhost
- role: reverse_proxy_fluxer_vhost
- role: reverse_proxy_fail2ban
@@ -0,0 +1,12 @@
# reverse_proxy_fluxer_vhost
NPM proxy host + Let's-Encrypt certificate for the Fluxer instance
`chat.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.
@@ -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: chat.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;
}
@@ -0,0 +1,117 @@
#!/usr/bin/env python3
"""Idempotent NPM proxy-host + LE certificate for chat.ghostnet.selfhost.eu
(Fluxer on CT 117, GNAI-025). Usage:
npm_fluxer_vhost.py <npm_api_base> <api_env_file> <spec.json>
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/<id>.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")
@@ -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
@@ -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 }}
}
+16
View File
@@ -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://chat.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).
@@ -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
`chat.ghostnet.selfhost.eu` → `10.0.0.62:8080`; add the Pi-hole split-DNS
record `chat.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).
@@ -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
@@ -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).
@@ -0,0 +1,41 @@
---
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: chat.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
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_registry: ghcr.io/fluxerapp
fluxer_stack_image_tag: v1
fluxer_stack_images: []
# Read-only access only; the agent inventory must never converge state.
fluxer_stack_start_allowed: false
fluxer_stack_production_enabled: false
@@ -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:PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP" # PENDING
fluxer_expected_processor_vcpus: 4
fluxer_minimum_memory_mb: 7800
fluxer_minimum_root_size_bytes: 68719476736 # 64 GiB
fluxer_minimum_root_available_bytes: 10000000000
@@ -0,0 +1,8 @@
---
all:
children:
fluxer_hosts:
hosts:
fluxer-ct117:
ansible_host: 10.0.0.62
ansible_user: ghost-agent
@@ -0,0 +1,41 @@
---
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: chat.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
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_registry: ghcr.io/fluxerapp
fluxer_stack_image_tag: v1
fluxer_stack_images: []
# Bootstrap converges configuration but must not start the stack yet.
fluxer_stack_start_allowed: false
fluxer_stack_production_enabled: false
@@ -0,0 +1,8 @@
---
fluxer_ctid: 117
fluxer_expected_ipv4: 10.0.0.62
fluxer_expected_ssh_host_key_fingerprint: "SHA256:PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP" # PENDING
fluxer_expected_processor_vcpus: 4
fluxer_minimum_memory_mb: 7800
fluxer_minimum_root_size_bytes: 68719476736 # 64 GiB
fluxer_minimum_root_available_bytes: 10000000000
@@ -0,0 +1,8 @@
---
all:
children:
fluxer_hosts:
hosts:
fluxer-ct117:
ansible_host: 10.0.0.62
ansible_user: ghost
@@ -0,0 +1,51 @@
---
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: chat.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_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: "PENDING-PIN-UPSTREAM-COMMIT"
fluxer_stack_compose_path: deploy/self-hosting/docker-compose.yml
fluxer_stack_compose_sha256: "PENDING-PIN-COMPOSE-SHA256"
fluxer_stack_registry: ghcr.io/fluxerapp
fluxer_stack_image_tag: v1
fluxer_stack_images: [] # filled with digest-pinned image refs by the operator
# The stack is started only on inventories with fluxer_stack_start_allowed.
fluxer_stack_start_allowed: true
fluxer_stack_production_enabled: true
@@ -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:PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP" # PENDING: gepinnt nach erstem Boot (GNAI-025 Abschnitt 6)
fluxer_expected_processor_vcpus: 4
fluxer_minimum_memory_mb: 7800
fluxer_minimum_root_size_bytes: 68719476736 # 64 GiB
fluxer_minimum_root_available_bytes: 10000000000
@@ -0,0 +1,8 @@
---
all:
children:
fluxer_hosts:
hosts:
fluxer-ct117:
ansible_host: 10.0.0.62
ansible_user: ansible-deploy
@@ -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 }}
@@ -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
@@ -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`.
@@ -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
@@ -0,0 +1,5 @@
---
- name: Restart the classic SSH service
ansible.builtin.systemd_service:
name: ssh.service
state: restarted
@@ -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 }}"
@@ -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 <command> [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
@@ -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
@@ -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).
@@ -0,0 +1,18 @@
---
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
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_turn_udp_port: 3478
fluxer_firewall_livekit_rtp_port_range: 50000-50100
@@ -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
@@ -0,0 +1,95 @@
---
- 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')
fail_msg: The active nftables policy does not match the declared CT 117 policy.
when: not ansible_check_mode
@@ -0,0 +1,57 @@
#!/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_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 %}
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 117 forwards nothing"
}
chain output {
type filter hook output priority 10; policy accept;
}
}
{{ '' }}
@@ -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' }}
@@ -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.
@@ -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
@@ -0,0 +1,88 @@
---
- 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
- 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"
@@ -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.
@@ -0,0 +1,80 @@
---
# 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"
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:<digest>
# 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: chat.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_edge: caddy
fluxer_stack_service_app_proxy: app-proxy
fluxer_stack_service_livekit: livekit
# Secrets generated once on the guest (never in git): name -> hex bytes.
fluxer_stack_secret_specs:
FLUXER_SETUP_TOKEN: 32
FLUXER_CONNECTION_INITIATION_SECRET: 32
FLUXER_JWT_SECRET: 32
POSTGRES_PASSWORD: 24
MEILI_MASTER_KEY: 32
FLUXER_S3_ACCESS_KEY: 16
FLUXER_S3_SECRET_KEY: 32
LIVEKIT_API_KEY: 8
LIVEKIT_API_SECRET: 32
# 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
@@ -0,0 +1,9 @@
---
- name: Reload systemd for the Fluxer stack
ansible.builtin.systemd_service:
daemon_reload: true
- name: Restart the Fluxer stack
ansible.builtin.systemd_service:
name: "{{ fluxer_stack_service_name }}"
state: restarted
@@ -0,0 +1,226 @@
---
- 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_images | length > 0
fail_msg: >-
fluxer_stack_upstream_commit / fluxer_stack_compose_sha256 /
fluxer_stack_images still contain PENDING placeholders. Pin the
upstream commit, the compose SHA-256 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
ansible.builtin.get_url:
url: "{{ fluxer_stack_compose_url }}"
dest: "{{ fluxer_stack_compose_file }}"
owner: root
group: root
mode: "0644"
checksum: "sha256:{{ fluxer_stack_compose_sha256 }}"
timeout: 60
notify:
- Restart the Fluxer stack
- name: Read the pinned compose for the service-name assertions
ansible.builtin.slurp:
src: "{{ fluxer_stack_compose_file }}"
register: fluxer_stack_compose_content
- 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_edge }}"
- "{{ fluxer_stack_service_app_proxy }}"
- "{{ fluxer_stack_service_livekit }}"
- 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: Check whether the secrets file already exists
ansible.builtin.stat:
path: "{{ fluxer_stack_secrets_file }}"
register: fluxer_stack_secrets_stat
- name: Generate the Fluxer secrets once on the guest (never in git)
ansible.builtin.shell: |
set -Eeuo pipefail
umask 077
tmp="$(mktemp "{{ fluxer_stack_secrets_file }}.XXXXXX")"
trap 'rm -f "$tmp"' EXIT
{% for name, nbytes in fluxer_stack_secret_specs.items() %}
printf '%s=%s\n' '{{ name }}' "$(/usr/bin/openssl rand -hex {{ nbytes }})" >> "$tmp"
{% endfor %}
mv "$tmp" "{{ fluxer_stack_secrets_file }}"
trap - EXIT
args:
executable: /bin/bash
changed_when: true
when: not fluxer_stack_secrets_stat.stat.exists
- name: Enforce root-only permissions on the secrets file
ansible.builtin.file:
path: "{{ fluxer_stack_secrets_file }}"
owner: root
group: root
mode: "0600"
- name: Read the persisted secrets
ansible.builtin.slurp:
src: "{{ fluxer_stack_secrets_file }}"
register: fluxer_stack_secrets_content
no_log: true
- 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
- 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
- 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
ansible.builtin.assert:
that:
- >-
fluxer_stack_ps.stdout | from_json |
selectattr('State', 'defined') | list | length > 0
- >-
fluxer_stack_ps.stdout | from_json |
selectattr('State', 'equalto', 'running') | list | length ==
(fluxer_stack_ps.stdout | from_json | length)
fail_msg: >-
Not all Fluxer compose services are running. Inspect with
`podman-compose -f docker-compose.yml -f docker-compose.ghostnet.yml ps`
and `podman logs <container>` on CT 117.
when:
- fluxer_stack_start_allowed
- not ansible_check_mode
@@ -0,0 +1,36 @@
# Managed by Ansible role fluxer_stack (GNAI-025).
# Ghostnet override for the pinned upstream compose:
# - the upstream Caddy edge is disabled (NPM on CT 103 terminates TLS and
# proxies to the app-proxy; no 80/443 published on CT 117);
# - only the app-proxy (HTTP/WS) and LiveKit signaling are published, plus
# the LiveKit media ports iff voice is enabled;
# - pull_policy: never on every touched service — images are pre-pulled by
# digest from fluxer_stack_images (CT 102/103 pinning convention);
# - journald logging so `podman logs`/`journalctl` work uniformly.
# Service names are asserted against the pinned compose by the role.
x-ghostnet-defaults: &ghostnet-defaults
pull_policy: never
logging:
driver: journald
services:
{{ fluxer_stack_service_edge }}:
<<: *ghostnet-defaults
profiles:
- ghostnet-disabled-edge
ports: []
{{ fluxer_stack_service_app_proxy }}:
<<: *ghostnet-defaults
ports:
- "{{ fluxer_stack_app_proxy_port }}:{{ fluxer_stack_app_proxy_port }}"
{{ fluxer_stack_service_livekit }}:
<<: *ghostnet-defaults
ports:
- "{{ fluxer_stack_livekit_signaling_port }}:7880"
{% if fluxer_stack_voice_enabled %}
- "{{ fluxer_stack_livekit_tcp_port }}:{{ fluxer_stack_livekit_tcp_port }}/tcp"
- "{{ 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 %}
@@ -0,0 +1,21 @@
[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 }}
ExecStart=/usr/bin/podman-compose --project-name fluxer -f {{ fluxer_stack_compose_file }} -f {{ fluxer_stack_override_file }} up -d
ExecStop=/usr/bin/podman-compose --project-name fluxer -f {{ fluxer_stack_compose_file }} -f {{ fluxer_stack_override_file }} down
TimeoutStartSec=900
TimeoutStopSec=180
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,35 @@
# 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 }}
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 }}
FLUXER_REGISTRY={{ fluxer_stack_registry | regex_replace('/$', '') }}
FLUXER_REGISTRY_OWNER=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 }}
@@ -0,0 +1,17 @@
# 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`.
+244
View File
@@ -0,0 +1,244 @@
#!/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'
readonly 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:-<unset>})"
}
[[ "${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}"
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)'