Commit graph

145 commits

Author SHA1 Message Date
29dcc8915a
ci: evaluate only, comin deploys
All checks were successful
nixos / nixos (push) Successful in 21s
comin on each host pulls main and switches, so the CI deploy job, its
SSH configuration and the known_hosts it used go. CI keeps evaluating
every host on every push and no longer holds a key to the servers;
SSH_DEPLOY_KEY can be removed from the repository secrets.

Assisted-by: Claude:opus-5-5
2026-11-17 11:39:40 +04:00
9290a4e181
nixos: add comin, hosts pull their configuration from main
All checks were successful
nixos / nixos (push) Successful in 3m22s
Each host runs comin, which polls main of this repository every minute,
builds nixosConfigurations.<hostname> on the host and switches to it.
A branch testing-<hostname> on top of main is applied with `test` to
that host alone. Prometheus scrapes comin over the private network, and
a failing fetch, evaluation, build or switch alerts after 15 minutes.

CI still deploys this commit, which starts comin; the CI deploy job and
its SSH key go in the next commit, once comin runs on both hosts.

Assisted-by: Claude:opus-5-5
2026-11-17 11:39:03 +04:00
2635b887c7
nixos: drop the rehearsal pair and other migration leftovers
All checks were successful
nixos / nixos (push) Successful in 1m3s
The test pair served the move to NixOS, which is done. Its overlays,
dummy secrets and sops recipients go; the rules for testing on a copy
of production stay in nixos/README.md, and git log finds the overlay
if it is needed again. Options that existed only for it (alert address,
Loki bucket, extra cert-push keys) are inlined, and comments still
pointing at Ansible or MIGRATION.md are corrected.

The tofu README now spells out the state bucket bootstrap: the bucket
is a resource in the state it holds, so a new project needs one local
apply first. The bucket gets prevent_destroy for the same reason.

Assisted-by: Claude:opus-5-5
2026-11-17 11:11:33 +04:00
aebc919435
docs: TODO after the secret rotation; Postgres and Garage to services
Assisted-by: Claude:opus-5-5
2026-11-17 11:02:38 +04:00
c9ac900b3d
xray: restart only when its own config changes
All checks were successful
nixos / nixos (push) Successful in 1m15s
Xray restarted whenever anything in services' secrets file changed,
because its restart trigger was the whole sops file; the runner token
change just now restarted it. Xray may carry the admin's uplink. Tie the
restart to its own secret.

Assisted-by: Claude:opus-5-5
2026-11-17 11:00:57 +04:00
b7414c2ad1
runner: connect with UUID and token instead of registering
All checks were successful
nixos / nixos (push) Successful in 1m8s
The runner's token was regenerated in Forgejo (runner asxpio-services,
same UUID), which also retires the registration-token route the NixOS
module used. Both runners now work the same way: settings from Nix, the
connection (URL, UUID, token from sops) merged in at start, no
registration step. A new token is a sops change and a deploy.

Corrects 0a54caa: `forgejo actions generate-runner-token` returned the
existing registration token, so that commit rotated nothing.

Assisted-by: Claude:opus-5-5
2026-11-17 10:57:02 +04:00
0a54caa7d4
nixos: rotate the runner registration token
All checks were successful
nixos / nixos (push) Successful in 1m14s
The token sat in the old repository history. Forgejo generated a new
one, which retires the old; the runner re-registers with it on this
deploy (the job running the deploy shows as cancelled; the next run
confirms). The old runner entry stays behind offline.

Assisted-by: Claude:opus-5-5
2026-11-17 10:40:56 +04:00
f1baa4025c
nixos: rotate Forgejo's internal token and JWT secrets, Grafana's key
Some checks failed
nixos / nixos (push) Failing after 57s
Forgejo's INTERNAL_TOKEN, JWT_SECRET and LFS_JWT_SECRET sat in the old
repository history for a year; Grafana ran on its public default
secret_key. New values, generated by Forgejo and openssl, straight into
sops. SECRET_KEY stays: changing it would break 2FA.

sops-nix does not restart anything when a secret changes. The secrets
now name the unit that reads them (Forgejo, Grafana, postgres-roles,
garage-bootstrap), so a changed value takes effect on the deploy.

Assisted-by: Claude:opus-5-5
2026-11-17 10:38:32 +04:00
c6431760bd
ci: wait for a running activation before switching a host
All checks were successful
nixos / nixos (push) Successful in 1m8s
nixos-rebuild activates through a transient unit with a fixed name. An
activation that started a long one-shot job waits for it; a deploy in
the meantime failed with "did you forget --ask-sudo-password?", twice
today. Wait up to 20 minutes for the earlier activation to finish.

Assisted-by: Claude:opus-5-5
2026-11-17 10:35:44 +04:00
b8cbf0fbf5
nixos: deploys do not kill a running backup or replica
Some checks failed
nixos / nixos (push) Failing after 1m15s
The daily replica that started at 06:09:59 was stopped 41 seconds later
by a deploy that changed its unit, and mailed a failure. Long one-shot
jobs keep running through a switch now; the next run uses the new unit.

Assisted-by: Claude:opus-5-5
2026-11-17 10:21:13 +04:00
6d9122eeff
main: the current setup only
Some checks failed
nixos / nixos (push) Has been cancelled
Both servers run NixOS. The Ansible code and the move itself leave main
for their own branches: `ansible` is the Debian/Ansible setup as it was
before the migration, `migration` keeps the plan and record, the data
scripts and everything else the move needed.

README and RESTORE describe the setup as it is now: NixOS, Podman,
sops, OpenTofu, the backup paths and hooks of the new layout. The
README carries the TODO list that MIGRATION.md had. The Forgejo
sanitising script stays, under hosts/rehearsal, with the rules for
rehearsing on restored production data in the NixOS README. Renovate
no longer looks at Ansible files.

Assisted-by: Claude:opus-5-5
2026-11-17 10:08:40 +04:00
168fd2ecb9
Merge branch 'nix'
All checks were successful
nixos / nixos (push) Successful in 34s
Assisted-by: Claude:opus-5-5
2026-11-17 10:06:16 +04:00
e27baf32ee
replica: give rclone a home directory
All checks were successful
nixos / nixos (push) Successful in 33s
rclone looked for one and logged three errors per bucket on every run,
though its remotes come from the environment.

Assisted-by: Claude:opus-5-5
2026-11-17 10:06:13 +04:00
c543214c20
Merge branch 'nix': quieter access-file alert
All checks were successful
nixos / nixos (push) Successful in 1m19s
Assisted-by: Claude:opus-5-5
2026-11-17 09:59:55 +04:00
23b9bede43
monitoring: no "Access files changed" alert for a deploy
All checks were successful
nixos / nixos (push) Successful in 35s
On NixOS an activation rewrites accounts and authorized_keys whenever
the configuration changes them, so every such deploy fired the alert
and resolved it minutes later. Each host now records when it last
activated a configuration (nixos_activation_timestamp_seconds, written
on every deploy and boot), and the rule ignores changes within 20
minutes of one. A change outside a deploy, which on these hosts can only
be a hand edit, still fires.

Assisted-by: Claude:opus-5-5
2026-11-17 09:59:51 +04:00
fd5c891f5e
Merge branch 'nix'
All checks were successful
nixos / nixos (push) Successful in 1m14s
Assisted-by: Claude:opus-5-5
2026-11-17 09:46:29 +04:00
3edcdce243
docs: point the NixOS README at the OpenTofu config and state
All checks were successful
nixos / nixos (push) Successful in 33s
Assisted-by: Claude:opus-5-5
2026-11-17 09:46:26 +04:00
bb010c0bea
Merge branch 'nix': OpenTofu naming, state and Loki buckets
Some checks failed
nixos / nixos (push) Failing after 55s
Assisted-by: Claude:opus-5-5
2026-11-17 09:42:57 +04:00
796331815d
tofu: rename from terraform, state in its own bucket, Loki buckets
All checks were successful
nixos / nixos (push) Successful in 34s
The infrastructure is applied with OpenTofu; name it so. terraform/
becomes tofu/, the files end in .tofu (OpenTofu 1.8+ prefers them), the
local variables file is secrets.auto.tfvars, and both servers carry
managed_by=opentofu (an in-place label change).

