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
119 lines
4.1 KiB
Markdown
119 lines
4.1 KiB
Markdown
# ASXP.IO Infrastructure
|
|
|
|
Hetzner Cloud infrastructure, managed with [OpenTofu](https://opentofu.org)
|
|
(`tofu`; the dev shell of `../nixos` has it). The files are plain HCL and
|
|
the state lives in Object Storage (`asxpio-tofu-main`, key
|
|
`tofu/state/tofu.tfstate`); `.terraform.lock.hcl` (OpenTofu keeps that
|
|
name) pins the providers and is committed. Files end in `.tofu`.
|
|
|
|
## Servers
|
|
|
|
- **asxpio-ops** (CX23: 2 vCPU, 4GB) - Traefik, Forgejo, app stacks
|
|
- **asxpio-services** (CX43: 8 vCPU, 16GB) - CI runner, game servers, SillyTavern
|
|
|
|
Both have delete and rebuild protection. Hetzner's server backups are
|
|
off; restic backs up the data instead (see ../README.md).
|
|
|
|
Both servers carry `prevent_destroy` and ignore changes to `user_data`,
|
|
`image` and `ssh_keys`, because hcloud would replace a running server
|
|
when those change.
|
|
|
|
A new server boots Debian and converts itself to NixOS: its cloud-init
|
|
(`cloud-init/nixos.yaml.tftpl`, one template for both) runs a pinned
|
|
nixos-infect and reboots into a bare NixOS, about three minutes after
|
|
creation. The system's configuration then comes from `../nixos`. Edits
|
|
to the template reach a server only when it is created or rebuilt in
|
|
place; both procedures are in `../nixos/README.md`.
|
|
|
|
## Storage (S3-compatible)
|
|
|
|
**OpenTofu state:**
|
|
- asxpio-tofu-main (hel1), replicated daily to asxpio-tofu-repl (fsn1)
|
|
- asxpio-terraform-main / -repl: where the state lived until 2026-11-17;
|
|
kept for now (`legacy_state_*`), to be emptied and removed
|
|
|
|
**Backups:**
|
|
- asxpio-backups-main (hel1), replicated to asxpio-backups-repl (fsn1),
|
|
except `restic/` (restic writes both itself)
|
|
|
|
**Logs:**
|
|
- asxpio-loki-main (hel1): Loki's chunks, replicated to asxpio-loki-repl
|
|
(fsn1)
|
|
|
|
The daily replica runs on asxpio-services
|
|
(`nixos/hosts/asxpio-services/replica.nix`).
|
|
|
|
## DNS
|
|
|
|
`dns.tofu` holds the zones asxp.io and czsk.it (Hetzner DNS, this project)
|
|
and every record set except SOA and NS. Our servers' records reference
|
|
`hcloud_server`, so moving a service is one edit.
|
|
|
|
All record sets are change-protected except the test XMPP servers'
|
|
(`prosody`, `ejabberd`, `anotherim`); both zones are delete-protected.
|
|
To change a protected record set, apply twice: first with the set
|
|
excluded from protection, then with the new value. Hand edits in the
|
|
console show up as drift in `tofu plan`.
|
|
|
|
## Network
|
|
|
|
- VPC: 10.10.0.0/20
|
|
- WireGuard VPN: 10.20.0.0/24
|
|
- IPv4 + IPv6 enabled
|
|
|
|
## Cost
|
|
|
|
| Item | Monthly |
|
|
|------|---------|
|
|
| ops CX23 | €3.99 |
|
|
| services CX43 | €11.99 |
|
|
| IPv4 (2x) | €1.00 |
|
|
| S3 (1TB) | €6.49 |
|
|
| S3 1TB Traffic | €1.00 |
|
|
| **Total** | **€24.47** |
|
|
|
|
Prices are net, as billed in November 2026 (0% VAT).
|
|
|
|
Both servers are billed below the current list price (€5.49 and €15.99).
|
|
A deleted and recreated server gets the list price, so reinstall or
|
|
rebuild in place and never recreate. `prevent_destroy` and Hetzner's
|
|
delete protection guard against it.
|
|
|
|
## Setup
|
|
|
|
```bash
|
|
cp secrets.auto.tfvars.example secrets.auto.tfvars # token and Object Storage keys
|
|
export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... # state bucket
|
|
tofu init
|
|
tofu plan
|
|
tofu apply
|
|
```
|
|
|
|
### First run: the state bucket
|
|
|
|
The state bucket `asxpio-tofu-main` is itself a resource here
|
|
(`s3.tofu`), so in a new project `tofu init` fails: the backend points at
|
|
a bucket that doesn't exist yet. Bootstrap it once with local state:
|
|
|
|
```bash
|
|
# 1. comment out the backend "s3" block in providers.tofu
|
|
tofu init
|
|
tofu apply -target=minio_s3_bucket.state_main # just the bucket
|
|
# 2. restore the backend block
|
|
tofu init -migrate-state # copies local state into the bucket
|
|
rm terraform.tfstate* # S3 holds it now
|
|
tofu apply # everything else
|
|
```
|
|
|
|
The bucket holds the state that manages it, so it carries
|
|
`prevent_destroy`: a plan that would delete it fails instead.
|
|
|
|
## Files
|
|
|
|
- `servers.tofu` - Server definitions, cloud-init variables
|
|
- `s3.tofu` - Object Storage buckets
|
|
- `vpc.tofu` - Private network
|
|
- `firewall.tofu` - Security rules
|
|
- `dns.tofu` - DNS zones and records
|
|
- `keys.tofu` - SSH keys
|
|
- `cloud-init/nixos.yaml.tftpl` - first boot: Debian to NixOS
|