OpenBao: apply the vault IaC root to OpenBao via tofu-controller (fresh state, import hand-made config) #47

Closed
opened 2026-11-07 22:18:38 +00:00 by ginjiruu · 5 comments
Owner

Part of lab/machine-configs#7. Feeds lab/clusters#1669 ("Vault IaC roots (tofu-controller) retargeted at OpenBao").

OpenBao now runs on think-01..03 (lab/machine-configs#8, closed 2026-11-07). The iac/vault root (applied by tofu-controller on mini, clusters/mini/iac/vault-config.yaml) still targets the mini Vault. Applying the same root against OpenBao brings the non-secret config up to spec: Kanidm JWT/OIDC logins, superadmin identity groups and aliases, the secret KV mount, the per-app policy module, manager/reader/admin policies.

Plan

  • Fresh state. A second Terraform object (openbao-config) on the same root with its own state. Reusing the Vault state makes tofu believe resources exist that OpenBao never had.
  • Import what was made by hand on 2026-11-07 with import blocks: mount pki-infra (pki, issuers imported from the ceremony), mount infra (kv-v2), policy raft-snapshot, auth kubernetes-think + its config + role raft-snapshot.
  • Drop pki-apiserver (vault_pki_secret_backend_root_cert with an internal ed25519 root): it contradicts the offline root on hardware (#9). Replaced by pki-k3s-<cluster> intermediates signed by the root token.
  • Runner access. tofu-controller on mini reaches https://10.10.1.21-23:8200 (lab root CA in the runner's trust, VAULT_CACERT). Bootstrap AppRole (ADR 0003) recreated in OpenBao by hand once with the root token; its role_id/secret_id go into the object's varsFrom Secret.
  • Provider. hashicorp/vault 5.6.0 against OpenBao (Vault 1.14 API). Check every resource type in the root plans clean against 2.7.2 before the first apply.
  • Applies only through tofu-controller (hard rule: never local apply/destroy).

Done when

  • openbao-config Terraform object Ready on mini, plan clean
  • Hand-made 2026-11-07 objects imported, not recreated
  • Kanidm OIDC login to OpenBao works for the superadmin group (CLI and web)
  • Root token revoked after that login is proven
  • Secret values not in tofu (KV data migration stays with lab/clusters#1669)
Part of lab/machine-configs#7. Feeds lab/clusters#1669 ("Vault IaC roots (tofu-controller) retargeted at OpenBao"). OpenBao now runs on think-01..03 (lab/machine-configs#8, closed 2026-11-07). The `iac/vault` root (applied by tofu-controller on mini, `clusters/mini/iac/vault-config.yaml`) still targets the mini Vault. Applying the same root against OpenBao brings the non-secret config up to spec: Kanidm JWT/OIDC logins, superadmin identity groups and aliases, the `secret` KV mount, the per-app policy module, manager/reader/admin policies. ## Plan - **Fresh state.** A second Terraform object (`openbao-config`) on the same root with its own state. Reusing the Vault state makes tofu believe resources exist that OpenBao never had. - **Import what was made by hand on 2026-11-07** with `import` blocks: mount `pki-infra` (pki, issuers imported from the ceremony), mount `infra` (kv-v2), policy `raft-snapshot`, auth `kubernetes-think` + its config + role `raft-snapshot`. - **Drop `pki-apiserver`** (`vault_pki_secret_backend_root_cert` with an internal ed25519 root): it contradicts the offline root on hardware (#9). Replaced by `pki-k3s-<cluster>` intermediates signed by the root token. - **Runner access.** tofu-controller on mini reaches `https://10.10.1.21-23:8200` (lab root CA in the runner's trust, `VAULT_CACERT`). Bootstrap AppRole (ADR 0003) recreated in OpenBao by hand once with the root token; its role_id/secret_id go into the object's varsFrom Secret. - **Provider.** `hashicorp/vault` 5.6.0 against OpenBao (Vault 1.14 API). Check every resource type in the root plans clean against 2.7.2 before the first apply. - **Applies only through tofu-controller** (hard rule: never local apply/destroy). ## Done when - [ ] `openbao-config` Terraform object Ready on mini, `plan` clean - [ ] Hand-made 2026-11-07 objects imported, not recreated - [ ] Kanidm OIDC login to OpenBao works for the superadmin group (CLI and web) - [ ] Root token revoked after that login is proven - [ ] Secret values not in tofu (KV data migration stays with lab/clusters#1669)
Author
Owner

Two constraints found while writing the handoff (2026-11-07):

  • Separate root, not the shared ./vault path. import blocks in iac/vault would also run under the existing vault-config object against the mini Vault and fail there. Create iac/openbao (reuse vault/modules/app_secrets, copy what still applies, drop pki.tf), and point the new Terraform object at ./openbao. iac/vault stays untouched until the mini Vault is retired (lab/clusters#1669).
  • No auto-approve on the first runs. clusters/mini/iac/vault-config.yaml has approvePlan: "auto". The new openbao-config object starts with plan-only (no approvePlan, or a plan id to approve by hand), so the first plan, which must show only imports and creates, is reviewed before anything is written to OpenBao. Switch to auto once a plan is clean.
Two constraints found while writing the handoff (2026-11-07): - **Separate root, not the shared `./vault` path.** `import` blocks in `iac/vault` would also run under the existing `vault-config` object against the mini Vault and fail there. Create `iac/openbao` (reuse `vault/modules/app_secrets`, copy what still applies, drop `pki.tf`), and point the new Terraform object at `./openbao`. `iac/vault` stays untouched until the mini Vault is retired (lab/clusters#1669). - **No auto-approve on the first runs.** `clusters/mini/iac/vault-config.yaml` has `approvePlan: "auto"`. The new `openbao-config` object starts with plan-only (no `approvePlan`, or a plan id to approve by hand), so the first plan, which must show only imports and creates, is reviewed before anything is written to OpenBao. Switch to `auto` once a plan is clean.
Author
Owner

Bootstrap AppRole created on OpenBao, 2026-11-11 (ADR 0003: bootstrap-only, never declared or imported by tofu). Run once by hand with the root token from arch-ws; completed successfully.

export BAO_ADDR=https://10.10.1.21:8200
export BAO_CACERT=~/Projects/Personal/lab/machine-configs/pki/root.crt
read -rsp "Root token: " BAO_TOKEN; echo; export BAO_TOKEN
B="nix shell nixpkgs#openbao -c bao"

# ADR 0003: runner AppRole is bootstrap-only, never in tofu
$B policy write tofu-runner - <<'EOF'
path "*" { capabilities = ["create","read","update","delete","list","sudo"] }
EOF
$B auth enable approle
$B write auth/approle/role/tofu-runner \
    token_policies=tofu-runner token_ttl=1h token_max_ttl=2h \
    secret_id_bound_cidrs=10.44.0.0/16 token_bound_cidrs=10.44.0.0/16

ROLE_ID=$($B read -field=role_id auth/approle/role/tofu-runner/role-id)
SECRET_ID=$($B write -f -field=secret_id auth/approle/role/tofu-runner/secret-id)
OIDC=$(kubectl --context mini -n flux-system get secret vault-config-vars -o jsonpath='{.data.oidc_client_secret}' | base64 -d)

kubectl --context mini -n flux-system create secret generic openbao-config-vars \
  --from-literal=approle_role_id="$ROLE_ID" \
  --from-literal=approle_secret_id="$SECRET_ID" \
  --from-literal=oidc_client_secret="$OIDC"
unset BAO_TOKEN ROLE_ID SECRET_ID OIDC

Notes:

  • 10.44.0.0/16 is mini's pod CIDR. If runner traffic reaches the thinks SNATed to the node IP, logins fail; drop the bindings or use mini's node IP.
  • openbao-config-vars is a hand-made Secret on mini, not in git. A mini rebuild needs a fresh secret_id: re-run the last block (new secret-id, recreate the Secret).
  • auth/approle, policy tofu-runner and role tofu-runner must never appear in the vault root.

State of the rest, same day: flux bc810652 (trust-manager Bundle lab-root-ca into flux-system), flux 42a534c5 (vault-config suspended, openbao-config plan-only at https://10.10.1.21:8200), iac b0c3fb7 (import blocks, pki.tf dropped). DNS deferred to #50, public UI to #51.

Bootstrap AppRole created on OpenBao, 2026-11-11 (ADR 0003: bootstrap-only, never declared or imported by tofu). Run once by hand with the root token from arch-ws; completed successfully. ```bash export BAO_ADDR=https://10.10.1.21:8200 export BAO_CACERT=~/Projects/Personal/lab/machine-configs/pki/root.crt read -rsp "Root token: " BAO_TOKEN; echo; export BAO_TOKEN B="nix shell nixpkgs#openbao -c bao" # ADR 0003: runner AppRole is bootstrap-only, never in tofu $B policy write tofu-runner - <<'EOF' path "*" { capabilities = ["create","read","update","delete","list","sudo"] } EOF $B auth enable approle $B write auth/approle/role/tofu-runner \ token_policies=tofu-runner token_ttl=1h token_max_ttl=2h \ secret_id_bound_cidrs=10.44.0.0/16 token_bound_cidrs=10.44.0.0/16 ROLE_ID=$($B read -field=role_id auth/approle/role/tofu-runner/role-id) SECRET_ID=$($B write -f -field=secret_id auth/approle/role/tofu-runner/secret-id) OIDC=$(kubectl --context mini -n flux-system get secret vault-config-vars -o jsonpath='{.data.oidc_client_secret}' | base64 -d) kubectl --context mini -n flux-system create secret generic openbao-config-vars \ --from-literal=approle_role_id="$ROLE_ID" \ --from-literal=approle_secret_id="$SECRET_ID" \ --from-literal=oidc_client_secret="$OIDC" unset BAO_TOKEN ROLE_ID SECRET_ID OIDC ``` Notes: - `10.44.0.0/16` is mini's pod CIDR. If runner traffic reaches the thinks SNATed to the node IP, logins fail; drop the bindings or use mini's node IP. - `openbao-config-vars` is a hand-made Secret on mini, not in git. A mini rebuild needs a fresh secret_id: re-run the last block (new `secret-id`, recreate the Secret). - `auth/approle`, policy `tofu-runner` and role `tofu-runner` must never appear in the `vault` root. State of the rest, same day: flux `bc810652` (trust-manager Bundle `lab-root-ca` into `flux-system`), flux `42a534c5` (`vault-config` suspended, `openbao-config` plan-only at `https://10.10.1.21:8200`), iac `b0c3fb7` (import blocks, `pki.tf` dropped). DNS deferred to #50, public UI to #51.
Author
Owner

2026-11-11: openbao-config applied master@b0c3fb7 (6 imported, 42 created, 0 changed/destroyed), approvePlan auto, vault-config removed (state secret kept). Kanidm CLI login (oidc-cli via vault/scripts/vault-login.py with VAULT_ADDR=https://10.10.1.21:8200) verified by owner: token works, status + auth list OK. Web OIDC login waits on a reachable hostname (#50/#51). Remaining: revoke root token.

2026-11-11: openbao-config applied master@b0c3fb7 (6 imported, 42 created, 0 changed/destroyed), approvePlan auto, vault-config removed (state secret kept). Kanidm CLI login (oidc-cli via vault/scripts/vault-login.py with VAULT_ADDR=https://10.10.1.21:8200) verified by owner: token works, status + auth list OK. Web OIDC login waits on a reachable hostname (#50/#51). Remaining: revoke root token.
Author
Owner

Status 2026-11-17: openbao-config object Ready, applies through tofu-controller, hand-made 11-07 objects imported, pki-apiserver gone (c1 CA tree rebuilt under the hardware root 11-12, 7/7 CAs). Still unchecked: Kanidm OIDC login proven CLI+web, and root token revoke still waiting on that web login (see 11-11 note). Leaving open for the human two checkboxes.

Status 2026-11-17: openbao-config object Ready, applies through tofu-controller, hand-made 11-07 objects imported, pki-apiserver gone (c1 CA tree rebuilt under the hardware root 11-12, 7/7 CAs). Still unchecked: Kanidm OIDC login proven CLI+web, and root token revoke still waiting on that web login (see 11-11 note). Leaving open for the human two checkboxes.
Author
Owner

Done per owner 2026-11-17: Kanidm OIDC login to OpenBao proven CLI and web, which was the gate for the last two checkboxes. All earlier evidence stands: openbao-config Ready with clean plans through tofu-controller, hand-made 2026-11-07 objects imported not recreated, pki-apiserver gone (CA tree under the hardware root), KV data migration carried by lab/clusters#1669. If the root token somehow survived (it should have been revoked with the proven login), revoking it is a one-liner and deserves its own note rather than this issue.

Done per owner 2026-11-17: Kanidm OIDC login to OpenBao proven CLI and web, which was the gate for the last two checkboxes. All earlier evidence stands: openbao-config Ready with clean plans through tofu-controller, hand-made 2026-11-07 objects imported not recreated, pki-apiserver gone (CA tree under the hardware root), KV data migration carried by lab/clusters#1669. If the root token somehow survived (it should have been revoked with the proven login), revoking it is a one-liner and deserves its own note rather than this issue.
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/iac#47
No description provided.