The state moved to new buckets asxpio-tofu-main/-repl, key
tofu/state/tofu.tfstate, with `tofu init -migrate-state`; a plan against
it shows no changes. The old asxpio-terraform-* buckets stay, renamed
in the config with moved blocks, until the new state has been used for
a while.

asxpio-loki-main, created by hand, is adopted with an import block, and
a new asxpio-loki-repl in fsn1 receives it in the daily replica, which
now also copies the new state bucket instead of the old one.

What keeps the Terraform name is OpenTofu's own: the `terraform {}`
block and .terraform.lock.hcl.

Assisted-by: Claude:opus-5-5
2026-11-17 09:42:53 +04:00
91a274ee34
Merge branch 'nix': Phase 2 record
Assisted-by: Claude:opus-5-5
2026-11-17 09:31:27 +04:00
e33cb4ad75
docs: asxpio-ops is on NixOS; Phase 2 record and TODO
Both servers run NixOS and deploy from main through CI. Record the ops
conversion (18.5 minutes of downtime, WireGuard back with the first test
activation, dead-man reboot not needed) and what is left: asxpio's
healthcheck branch, /old-root and the snapshots after a week, the
rehearsal server, Phase 3.

Assisted-by: Claude:opus-5-5
2026-11-17 09:31:23 +04:00
d6219bce65
Merge branch 'nix': drop the conversion's temporary access
All checks were successful
nixos / nixos (push) Successful in 1m27s
Assisted-by: Claude:opus-5-5
2026-11-17 09:21:01 +04:00
106bba969f
nixos: drop the access the ops conversion needed
All checks were successful
nixos / nixos (push) Successful in 39s
asxpio-ops runs NixOS since 2026-11-17. Remove the break-glass root
login from the admin's exit address, and on services the key Debian
ops pushed certificates with: ops now pushes with its own key from
sops, which services keeps.

Assisted-by: Claude:opus-5-5
2026-11-17 09:20:57 +04:00
3ac6937ee2
Merge branch 'nix': Ansible deploy removed for the ops conversion
Assisted-by: Claude:opus-5-5
2026-11-17 08:49:52 +04:00
81381d8438
ci: remove the Ansible deploy; asxpio-ops moves to NixOS
ops is the last host Ansible manages, and it is being converted now
(MIGRATION.md, Phase 2). A later push under ansible/ would otherwise
apply the Debian roles to the converted host. The Ansible code stays
until the clean-up.

Assisted-by: Claude:opus-5-5
2026-11-17 08:49:47 +04:00
85e3698c1e
Merge branch 'nix': podman for admins, podman-restart, ops rehearsal fixes
All checks were successful
nixos / nixos (push) Successful in 1m6s
Assisted-by: Claude:opus-5-5
2026-11-17 08:31:55 +04:00
acf5260414
nixos: never restart podman-restart on a deploy
All checks were successful
nixos / nixos (push) Successful in 40s
Its stop step is `podman stop --all`. A deploy that changes the unit,
such as a Podman update, would restart it and so stop XMPP, running CI
jobs and every app, only to start them again. It does its work at boot;
leave it alone on a switch.

Assisted-by: Claude:opus-5-5
2026-11-17 08:31:51 +04:00
c1a4080f39
docs: the ops rehearsal, its timings and the bugs it found
Assisted-by: Claude:opus-5-5
2026-11-17 08:30:33 +04:00
2ca56d595c
nixos: containers come back after a reboot; ops-data.sh fixes
All checks were successful
nixos / nixos (push) Successful in 44s
Found by rehearsing the ops conversion on a fresh test server with last
night's backup:

