Ops-dashboard. deployen van repos naar docker
Adds deploy/server-backup/install-flows.sh — een idempotent installer die de ops-agent-zijde van de server-backup feature aan elkaar plakt: 1. wrappers/*.sh → /srv/backups/scripts/wrappers/ 2. flows.example/server_backup_* → /etc/ops-agent/flows/ 3. commands.yml.example commands → /etc/ops-agent/commands.yml (append, met backup) 4. NOPASSWD-regels voor wrappers → /etc/sudoers.d/ops-agent (visudo-validated) 5. systemctl restart ops-agent 6. systemctl enable --now server-backup.timer Wat het bewust *niet* doet (staat in scriptheader): restic env/password aanmaken, repos initialiseren, base-scripts of systemd-units plaatsen — die secrets-stappen blijven handwerk per README "Snelle installatie". Re-run safe: - cmp-check per file in stappen 1-2 (skip als identiek) - grep-check op command-name in stap 3 (skip als al aanwezig) - visudo-validatie in stap 4 voorkomt lockout bij syntax-fout - backups van mutaties: commands.yml.bak.<ts> en sudoers.d/ops-agent.bak.<ts> Regex-fix t.o.v. eerste handmatige run vandaag: command-block-extractie gebruikt nu [a-z0-9_]+ ipv [a-z_]+, zodat namen met digits (restic_*_b2) als losse blocks gezien worden. Het oude pattern miste ze maar sleepte ze toevallig mee in het vorige block — eindresultaat correct, output misleidend. Nieuwe versie faalt expliciet als een command echt ontbreekt. README aangevuld met sectie "Ops-agent wiring (na stap 1-7)" die naar het script verwijst. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| app | ||
| components | ||
| deploy | ||
| docs | ||
| hooks | ||
| lib | ||
| ops-agent | ||
| prisma | ||
| public | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| components.json | ||
| Dockerfile | ||
| next.config.ts | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.mjs | ||
| prisma.config.ts | ||
| proxy.ts | ||
| README.md | ||
| tsconfig.json | ||
Ops Dashboard
Single-user ops dashboard voor jp-visser.nl.
See docs/runbooks/ for setup, deployment, and operational procedures.
Installation
Prerequisites
- Docker + Docker Compose (plugin) installed on the host
- A PostgreSQL service named
postgresalready running in the same Compose stack - The repository cloned to
/srv/ops/repos/ops-dashboard /srv/scrum4me/compose/docker-compose.ymlas the shared Compose file
1. Configure environment
cp deploy/ops-dashboard.env.example /srv/ops/ops-dashboard.env
# Edit /srv/ops/ops-dashboard.env — set DATABASE_URL, AUTH_SECRET, etc.
2. Install ops-agent
sudo deploy/ops-agent/setup.sh
This creates the ops-agent system user, installs /opt/ops-agent, generates
/etc/ops-agent/secret, and enables the systemd unit.
Copy the generated secret into the web-app env file:
sudo cat /etc/ops-agent/secret
# Paste the value as OPS_AGENT_SECRET= in /srv/ops/ops-dashboard.env
3. Build and start the dashboard
sudo docker compose -f /srv/scrum4me/compose/docker-compose.yml build ops-dashboard
sudo docker compose -f /srv/scrum4me/compose/docker-compose.yml up -d ops-dashboard
The dashboard is now reachable on 127.0.0.1:3001 (proxied by Caddy).
4. Install the self-update script
sudo deploy/ops-dashboard-updater/install.sh
To enable scheduled updates (daily at 03:00):
sudo systemctl enable --now ops-dashboard-updater.timer
To trigger a manual update via SSH:
sudo systemctl start ops-dashboard-updater.service
# or:
sudo /opt/ops-dashboard-updater/update.sh
Never trigger updates through the dashboard UI — the script restarts the container that serves the UI.
Configuration
| File | Purpose |
|---|---|
/srv/ops/ops-dashboard.env |
Web-app environment (DATABASE_URL, AUTH_SECRET, OPS_AGENT_SECRET, …) |
/etc/ops-agent/secret |
Shared HMAC secret between web-app and ops-agent |
/etc/ops-agent/commands.yml |
Whitelist of commands the ops-agent may run |
/etc/ops-agent/flows/ |
Flow YAML files (backup, caddy reload, etc.) |
/srv/scrum4me/compose/docker-compose.yml |
Main Compose file (add ops-dashboard fragment from deploy/) |
Ops-agent auth
The web-app communicates with the ops-agent via a shared secret stored in
/etc/ops-agent/secret (mode 0640, owner root:ops-agent).
- The ops-agent reads the secret at startup via
OPS_AGENT_SECRET_PATH. - Every request from the web-app carries
Authorization: Bearer <secret>. - The agent validates using a constant-time comparison to prevent timing attacks.
- The web-app reads the secret value from the
OPS_AGENT_SECRETenvironment variable.
Secret rotation procedure
- Generate a new secret on the server:
openssl rand -hex 32 | sudo tee /etc/ops-agent/secret sudo chown root:ops-agent /etc/ops-agent/secret sudo chmod 0640 /etc/ops-agent/secret - Update
OPS_AGENT_SECRETin the web-app's environment file (/srv/ops/ops-dashboard.env) with the new value. - Restart both services:
sudo systemctl restart ops-agent sudo docker compose -f /srv/ops/docker-compose.ops-dashboard.yml restart ops-dashboard - Verify the dashboard is operational and that
systemctl status ops-agentshows the service running without errors.