ci: check that OpenTofu and Ansible agree on ingress ports and subnet #612

Stängd
öppnade 2026-10-08 21:12:23 +00:00 av supernaut · 0 kommentarer
Ägare

What

The perimeter is defined twice. OpenTofu has ingress_tcp_ports, admin_ssh_port and the subnet (opentofu/variables.tofu:77-81,175-187,250-260). Ansible has admin_ssh_port, git_ssh_port, bitborg_subnet_cidr and monitoring_ingestion_ports (ansible/group_vars/all/vars.yml:147-173,414, group_vars/monitoring.yml:17-23). The tofu comment says the list is the single source of truth and to keep both in sync. Nothing checks it.

Why

A one-sided change locks the operator out, and CI stays green.

Failing case

Set admin_ssh_port: 2223 in Ansible only. nftables allows 2223. The security group has no rule for it and keeps the stale 2222 rule. Ansible loses SSH after the sshd cutover. The same applies to git_ssh_port (the group keeps opening 22), to monitoring_ingestion_ports (8428 and 3100) and to the 192.168.42.0/24 subnet.

Fix

Add scripts/check-ingress-parity.py. It reads the tofu defaults and the Ansible values and asserts the same ports and subnet. Wire it into ci.yml for changes under opentofu/ or ansible/group_vars/. Give it a self-test that proves it can fail, like check-alert-rules.py.

Done when

  • The script fails when either side changes alone.
  • It runs in CI.
  • The "single source of truth" comments describe the real mechanism.

Plan outline

  1. Decide the single source: parse both files, or have one side read the other (for example yamldecode of two scalars).
  2. List what must match: ports 22, 2222, 80, 443, ingestion ports 8428 and 3100, subnet.
  3. Write scripts/check-ingress-parity.py with a self-test.
  4. Wire it into ci.yml behind the same change detection as the other checks.
  5. Fix the comments in variables.tofu and vars.yml.
## What The perimeter is defined twice. OpenTofu has `ingress_tcp_ports`, `admin_ssh_port` and the subnet (`opentofu/variables.tofu:77-81,175-187,250-260`). Ansible has `admin_ssh_port`, `git_ssh_port`, `bitborg_subnet_cidr` and `monitoring_ingestion_ports` (`ansible/group_vars/all/vars.yml:147-173,414`, `group_vars/monitoring.yml:17-23`). The tofu comment says the list is the single source of truth and to keep both in sync. Nothing checks it. ## Why A one-sided change locks the operator out, and CI stays green. ## Failing case Set `admin_ssh_port: 2223` in Ansible only. nftables allows 2223. The security group has no rule for it and keeps the stale 2222 rule. Ansible loses SSH after the sshd cutover. The same applies to `git_ssh_port` (the group keeps opening 22), to `monitoring_ingestion_ports` (8428 and 3100) and to the 192.168.42.0/24 subnet. ## Fix Add `scripts/check-ingress-parity.py`. It reads the tofu defaults and the Ansible values and asserts the same ports and subnet. Wire it into `ci.yml` for changes under `opentofu/` or `ansible/group_vars/`. Give it a self-test that proves it can fail, like `check-alert-rules.py`. ## Done when - [ ] The script fails when either side changes alone. - [ ] It runs in CI. - [ ] The "single source of truth" comments describe the real mechanism. ## Plan outline 1. Decide the single source: parse both files, or have one side read the other (for example `yamldecode` of two scalars). 2. List what must match: ports 22, 2222, 80, 443, ingestion ports 8428 and 3100, subnet. 3. Write `scripts/check-ingress-parity.py` with a self-test. 4. Wire it into `ci.yml` behind the same change detection as the other checks. 5. Fix the comments in `variables.tofu` and `vars.yml`.
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#612
Ingen beskrivning angiven.