- After a reboot the app containers stayed stopped. Docker restarted
  them; Podman does so only through podman-restart.service, which it
  ships but does not enable. Enable it; on ops it waits for the app
  networks, Postgres and Garage.
- ops-data.sh: a fresh NixOS has no /opt, so moving the app directories
  failed; and NixOS creates an empty /var/lib/forgejo/repositories at
  boot, so the repositories were moved into it, one level too deep.
  Every part now creates its target, replaces what is empty and skips
  what already moved, so an interrupted run can be resumed.
- `forgejo admin regenerate hooks` is gone in Forgejo 17, which gives
  git its own hooks on every push; a push to a restored repository
  works with the old hook files in place. Drop the call.
- The rehearsal ops host does not push XMPP certificates: there is no
  services host behind 10.10.0.20 on the test network.

Assisted-by: Claude:opus-5-5
2026-11-17 08:27:35 +04:00
f49dd72172
nixos: podman without sudo for the admins; re-key the rehearsal ops
All checks were successful
nixos / nixos (push) Successful in 35s
`podman` run as an admin showed that user's own, empty rootless store,
so `podman ps` needed sudo while `docker ps` did not. Point CONTAINER_HOST
at the system Podman's socket, which group podman (the admins) may use.

The rehearsal ops server was rebuilt and has a new host key.

Assisted-by: Claude:opus-5-5
2026-11-17 08:10:13 +04:00
5742e06332
nixos: ops-data.sh starts no apps on a rehearsal host
All checks were successful
nixos / nixos (push) Successful in 33s
A restored /opt/<app>/.env holds production credentials: vhpbot would
log in as the production bot, asxpio-monitor would probe the internet,
the apps could send mail. On a rehearsal host the script now stops
before starting them; they are started by hand, sanitized.

Assisted-by: Claude:opus-5-5
2026-11-17 07:56:10 +04:00
3aca8a85a3
nixos: break-glass root login on ops for its conversion
All checks were successful
nixos / nixos (push) Successful in 33s
ops is the WireGuard hub. If WireGuard does not come back after the
switch, root may still log in from the admin's exit address (services'
IPv4, where the admin's traffic leaves through Xray). Root only, ops
only; the dead-man reboot covers the rest. Remove after Phase 2.

Assisted-by: Claude:opus-5-5
2026-11-17 07:51:59 +04:00
06a274a472
Merge branch 'nix': Phase 2 plan, TODO
Assisted-by: Claude:opus-5-5
2026-11-17 07:46:47 +04:00
ce8b1a678e
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
2026-11-17 07:46:42 +04:00
18ce1c7571
Merge branch 'nix': Phase 1 notes
Assisted-by: Claude:opus-5-5
2026-11-17 07:38:41 +04:00
21c58a4a66
docs: asxpio-services is on NixOS; what Phase 1 taught
Record the conversion of asxpio-services (34 minutes of downtime) and
the lessons now in the config or the runbook: the admin's uplink runs
through Xray on services, build on the host rather than from the
workstation, Podman DNS on every network, IPv6 for published ports.
Phase 2 gains two steps: switch Ansible's deploy off before ops
converts, and drop the interim certificate-push key afterwards.

Assisted-by: Claude:opus-5-5
2026-11-17 07:38:35 +04:00
347c6542f9
Merge branch 'nix'
All checks were successful
nixos / nixos (push) Successful in 1m38s
asxpio-services runs NixOS since 2026-11-17 and is deployed from here by
.forgejo/workflows/nixos.yaml from now on. asxpio-ops still runs Debian:
Ansible keeps deploying it, and the NixOS workflow skips it until its
conversion (MIGRATION.md).

Assisted-by: Claude:opus-5-5
2026-11-17 07:29:19 +04:00
72a14a1b1b
nixos: zsh for every account, security summary on login, XMPP over IPv6
All checks were successful
nixos / nixos (push) Successful in 1m3s
Every account now logs in with zsh, including ones added later, except
deploy and git: the app CI and Forgejo run commands through their login
shells. root gets the same zsh with a red prompt ending in #.

Interactive SSH logins show, under fastfetch, the host's security state
as the Grafana alerts see it, read from the local metrics files:
anything unexpected (peers, devices, accounts, ports, containers),
who is logged in, the last good backup per repository, the bucket
replica, failed units and fail2ban bans.

XMPP gets a Podman network of its own with IPv6. xmpp.asxp.io has an
AAAA record, and Podman's default network forwards published ports over
IPv4 only, where Docker on Debian did both: since the conversion, XMPP
over IPv6 was refused. Tried on the rehearsal host with a published port
on the new network, reached over IPv6 and IPv4.

Assisted-by: Claude:opus-5-5
2026-11-17 07:28:36 +04:00
8c7e725463
ci: re-run on the converted runner
Assisted-by: Claude:opus-5-5
2026-11-17 07:16:09 +04:00
4891df3105
ci: re-run after the Podman DNS fix
Assisted-by: Claude:opus-5-5
2026-11-17 07:14:49 +04:00
a80134f6ff
nixos: Podman DNS on every container network
Some checks failed
nixos / nixos (push) Failing after 1m45s
The NixOS Podman module opens DNS (aardvark-dns, port 53) on podman0
only. CI jobs and compose stacks run on networks of their own, whose
bridges are podman1, podman2 and so on, so their containers could not
resolve anything. The first CI run on the converted asxpio-services
failed this way: nix could not reach cache.nixos.org. The rehearsal
jobs had not downloaded anything, so it went unnoticed there.

Open 53 on every podman* interface. Tried on the rehearsal host with a
container on its own network.

Assisted-by: Claude:opus-5-5
2026-11-17 07:12:52 +04:00
39ed5d17b7
nixos: zsh and fastfetch for the admins
Some checks failed
nixos / nixos (push) Failing after 3m20s
zsh as on the admin's workstation (asxpi/nixOS modules/shell.nix):
completion, autosuggestions, syntax highlighting, the same history
options, key bindings and blue prompt, without what only the
workstation needs. asxpi logs in with it; deploy and root keep bash,
because the app CI and scripts run commands through their login shell.
The new-user wizard is off, since fresh homes have no ~/.zshrc.

fastfetch prints a system summary on interactive SSH logins only, so
scp, CI and `ssh host <command>` stay quiet. bat and eza come along.

Tried on the rehearsal services host.

Assisted-by: Claude:opus-5-5
2026-11-17 07:07:37 +04:00
827107be28
Merge branch 'ansible-services-handoff'
All checks were successful
deploy / ansible (push) Successful in 6m9s
Hand asxpio-services over to NixOS: Ansible manages asxpio-ops only.

Assisted-by: Claude:opus-5-5
2026-11-17 06:07:31 +04:00
ffb81b4523
ansible: hand asxpio-services over to NixOS
asxpio-services moves to NixOS (branch nix). Without this, the next
deploy from main would apply the Debian roles to it. Take it out of
every play: services_servers is empty, and the host stays in the
inventory only so that ops's roles can still read its addresses and
public IP. The xmpp_cert_sync tasks that set up the receiving end on
services through delegate_to now run only while services is managed
here; on NixOS that end is part of its configuration.

A dry run of site.yaml against production with this change: ops ok=62
changed=0, every services play skipped.

Assisted-by: Claude:opus-5-5
2026-11-17 06:00:51 +04:00
b634e50cb0
nixos: accept Debian ops's certificate push until ops converts
All checks were successful
nixos / nixos (push) Successful in 34s
Between the two conversions, services runs NixOS while ops still pushes
the XMPP certificates with the key Ansible generated there. Authorize
that key too, with the same forced command and source restriction, so
renewals keep reaching ejabberd. Remove it after the ops conversion.

