- Jinja 52.2%
- Shell 42.8%
- Python 5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PVUe4g65L7UnUVqHmQp7kG |
||
| .forgejo/workflows | ||
| bin | ||
| docs | ||
| examples/infra | ||
| extensions/molecule | ||
| inventory | ||
| playbooks | ||
| schemas | ||
| .ansible-lint | ||
| .gitignore | ||
| .gitleaks.toml | ||
| .pre-commit-config.yaml | ||
| .yamllint | ||
| ansible.cfg | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| README.md | ||
| requirements.yml | ||
| ruff.toml | ||
| SECURITY.md | ||
infrastructure
Site repository of the belowtoxic infrastructure: Hetzner dedicated servers running KVM guests (libvirt VMs and Firecracker micro-VMs - Flatcar, Ubuntu, Debian) and Hetzner Cloud servers.
This repository is public and contains no environment data. Hosts and their addresses come from the Hetzner APIs; guests, address assignments, exposure rules and secrets come from OpenBao. See docs/security.md.
Layout
| Path | |
|---|---|
inventory/ |
Inventory plugin configurations only (OpenBao, Hetzner Robot, Hetzner Cloud) |
playbooks/ |
anchor.yml (the trust anchor: WireGuard hub and OpenBao), idp.yml (the identity provider: Authentik on Flatcar), monitoring.yml (the monitoring host: Prometheus, Thanos, Loki, Grafana on Flatcar), backup.yml (the backup coordinator: restic pulls the sources over the backup network), mail.yml (a mail server: Stalwart on Flatcar), bootstrap_dedicated.yml (reinstall, destructive), hypervisor.yml, guests.yml, site.yml (both), openbao_config.yml |
schemas/ |
JSON Schemas of the intent documents stored in OpenBao |
examples/infra/ |
Example intent documents (documentation addresses only) |
bin/bao-login |
Interactive OpenBao login (OIDC, also from a VM or over SSH) |
bin/bao-delegate |
Hand a short-lived token to a VM or agent that cannot log in itself |
bin/ssh-cert |
Short-lived SSH certificate for the ansible login |
bin/infra-data, bin/wg-peer, bin/bao-init, bin/bao-unseal, bin/bao-root, bin/bao-snapshot-pull, bin/backup, bin/idp-recover, bin/hcloud-flatcar-image |
Wrappers around infractl (config, wg, bao init|unseal|root|snapshot-pull, backup, idp recover, image flatcar), run without a context: for the playbooks, the test scenarios and the runbooks |
extensions/molecule/site/ |
The site playbooks end to end in a QEMU lab |
extensions/molecule/anchor/ |
anchor.yml (host part) and the key ceremony over the VPN, on Flatcar |
extensions/molecule/identity/ |
idp.yml (host part) on Flatcar, then bin/backup backs it up and restores it |
extensions/molecule/monitoring/ |
monitoring.yml (host part) on Flatcar: both tunnels, the stack, the gateway, Grafana on the admin address |
extensions/molecule/mail/ |
mail.yml (host part) on Flatcar: Stalwart with Pebble and a relay that requires STARTTLS, the secrets from OpenBao, a member of both networks, the metrics password rotated |
extensions/molecule/backup/ |
backup.yml (host part) and a source on Flatcar: the backup network, the forced command, a snapshot pulled and read back |
extensions/molecule/openbao-tasks/ |
the task files that talk to OpenBao (bao_generate, approle_prune) against a throwaway OpenBao on the controller - no VMs |
docs/ |
Architecture, data model, security model, decisions, runbooks |
requirements.yml |
Collections, pinned by tag/version |
Getting started
git clone https://git.belowtoxic.cloud/belowtoxic-ansible/toolchain.git ../toolchain
eval "$(../toolchain/bin/bt-ci-setup)" # pinned toolchain; prints exports, so: eval
ansible-galaxy collection install -r requirements.yml -p collections
uv tool install git+https://git.belowtoxic.cloud/belowtoxic-ansible/infractl.git@v0.7.0 # INFRACTL_REF in ci.yml
bt-ci doctor # toolchain version and PATH, hvac, collections, login
export VAULT_ADDR=https://bao.example.com:8200 # in your shell profile, not here
bin/bao-login
ansible-inventory --graph
Updating later: git -C ../toolchain pull && git pull, the eval again,
the collection install with --force, and infractl at the pinned version
(bin/_infractl warns when the installed one differs).
The helpers' tests are in infractl's repository and run there against this one (schemas, examples, the WireGuard planner).
A new infrastructure starts with the trust anchor: docs/runbooks/first-run.md. Each operator workstation then follows docs/runbooks/first-time-setup.md - the inventory needs credentials that only exist after those steps.
Data model
docs/data-model.md describes the documents; the
schemas in schemas/ are authoritative and bin/infra-data validate checks
them plus the rules that span documents (unique addresses, hosts exist, NAT
port collisions, ...).
Development
bt-ci lint # pre-commit: leak checks, yamllint, ansible-lint, examples, ...
bt-ci molecule site # the playbooks end to end (needs /dev/kvm)
The site scenario runs the playbooks the way an operator does: a
throwaway OpenBao holds the intent (validated against schemas/), the
real inventory plugin reads it, a lab SSH CA signs the login certificate,
and an Ubuntu 24.04 VM behind a fake Hetzner router plays the freshly
installed server. bootstrap_dedicated.yml (without installimage),
hypervisor.yml and guests.yml run in turn, then site.yml again must
change nothing. The router doubles as the WireGuard hub: the server
becomes a site and is reached over the tunnel. Verify checks that only
certificate logins work, logs into a Debian and a Flatcar guest and probes
their exposure from the router. Host variables make that possible:
infra_robot_network (preset Robot API data), infra_connect_port
(connection port behind a port forward), infra_input_rules (extra nft
input rules) and infra_ssh_jump ("": connect directly instead of
through the anchor, see inventory/group_vars/all.yml).
The anchor scenario runs playbooks/anchor.yml (without the Hetzner
Cloud play) on a Flatcar VM, joins a Debian "laptop" to the VPN and runs
bin/bao-init and bin/bao-unseal over it, checks that only WireGuard
answers on the public address, and locks itself out on purpose to see the
firewall's dead-man switch undo it.
The identity scenario runs playbooks/idp.yml (without the Hetzner
Cloud play) twice against a Flatcar VM and a throwaway OpenBao: the
secrets are generated once, the second run changes nothing, Authentik
answers through Caddy (certificates from Pebble) with OpenBao's client
secret from OpenBao, and bin/backup backs the IdP up into a restic
repository and restores it.
The monitoring scenario runs playbooks/monitoring.yml (without the
Hetzner Cloud play) twice against a Flatcar VM and a throwaway OpenBao:
Grafana's secrets are generated once, both WireGuard keys are recorded in
the intent, the host's own metrics arrive through its gateway, the probes
from outside and the dead man's switch work, Grafana answers on the admin
address with the IdP login, and nothing but the gateway and Grafana
listens off loopback. The anchor and identity scenarios have a monitoring
host registered: both join its network and run Alloy.
The backup scenario runs playbooks/backup.yml (without the Hetzner
Cloud play) against a Flatcar coordinator, a Flatcar source made one the
way the anchor is, and a throwaway OpenBao: the coordinator first (its keys
recorded), the source (it joins the backup network and gets the backup
user), the coordinator again, which pulls the source's stream into a
restic repository (versitygw for Wasabi) and records its success; a last
run changes nothing. The source accepts only the coordinator's key from its
tunnel address, and only the stream runs; nothing reaches the coordinator
over the tunnel. The anchor and identity scenarios have a coordinator
registered: both become sources.
The mail scenario runs playbooks/mail.yml (without the Hetzner Cloud
play) against a Flatcar server and a throwaway OpenBao twice - the second
run changes nothing. Pebble issues the certificate (TLS-ALPN-01), Mailpit
plays the relay and requires STARTTLS with a certificate from a CA made in
the test. The administrator's initial password from OpenBao sends a message
out through the relay; the metrics answer only with the generated password,
which the side effect rotates; the server is a member of the monitoring and
backup networks, its firewall open for mail and HTTPS only.
License
MIT, see LICENSE.