Skip to content

Declarative permanent infra (OpenTofu + Ansible) & gatewayd systemd wiring - #73

Merged
rlrs merged 2 commits into
mainfrom
declarative-infra
Dec 2, 2026
Merged

rlrs merged 2 commits into
mainfrom
declarative-infra

Conversation

@rlrs

@rlrs rlrs commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Replaces all 6 legacy imperative Gateway/Store/Hetzner installers (~1,900 LOC deleted) with a clean two-layer declarative deployment workflow (supporting Hetzner Cloud, UCloud, and future Ubuntu backends) while leaving ephemeral worker autoscaling untouched:

  1. Wire ucloud-gatewayd into systemd & gateway-reconcile

    • Packaged sandboxes/systemd/ucloud-sandbox-gatewayd.service and added it to SYSTEMD_UNIT_NAMES.
    • Updated reconcile_gateway_services() in sandboxes/systemd.py to automatically enable and restart ucloud-sandbox-gatewayd.service when installed, with unit tests in tests/test_systemd.py.
  2. Hetzner Cloud OpenTofu module (infra/hetzner/)

    • Declaratively manages the private network, subnet, default egress route, bootstrap SSH key, worker/gateway firewalls, protected Primary IPv4s (auto_delete = false, prevent_destroy = true), protected 1 TB chunk-store volume, and Gateway/Store VMs (default cpx32).
    • Verified with tofu validate, tofu fmt -check, and a live non-destructive import of all 14 Hetzner resources (0 to add, 0 to destroy).
  3. Provider-agnostic Ansible roles & playbooks (infra/ansible/)

    • Pure ansible.builtin.* (zero external Galaxy collections): common, gateway, store, observability (fully native collector.yaml, tempo.yaml, scrape.yaml, Grafana provisioning, dashboard, CLI, and bounded systemd units), ops, plus optional gateway_nat and gateway_ingress (fully native Nginx TLS + Grafana /grafana/ops/ auth proxy + Certbot renewal) overlays toggled per provider via inventory vars.
    • Example inventories for both Hetzner (inventories/hetzner.example/) and UCloud (inventories/ucloud.example/); real environment state stays outside Git under .deploy/ (gitignored).
    • Includes site.yml (full convergence + cross-host chunk-index token SHA-256 verification), upgrade.yml (fast release rollout), and scripts/release/build_release.py (digest-pinned wheel + ucloud-gatewayd + ucloud-chunk-serve).
  4. Deleted all 6 legacy imperative installers & updated tests/docs

    • Removed scripts/ops/setup_hetzner_foundation.py, install_hetzner_gateway.sh, install_ucloud_gateway.sh, install_ucloud_ops.sh, install_ucloud_observability_stack.sh, and configure_hetzner_sdk_ingress.sh (~1,900 LOC removed).
    • Replaced legacy bash-inspection tests with tests/test_declarative_infra.py, lowered tests/test_rules_baseline.json, and updated docs/operations.md.

Verification

  • scripts/check.sh: PASS (ruff, 200 Python modules, Go managed_process + chunk_serve + gatewayd, Rust ucloud-noded, wheel build, and all 133 SDK tests).
  • tofu validate & tofu fmt -check in infra/hetzner/: PASS; live 14-resource import verified (0 to add, 0 to destroy).
  • ansible-playbook --syntax-check: PASS for Hetzner site.yml, UCloud site.yml, and upgrade.yml.
  • Live convergence on the cpx32 Hetzner cluster (site.yml), followed by site.yml --check --diff: changed=0, failed=0 (sandboxes-gateway: ok=61, sandboxes-store: ok=15, cross-host chunk-index token assertions passed).
  • scripts/release/build_release.py: built wheel + static Linux ucloud-gatewayd & ucloud-chunk-serve + SHA-256 manifest.json.

@rlrs
rlrs merged commit 3a8ceee into main Dec 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant