docs: plan the ops conversion around the WireGuard hub; TODO list
ops is the WireGuard hub, so converting it takes the admin network down for everyone, and services with it. The Phase 2 plan now says how ops is reached at every point: WireGuard until the stop, its public address in the bootstrap system, then WireGuard again, with a break-glass root login from the admin's exit address (services' IPv4, through Xray) for this phase only. The new system is activated with `nixos-rebuild test` under a 15-minute dead-man reboot first, so a lock-out ends in the reachable bootstrap system instead of a console session; only after the laptop is back on WireGuard does `switch` make it the boot default. A TODO section tracks what is left, starting with deleting /old-root on services after a week. Assisted-by: Claude:opus-5-5
This commit is contained in:
parent
21c58a4a66
commit
ce8b1a678e
1 changed files with 113 additions and 55 deletions
164
MIGRATION.md
164
MIGRATION.md
|
|
@ -12,6 +12,18 @@ list price, so each one is converted **in place** and never recreated.
|
|||
**Nothing in production changes without the owner's go-ahead for that
|
||||
step.** Every step below that touches a server says so.
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] **2026-11-24 or later**, if services has run without surprises:
|
||||
`rm -rf /old-root` on asxpio-services (about 47 GB of Debian and its
|
||||
Docker data), then delete its snapshot `pre-nixos-2026-11-17` in the
|
||||
Hetzner console.
|
||||
- [ ] Delete the two offline runners (ids 1 and 2) in Forgejo → Site
|
||||
administration → Runners.
|
||||
- [ ] Phase 2 (asxpio-ops), below.
|
||||
- [ ] One week after Phase 2: `rm -rf /old-root` on asxpio-ops, delete its
|
||||
snapshot.
|
||||
|
||||
## Where things stand (2026-11-17)
|
||||
|
||||
**asxpio-services runs NixOS** since 2026-11-17 (Phase 1 below, done) and
|
||||
|
|
@ -219,76 +231,122 @@ After a week without surprises: `rm -rf /old-root`, delete the snapshot.
|
|||
|
||||
## Phase 2: asxpio-ops (owner's go-ahead required)
|
||||
|
||||
Before it, in addition to Phase 0: disable `.forgejo/workflows/deploy.yaml`
|
||||
(Ansible) on `main`, or a later push would apply the Debian roles to the
|
||||
converted ops. Build on the host (Phase 1 lessons), and check IPv6 from
|
||||
outside for every site.
|
||||
Harder than Phase 1 for one reason: **ops is the WireGuard hub.** Every
|
||||
admin connection (and asxpio-services' only admin path) goes through
|
||||
`wg0` on ops. While ops is converted, WireGuard is down for everyone
|
||||
(laptop, aleks, zerrtika, sanya, and services' spoke).
|
||||
|
||||
Downtime about 30–45 minutes for every site, Forgejo, the registry and
|
||||
monitoring: the conversion itself, the first build of the system, then
|
||||
pulling each app image again (Docker's image store does not carry over).
|
||||
Announce it.
|
||||
The admin's internet keeps working throughout: it leaves through Xray on
|
||||
services, which this phase does not touch. Its exit address is services'
|
||||
public IPv4, **46.62.228.216**, and that is the address ops sees for
|
||||
anything the admin sends it outside WireGuard.
|
||||
|
||||
ops is the WireGuard hub, so during the window the admin network is
|
||||
down. Until step 4, ops is reachable as root on its public address
|
||||
(nixos-infect's bootstrap system has no address restriction); from step
|
||||
4 on, over WireGuard again, or from services over the private network.
|
||||
### How ops is reached at each point
|
||||
|
||||
1. **Snapshot**, as in Phase 1.
|
||||
2. **Dumps and stop**, the staged copies the data script loads:
|
||||
| Point | Path | Why it works |
|
||||
|---|---|---|
|
||||
| Debian, before the stop | WireGuard, as now | — |
|
||||
| nixos-infect's bootstrap system | `ssh root@135.181.27.77` | Hetzner allows 22 from anywhere (Forgejo's git SSH); the bootstrap sshd has no `AllowUsers`; same host key |
|
||||
| `nixos-rebuild test` (new system, not yet the boot default) | WireGuard again (same keys); **break-glass:** `ssh root@135.181.27.77` from 46.62.228.216 | the flake allows root from that one address during this phase only |
|
||||
| locked out anyway | wait: a dead-man timer reboots into the bootstrap system after 15 min | `test` does not change the boot default |
|
||||
| after `switch` | WireGuard; break-glass until removed | — |
|
||||
|
||||
services during the window: unreachable from outside (its SSH is
|
||||
WireGuard/private only); reach it through ops once ops answers:
|
||||
`ssh -J root@135.181.27.77 root@10.10.0.20`. It keeps running; only its
|
||||
log shipping to Loki and the runner's link to Forgejo pause.
|
||||
|
||||
### Before the window (no downtime)
|
||||
|
||||
1. **App healthchecks in the compose files** (Phase 0 step 3): asxpio,
|
||||
datacenterbingo, blog. Deployed on Debian through their normal CI, so
|
||||
the first deploy on NixOS can reach "healthy".
|
||||
2. **Storage repo:** disable its deploy workflow (Phase 0 step 4).
|
||||
3. **Secrets:** compare every ops secret in sops with the vault,
|
||||
`/opt/storage/.env` and the live values, as was done for services.
|
||||
4. **Final rehearsal on `claude-test-nixos-a`** with that night's ops
|
||||
backup: `migration/ops-data.sh /restore`, the apps pulled and healthy
|
||||
through the Docker CLI, monitoring history moved. Proves the data
|
||||
script end to end on fresh data.
|
||||
5. **Break-glass in the flake:** root SSH from 46.62.228.216 for ops only
|
||||
(`asxpio.sshFrom` override in `hosts/asxpio-ops`), merged before the
|
||||
window, removed after it.
|
||||
6. **Announce** to the WireGuard users: their tunnel drops for about 30
|
||||
minutes; to everyone: sites, Forgejo and the registry are down for
|
||||
about 30 minutes. Freeze pushes (Phase 0 step 6).
|
||||
7. **Snapshot** of ops in the Hetzner console (the prod token is
|
||||
read-only), `pre-nixos-<date>`.
|
||||
|
||||
### The window (about 25–35 minutes of downtime)
|
||||
|
||||
From a workstation on WireGuard, in the repo. Every step is a separate
|
||||
go-ahead.
|
||||
|
||||
1. **Ansible off:** merge a commit to `main` that removes
|
||||
`.forgejo/workflows/deploy.yaml`; check no run is left. Ansible would
|
||||
otherwise apply the Debian roles to the converted ops on the next push.
|
||||
2. **Fresh backup, dumps, stop** (WireGuard still up):
|
||||
|
||||
```sh
|
||||
ssh root@10.20.0.10 'set -e; d=/var/backups/restic-stage; install -d -m 700 $d; \
|
||||
ssh root@10.20.0.10 'restic-backup run; set -e; d=/var/backups/restic-stage; install -d -m 700 $d; \
|
||||
docker stop asxpio asxpio-monitor datacenterbingo blog czsk vhpbot vhpbot-dev || true; \
|
||||
docker exec storage-postgres pg_dumpall -U postgres > $d/pg_dumpall.sql; \
|
||||
sqlite3 /opt/forgejo/data/gitea/gitea.db ".backup $d/forgejo-gitea.db"; \
|
||||
docker exec storage-garage /garage meta snapshot --all; \
|
||||
docker ps -q | xargs -r docker stop -t 60; systemctl stop docker.socket docker containerd'
|
||||
docker image prune -af; docker ps -q | xargs -r docker stop -t 60; \
|
||||
systemctl stop docker.socket docker containerd'
|
||||
```
|
||||
|
||||
3. **Convert**, as in Phase 1 step 3, on 135.181.27.77.
|
||||
4. **Switch to the flake** on its public address:
|
||||
**Downtime starts.** Undo: `systemctl start docker`.
|
||||
|
||||
3. **Convert:** write `/etc/nixos/bootstrap.nix` (from `tofu output -json
|
||||
user_data | jq -r '."asxpio-ops"'`), then run nixos-infect as in Phase
|
||||
1 step 3. Its existing 2 GB swapfile carries the build. **WireGuard goes
|
||||
down here.** Wait for `ssh root@135.181.27.77 'test -d /old-root'`.
|
||||
4. **Build and test, not switch**, on the host (Phase 1 lesson):
|
||||
|
||||
```sh
|
||||
nixos-rebuild switch --flake .#asxpio-ops --target-host root@135.181.27.77 \
|
||||
--build-host root@135.181.27.77
|
||||
git archive HEAD | ssh root@135.181.27.77 'rm -rf /root/iac; mkdir /root/iac; tar -x -C /root/iac'
|
||||
ssh root@135.181.27.77 'systemd-run --unit=deadman --on-active=15min systemctl reboot; \
|
||||
cd /root/iac/nixos && NIX_CONFIG="experimental-features = nix-command flakes" \
|
||||
nixos-rebuild test --flake .#asxpio-ops'
|
||||
```
|
||||
|
||||
From here on root logs in from WireGuard and the private network only;
|
||||
WireGuard is up again with the same keys, so clients reconnect.
|
||||
Then from the laptop: WireGuard handshake, `ssh root@10.20.0.10`,
|
||||
`ssh root@10.20.0.20`. Only then: `systemctl stop deadman.timer`. If
|
||||
anything fails, do nothing: in 15 minutes ops reboots into the
|
||||
bootstrap system, reachable on 135.181.27.77, and the cause can be
|
||||
fixed there.
|
||||
5. **Make it the boot default:** `nixos-rebuild switch --flake .#asxpio-ops`
|
||||
(same build, instant).
|
||||
6. **Data, start, images:** `ssh root@10.20.0.10 'bash -s /old-root' <
|
||||
nixos/migration/ops-data.sh`, then reboot once.
|
||||
7. **Check** (all from outside where possible):
|
||||
- WireGuard: all five peers handshake again (`wg show` on ops).
|
||||
- Every site over IPv4 **and IPv6** (Grafana → Probes, plus `curl -6`
|
||||
from services); certificates are the old ones from `acme.json`.
|
||||
- Forgejo: web, `git clone` and push over SSH and HTTPS, the registry
|
||||
serves a pull; CI on services reaches Forgejo again.
|
||||
- asxpio: admin login, render an invoice. datacenterbingo: photos,
|
||||
`/data.json`. `garage status`; an anonymous read of the public bucket.
|
||||
- An app deploy from CI reaches "healthy".
|
||||
- Grafana: targets up, logs from both hosts, security panel clean;
|
||||
the first alert evaluation after the move sends nothing unexpected.
|
||||
- `systemctl start restic-backup xmpp-cert-sync` succeed (the push now
|
||||
uses the new key).
|
||||
- `systemctl --failed` empty; the login summary is clean.
|
||||
|
||||
5. **Move the data, start everything, pull the app images:**
|
||||
### After
|
||||
|
||||
```sh
|
||||
ssh root@10.20.0.10 'bash -s /old-root' < migration/ops-data.sh
|
||||
ssh root@10.20.0.10 reboot
|
||||
```
|
||||
- Remove the break-glass from the flake, and the Debian ops key from
|
||||
`xmppCertSyncKeysExtra` (`hosts/asxpio-services/xmpp-cert-install.nix`).
|
||||
- Delete `/old-root/var/lib/docker` once the apps run (frees the old
|
||||
images on the small disk); the rest of `/old-root` after a week (TODO).
|
||||
- Phase 3.
|
||||
|
||||
The script moves Forgejo, Garage, Traefik's certificates, the
|
||||
monitoring history and `/opt/<app>`; loads the Postgres dump (roles
|
||||
then get their passwords from sops); regenerates Forgejo's hooks and
|
||||
SSH keys file; and runs `docker compose pull && up -d` for each app
|
||||
as `deploy` (vhpbot-prod builds locally).
|
||||
|
||||
6. **Check:**
|
||||
- Every site answers (Grafana → Probes). Certificates are the old ones
|
||||
from `acme.json`; Traefik renews as before.
|
||||
- `git clone` over SSH and HTTPS; a push; the package registry serves
|
||||
a pull.
|
||||
- asxpio: log in to the admin, render an invoice (the boot test that
|
||||
catches what a database check does not).
|
||||
- datacenterbingo shows photos (Garage through the app) and
|
||||
`/data.json`.
|
||||
- `garage status`; `curl -I https://s3.asxp.io/public/<a known key>`.
|
||||
- Grafana: targets up, logs from both hosts, security panel clean.
|
||||
- CI: push an empty commit to an app repo; the deploy reaches
|
||||
"healthy" (Phase 0 step 3).
|
||||
- `systemctl start restic-backup xmpp-cert-sync` succeed.
|
||||
- Remove the Debian ops key from `xmppCertSyncKeysExtra`
|
||||
(`hosts/asxpio-services/xmpp-cert-install.nix`).
|
||||
|
||||
**Rollback:** as in Phase 1. If services has already moved, it keeps
|
||||
working against a Debian ops: nothing on services depends on how ops is
|
||||
built.
|
||||
**Rollback:** before step 3, `systemctl start docker`. After it, rebuild
|
||||
from the snapshot in the Hetzner console. services keeps working against
|
||||
a Debian ops: nothing on it depends on how ops is built.
|
||||
|
||||
## Phase 3: clean-up
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue