Node bootstrap identity: AppRole + response-wrapped SecretID minted at image build #3

Open
opened 2026-08-14 01:30:11 +00:00 by ginjiruu · 3 comments
Owner

Part of lab/machine-configs#7. Rewritten 2026-11-05: the original R6/R8 plan (sops identity from baked host keys, rke2 apiserver CA via sops) is superseded by OpenBao.

Design

  • One AppRole per host.
  • At per-host image build (installer ISO / Pi SD image), the task mints a response-wrapped SecretID (single-use wrapping token, TTL ~24h; the SecretID lives in the wrapping token's cubbyhole). Images are single-use; build right before installing.
  • First boot: the node unwraps once, logs in with role_id + SecretID, and keeps the SecretID on disk bound to its address (secret_id_bound_cidrs), revocable centrally.
  • A failed unwrap means the token was used or expired: rebuild, and treat "already used" as an incident (tamper evidence).
  • The image build authenticates as the human (OIDC) with a policy that can only mint wrapped SecretIDs for host roles.
  • Later: thinks move to YubiKey PIV cert auth (follow-up issue); Pis stay on AppRole.

Done when

  • Image build mints a wrapped SecretID per host; first boot unwraps and authenticates with no human input
  • Reusing an image fails visibly
  • SecretIDs bound to host CIDRs; revocation tested
  • Applies to every host (thinks, Pis, mini-01, game, test-01 via the harness OpenBao)
Part of lab/machine-configs#7. Rewritten 2026-11-05: the original R6/R8 plan (sops identity from baked host keys, rke2 apiserver CA via sops) is superseded by OpenBao. ## Design - One AppRole per host. - At per-host image build (installer ISO / Pi SD image), the task mints a **response-wrapped SecretID** (single-use wrapping token, TTL ~24h; the SecretID lives in the wrapping token's cubbyhole). Images are single-use; build right before installing. - First boot: the node unwraps once, logs in with role_id + SecretID, and keeps the SecretID on disk bound to its address (`secret_id_bound_cidrs`), revocable centrally. - A failed unwrap means the token was used or expired: rebuild, and treat "already used" as an incident (tamper evidence). - The image build authenticates as the human (OIDC) with a policy that can only mint wrapped SecretIDs for host roles. - Later: thinks move to YubiKey PIV cert auth (follow-up issue); Pis stay on AppRole. ## Done when - [ ] Image build mints a wrapped SecretID per host; first boot unwraps and authenticates with no human input - [ ] Reusing an image fails visibly - [ ] SecretIDs bound to host CIDRs; revocation tested - [ ] Applies to every host (thinks, Pis, mini-01, game, test-01 via the harness OpenBao)
Author
Owner

LOE estimate: 3–5 days (split into two independent halves)

R6 half — ~1 day, independent, start now

  • sops.age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"] in modules/base.nix is a one-liner.
  • The real work is embedding pre-generated host keys into the installer ISO. The installer-<host> configs already embed the closure (flake.nix mkInstaller); extending modules/installer.nix to also drop the pre-generated /etc/ssh/ssh_host_ed25519_key into the ISO is the delta. Accept the documented trade-off: whoever holds the ISO holds the host key.
  • Verify with the existing libvirt test flow (task vm-run → boot installed disk): first boot should decrypt sops offline with zero manual key injection — that's the R6 acceptance box, and the VM harness we already have makes it testable.

R7/R8 half — ~2–4 days, depends on iac#40 (Vault CA)

  • Build-time generation of the shared apiserver CA (key + cert) into secrets/<cluster>.sops.yaml as apiserver-ca / apiserver-ca-crt — a human/Vault-IaC step, not per-host code.
  • The fiddly bit is R7: modules/rke2.nix must lay the CA material into /var/lib/rancher/rke2/server/tls/ (server-ca.key, server-ca.crt + support files) before rke2-server starts. This means either a preStart/ordering unit in the rke2-${role} service (rke2.nix:154) or extending rke2-install.service (rke2.nix:175) — needs a careful look at rke2's actual TLS layout so the first server bootstraps with the shared CA rather than generating its own (the exact thing R7 warns about). Realistically this needs one boot-test iteration to confirm.
  • One-time cost at CA-rotation boundaries only, not per host.

R9 note (deploy key) — small, but flagging a mismatch

  • ~0.25 day for the sops-secret wiring, plus a human step (create the read-capable deploy key on Forgejo for pull.nix).
  • Heads-up: modules/base.nix sets deploy.flakeUrl = git+ssh://git@git.animeteamspeak.moe/ginjiruu/machine-configs (base.nix:82), but the actual repo/remote is lab/machine-configs. The flake URL must be updated or nixos-pull will fail on the timer. Worth fixing in the same change.

Recommendation: start the R6 half now; hold R7/R8 until iac#40.

## LOE estimate: 3–5 days (split into two independent halves) ### R6 half — ~1 day, independent, start now - `sops.age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"]` in `modules/base.nix` is a one-liner. - The real work is **embedding pre-generated host keys into the installer ISO**. The `installer-<host>` configs already embed the closure (flake.nix `mkInstaller`); extending `modules/installer.nix` to also drop the pre-generated `/etc/ssh/ssh_host_ed25519_key` into the ISO is the delta. Accept the documented trade-off: whoever holds the ISO holds the host key. - Verify with the existing libvirt test flow (`task vm-run` → boot installed disk): first boot should decrypt sops offline with zero manual key injection — that's the R6 acceptance box, and the VM harness we already have makes it testable. ### R7/R8 half — ~2–4 days, depends on iac#40 (Vault CA) - Build-time generation of the shared apiserver CA (key + cert) into `secrets/<cluster>.sops.yaml` as `apiserver-ca` / `apiserver-ca-crt` — a human/Vault-IaC step, not per-host code. - The fiddly bit is R7: `modules/rke2.nix` must lay the CA material into `/var/lib/rancher/rke2/server/tls/` (`server-ca.key`, `server-ca.crt` + support files) **before** `rke2-server` starts. This means either a `preStart`/ordering unit in the `rke2-${role}` service (rke2.nix:154) or extending `rke2-install.service` (rke2.nix:175) — needs a careful look at rke2's actual TLS layout so the first server bootstraps *with* the shared CA rather than generating its own (the exact thing R7 warns about). Realistically this needs one boot-test iteration to confirm. - One-time cost at CA-rotation boundaries only, not per host. ### R9 note (deploy key) — small, but flagging a mismatch - ~0.25 day for the sops-secret wiring, plus a human step (create the read-capable deploy key on Forgejo for `pull.nix`). - **Heads-up:** `modules/base.nix` sets `deploy.flakeUrl = git+ssh://git@git.animeteamspeak.moe/ginjiruu/machine-configs` (base.nix:82), but the actual repo/remote is `lab/machine-configs`. The flake URL must be updated or `nixos-pull` will fail on the timer. Worth fixing in the same change. **Recommendation:** start the R6 half now; hold R7/R8 until iac#40.
ginjiruu changed title from 003 — R6/R8: first-boot sops identity + build-time key pre-generation to Node bootstrap identity: AppRole + response-wrapped SecretID minted at image build 2026-11-05 16:59:35 +00:00
Author
Owner

2026-11-11 progress.

Built:

  • Host side: modules/openbao-agent.nix (c0b2edb), enabled on think-01..03 + pi-01..04 via profiles-think-node. openbao-identity unwraps the wrapped SecretID once, keeps it 0400, deletes the wrapping file. INCIDENT only when OpenBao rejects the token (used/expired/revoked). Unreachable or TLS trouble is a retry and leaves the token unused. Not enrolled = ExecCondition skip, never a failed unit (a failed unit at switch time would trip deploy-revert). openbao-render runs bao agent once (exit_after_auth, exit_on_err) from a timer, not during switch, so an OpenBao outage can't roll a deploy back.
  • OpenBao side: lab/iac#57. Mount approle-hosts (separate from the hand-made runner approle, ADR 0003), a role per host with role_id = hostname, SecretID + token bound to the host /32, SecretID ttl 0, host- policies, host-enroller policy (wrapped-only minting).
  • Enrollment: task bao:enroll HOST=<h> [FORCE=1] mints the wrapped SecretID with the admin's login and pipes it over ssh stdin.
  • VM test: checks.openbao-agent-approle covers not enrolled (skip), unreachable (no incident, token kept), first boot, restart, reuse (INCIDENT), revocation (invalid secret ID), CIDR (unauthorized by CIDR), the identity template, and nothing secret in the store.

Rolled out: all 7 hosts show the timer armed, identity skipped with the enroll hint, 0 failed units.

Not yet: enrolling the 7 hosts (needs an admin login), image-build minting (installer/SD path, with #13), mini-01/game-01 (not on comin yet; their machine-configs IPs aren't what OpenBao sees).

2026-11-11 progress. Built: - **Host side:** `modules/openbao-agent.nix` (c0b2edb), enabled on think-01..03 + pi-01..04 via profiles-think-node. openbao-identity unwraps the wrapped SecretID once, keeps it 0400, deletes the wrapping file. INCIDENT only when OpenBao rejects the token (used/expired/revoked). Unreachable or TLS trouble is a retry and leaves the token unused. Not enrolled = ExecCondition skip, never a failed unit (a failed unit at switch time would trip deploy-revert). openbao-render runs bao agent once (exit_after_auth, exit_on_err) from a timer, not during switch, so an OpenBao outage can't roll a deploy back. - **OpenBao side:** lab/iac#57. Mount approle-hosts (separate from the hand-made runner approle, ADR 0003), a role per host with role_id = hostname, SecretID + token bound to the host /32, SecretID ttl 0, host-<name> policies, host-enroller policy (wrapped-only minting). - **Enrollment:** `task bao:enroll HOST=<h> [FORCE=1]` mints the wrapped SecretID with the admin's login and pipes it over ssh stdin. - **VM test:** checks.openbao-agent-approle covers not enrolled (skip), unreachable (no incident, token kept), first boot, restart, reuse (INCIDENT), revocation (invalid secret ID), CIDR (unauthorized by CIDR), the identity template, and nothing secret in the store. Rolled out: all 7 hosts show the timer armed, identity skipped with the enroll hint, 0 failed units. Not yet: enrolling the 7 hosts (needs an admin login), image-build minting (installer/SD path, with #13), mini-01/game-01 (not on comin yet; their machine-configs IPs aren't what OpenBao sees).
Author
Owner

2026-11-11: all 7 comin hosts enrolled (task bao:enroll HOST=<h> FORCE=1, now scripts/bao-enroll.sh).

Verified on every host: /var/lib/openbao-agent/secret-id 0400, no wrapping file left, /run/openbao-agent/identity = its own role name, 0 failed units, render timer active. A second login from the kept SecretID (pi-03, identity file removed first) re-rendered with result=success.

The first enrollment attempt died after minting: Task's shell strips backslash escapes even in quoted heredocs. Its SecretIDs on think-01/02 were destroyed by --force; the wrapping tokens never left the workstation and expired unread.

Done-when status:

  • First boot unwraps and authenticates with no human input (VM test + live on 7 hosts)
  • Reusing a wrapping token fails visibly (INCIDENT, VM test)
  • SecretIDs bound to host CIDRs; revocation tested (VM test: "invalid role or secret ID", "unauthorized by CIDR restrictions")
  • Image build mints the wrapped SecretID: installer/SD path, built with #13
  • Every host: thinks + Pis done; mini-01/game-01 when they join comin; test-01 via the harness OpenBao (#13)
2026-11-11: all 7 comin hosts enrolled (`task bao:enroll HOST=<h> FORCE=1`, now `scripts/bao-enroll.sh`). Verified on every host: `/var/lib/openbao-agent/secret-id` 0400, no wrapping file left, `/run/openbao-agent/identity` = its own role name, 0 failed units, render timer active. A second login from the kept SecretID (pi-03, identity file removed first) re-rendered with result=success. The first enrollment attempt died after minting: Task's shell strips backslash escapes even in quoted heredocs. Its SecretIDs on think-01/02 were destroyed by `--force`; the wrapping tokens never left the workstation and expired unread. Done-when status: - [x] First boot unwraps and authenticates with no human input (VM test + live on 7 hosts) - [x] Reusing a wrapping token fails visibly (INCIDENT, VM test) - [x] SecretIDs bound to host CIDRs; revocation tested (VM test: "invalid role or secret ID", "unauthorized by CIDR restrictions") - [ ] Image build mints the wrapped SecretID: installer/SD path, built with #13 - [ ] Every host: thinks + Pis done; mini-01/game-01 when they join comin; test-01 via the harness OpenBao (#13)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/machine-configs#3
No description provided.