Assisted-by: Claude:opus-5-5
2026-11-17 05:54:34 +04:00
ebbf458983
docs: the full migration plan; ci: deploy NixOS hosts
All checks were successful
nixos / nixos (push) Successful in 55s
MIGRATION.md is now the complete plan for moving production from
Ansible and Terraform to NixOS and OpenTofu: what was rehearsed and
how, the preparation that needs no downtime, one runbook per host with
its checks and rollback, the clean-up including the branch renames,
and the rules for running restored production data on test servers.

The NixOS workflow now deploys on main, ops first, building on each
host. It checks /etc/NIXOS before touching a host, so it skips both
servers until their conversion and cannot reach a Debian one.
known_hosts moves to the repository root for it.

Renovate learns the Nix files: version comments, the runner's job
images and flake.lock (weekly). The Ansible patterns stay until
Ansible is gone.

Assisted-by: Claude:opus-5-5
2026-11-17 05:15:16 +04:00
fa46d26f89
nixos: app stacks on Podman, unchanged
The apps keep deploying themselves: their CI copies a compose file and
a .env and runs docker compose as user deploy. `docker` is now the real
Docker CLI against rootful Podman's socket, so compose, inspect and
logs behave as before and every user sees the same containers.

Their compose files still expect the storage stack's network and the
hosts postgres and garage. On ops every container resolves those two
names to the host, where the native services run, and an empty storage
network exists, so nothing in the app repositories has to change for
the move itself.

Tried on the rehearsal pair with the real asxpio and datacenterbingo
images on the restored database and Garage (mail and IndexNow
disabled): both serve through Traefik, and a local compose build works.

One thing does need the app repositories: Podman ignores the
HEALTHCHECK of OCI-format images, which is what the CI builds, so the
deploy's wait for "healthy" would time out. Declaring the healthcheck
in each compose file fixes it, also under Docker; see MIGRATION.md.

ops-data.sh now also moves the monitoring history, Traefik's
certificates and the app directories, and pulls the images again.

Assisted-by: Claude:opus-5-5
2026-11-17 05:11:17 +04:00
2a0e7bd83a
nixos: crawler report as native units
Same script, schedule and threshold. It now mails through SMTP with the
alert account from sops instead of reading Forgejo's app.ini out of its
container, and reads Traefik's log at its new place. Forgejo's router
is forgejo@file now.

Tried on the rehearsal pair against generated GPTBot traffic.

Assisted-by: Claude:opus-5-5
2026-11-17 04:51:37 +04:00
cbf14b4b99
nixos: monitoring as native services
Every host runs node_exporter, cAdvisor (now against Podman), Alloy and
the security-metrics script, on its private address. Each service
declares its own expected ports, users and privileged containers next
to its definition, so the security baseline follows the config instead
of a separate inventory list.

On ops: Prometheus, Loki, Grafana, the blackbox prober and the Postgres
exporter, with the same scrape jobs, probes, retention, dashboards and
33 alert rules. Two rules matched container-era names and now match the
native ones: Forgejo's log is unit forgejo.service, Grafana's route is
grafana@file.

Grafana keeps its default secret_key on production, because its
database was written with it; rotating it is a separate step.

Prometheus, Grafana and Alloy come from nixos-unstable: their data is
from newer versions than 26.05 ships.

LLMNR and mDNS are off: the baseline flagged them as public listeners.

Tried on the rehearsal pair: all 28 scrape targets up, logs from both
hosts in Loki, Grafana WireGuard-only, no unexpected port, user or
container on either host.

Assisted-by: Claude:opus-5-5
2026-11-17 04:48:56 +04:00
422eb3bc6e
nixos: bucket replica and XMPP certificate sync
s3-replicate is the same rclone sync with the same delete limit, run by
the rclone package instead of its image.

The certificate push keeps its shape: ops reads Traefik's acme.json and
sends each certificate over SSH with a key that may run one command on
services, from ops only. The key is now a sops secret with its public
half in the config, instead of being generated on the host, so a
rebuilt pair works without a manual step. Tried on the rehearsal pair
with a throwaway certificate; any other command is refused.

Assisted-by: Claude:fable-5-2
2026-11-16 23:27:47 +04:00