Commit Graph

250 Commits

Author SHA1 Message Date
unkin-agent aef0666da8 Mint netbox user-management token dynamically (#184)
ci/woodpecker/push/apply Pipeline was successful
The netbox engine admin token was rotated, so netbox_user_management (still on the static KV admin_token because user_mgmt_username is unset) now fails plan with 403 "Invalid v2 token". The vault-user-mgmt role already exists in Vault.

- set user_mgmt_username to admin so user management uses the Vault-minted netbox/creds/vault-user-mgmt token
- declare the vault-secrets-netbox provider in the generated root config
- import the existing netbox/roles/vault-user-mgmt role into state

Reviewed-on: #184
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-17 23:06:43 +11:00
unkin-agent 167879e0c7 Emit groups claim for victorialogs-reader OIDC tokens (#181)
ci/woodpecker/push/apply Pipeline was successful
oauth2-proxy reads groups for extra-JWT-issuer bearer tokens from the hard-coded `groups` claim; `oidc_groups_claim` only applies to the primary provider. The `victorialogs-reader` token carries `ak_groups`, so its session has no groups and every request to vlogs.unkin.net 403s.

- emit `groups` instead of `ak_groups` in the `victorialogs-reader` OIDC role template

Reviewed-on: #181
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-16 21:40:50 +11:00
unkin-agent cf56bf05a6 Add group and email claims to victorialogs-reader tokens (#180)
ci/woodpecker/push/apply Pipeline was successful
victorialogs-reader tokens are presented as bearer tokens to the oauth2-proxy in front of vlogs.unkin.net, which requires an email claim and membership of akP-vlogs-admin via the ak_groups claim. Bare Vault identity tokens carry neither, so the proxy rejects them.

- add a claims template to the victorialogs-reader role setting ak_groups to [akP-vlogs-admin] and email to victorialogs-reader@vault.unkin.net

Reviewed-on: #180
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-16 21:28:18 +11:00
unkin-agent 62179ee9ec Add victorialogs-reader identity OIDC role for agents (#179)
ci/woodpecker/push/apply Pipeline was successful
AI agents need short-lived tokens to query VictoriaLogs; identity OIDC is the default app auth, so agents mint a Vault-signed JWT with audience `victorialogs`.

- add `victorialogs` identity OIDC key (RS256)
- add `victorialogs-reader` role (client_id `victorialogs`, 15m TTL)
- add policy granting read on `identity/oidc/token/victorialogs-reader` to approle `agents`, ldap `vault_admin`, oidc `akP-vault-admin`

Reviewed-on: #179
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-16 20:49:31 +11:00
unkin-agent 5245bcdc29 Omit empty tune block on remaining auth backends (#178)
ci/woodpecker/push/apply Pipeline was successful
terraform-provider-vault 5.6.0 panics in expandAuthMethodTune when an auth backend gets a tune block whose values are all null. #176 fixed the JWT backend; the approle, kubernetes, ldap and oidc backends still render tune unconditionally, so any mount of theirs without tune values crashes plan.

- Render tune via a dynamic block only when at least one tune value is set; values pass through unchanged
- Add tofu tests per module covering the unset and set cases
- Run the new module tests from make test and the tofu-module-tests hook

Reviewed-on: #178
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-14 19:02:09 +11:00
unkin-agent 4ea4a881ae Drop applied jwt/github/iuclabs import block (#177)
ci/woodpecker/push/apply Pipeline was canceled
The one-off import for the jwt/github/iuclabs auth backend has been applied, so the mount is now in state and the block is dead weight.

- Removes the `import` block for `module.auth_jwt_backend["jwt/github/iuclabs"]` from `modules/vault_cluster/state_migrations.tf`

Reviewed-on: #177
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-14 19:01:04 +11:00
unkin-agent fbd161ccf0 Omit empty tune block on JWT auth backends (#176)
ci/woodpecker/push/apply Pipeline was successful
The GitHub Actions JWT mount sets no tune values, so the module rendered an all-null `tune {}` that crashes hashicorp/vault 5.6.0 in `expandAuthMethodTune` after the mount is enabled, leaving `jwt/github/iuclabs` live but outside state.

- Render the `tune` block on JWT auth backends only when a tune value is set
- Import `jwt/github/iuclabs` into state so the next apply converges instead of hitting "path is already in use"
- Add a tofu test for tune rendering and run it in `make test` and pre-commit

Reviewed-on: #176
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-10 23:36:33 +11:00
unkin-agent b9ae4a6802 Add GitHub Actions JWT auth mount for IUCLabs (#175)
ci/woodpecker/push/apply Pipeline failed
IUCLabs GitHub Actions workflows need read access to their own KV secrets without per-repo role and policy plumbing.

- add `auth/jwt/github/iuclabs` JWT mount trusting GitHub Actions OIDC
- add org-wide `default` role (mount `default_role`): audience `https://vault.service.consul:8200`, `user_claim=jti`, metadata mappings, 15m/1h TTLs
- restrict to `repository_owner=IUCLabs`, events push/release/schedule/pull_request, refs heads/tags/pull-merge; validation rejects anything wider
- attach templated read-only policy on `kv/github/<repo>/event/<event>/*` and `kv/github/<repo>/ref/<ref>/.secrets/*`
- add `tofu test` cases, run by `make test` and pre-commit
- document login, KV layout, event-path scope, `+` ref caveat and entity growth

Pairs with the terraform-git ref-name ruleset.

Reviewed-on: #175
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-10 23:25:31 +11:00
unkin-agent be041f7112 Grant the vault deployer the GitHub Actions JWT auth mount (#174)
ci/woodpecker/push/apply Pipeline was successful
IUCLabs GitHub Actions workflows will authenticate to Vault through a JWT auth mount at `jwt/github/iuclabs`. AppRole capabilities are fixed at login and enabling an auth mount is sudo-protected, so the deployer needs these grants in an apply before the mount exists.

- add sudo rules for `sys/auth/jwt/github/iuclabs` and its `/tune`
- add `auth/jwt/github/iuclabs/*` admin policy for `tf_vault` and `woodpecker_terraform_vault`

Apply before the mount PR.

Reviewed-on: #174
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-10 22:19:12 +11:00
unkin-agent 2593065e9c Allow terraform-git to read the IUCLabs GitHub App secret (#173)
ci/woodpecker/push/apply Pipeline was successful
terraform-git manages the IUCLabs GitHub org through a GitHub App whose app_id, installation_id and pem live in kv/service/github/iuclabs/terraform. Its plan/apply identities need read access to that secret.

- add read policy on kv/data/service/github/iuclabs/terraform
- bind it to the terraform_git approle and the woodpecker_terraform_git k8s role

Reviewed-on: #173
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-09 23:50:21 +11:00
unkin-agent fa89757b03 Add artifactapi-writer OIDC role for Woodpecker uploads (#172)
ci/woodpecker/push/apply Pipeline was successful
Woodpecker pipelines need a Vault identity OIDC token with audience `artifactapi` to upload artifacts; only terraform-artifactapi can mint one today.

- add `artifactapi-writer` identity OIDC role (client_id artifactapi, ttl 900)
- add policy granting read on `identity/oidc/token/artifactapi-writer` to k8s role `woodpecker_artifactapi_writer`, vault admins via oidc/ldap
- add k8s auth role `woodpecker_artifactapi_writer` bound to woodpecker CI service accounts

Reviewed-on: #172
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-25 15:15:01 +11:00
unkin-agent cc298526e9 Pin plugin-backed mounts to their catalog version (#171)
ci/woodpecker/push/apply Pipeline was successful
Plugin-backed mounts keep their pinned `plugin_version` when a catalog yaml bumps `version`, so the old catalog entry is deregistered while the mount still points at it and the backend fails to start on the next leader change.

- add `mount_plugin_version` module tuning `sys/mounts/<path>/tune` to the catalog yaml version for each plugin-backed mount
- register new plugin versions before deregistering old ones (`create_before_destroy`)
- document the post-bump backend reload in the arrstack plugin yaml
- document that a versioned plugin yaml must keep `version` (removing it strands the mount on the old version)

Reviewed-on: #171
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-23 22:55:04 +11:00
unkin-agent 7c7b1df720 Add encapi identity OIDC key and roles (#170)
ci/woodpecker/push/apply Pipeline was successful
encapi moves to Vault identity OIDC auth, mirroring artifactapi: terraform-enc gets full write tokens, and admins can mint narrow encapi-testing tokens that may only switch a node to the testing environment.

- add RS256 identity OIDC key `encapi`
- add role `terraform-enc` (aud `encapi`) readable by approle `terraform_enc` and k8s `woodpecker_terraform_enc`
- add role `encapi-testing` (aud `encapi-testing`) readable by ldap `vault_admin` and oidc `akP-vault-admin`

Reviewed-on: #170
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-23 21:43:41 +11:00
unkin-agent d4d1f89674 Grant agents read on BinaryLane WireGuard keys (#169)
ci/woodpecker/push/apply Pipeline was successful
The BinaryLane VPN VM WireGuard keypairs live in kv/service/wireguard/binarylane, written only by terraform-binarylane. Agents need to read them to eyaml-encrypt the keys into puppet-prod hiera.

- add read-only agents approle policy on kv/data/service/wireguard/binarylane/*
- allow read/list on the matching metadata path

Reviewed-on: #169
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-17 12:46:36 +11:00
unkin-agent 07c87f9476 Sort kubernetes role allowed namespaces (#168)
ci/woodpecker/push/apply Pipeline was successful
Vault returns `allowed_kubernetes_namespaces` sorted, but the attribute is an ordered list, so any role declaring namespaces out of order (e.g. agent-observability) plans an in-place update on every run.

- sort `allowed_kubernetes_namespaces` in the kubernetes_secret_backend_role module

Reviewed-on: #168
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-16 22:10:09 +11:00
unkin-agent 59c42993bc Add identity OIDC token role for terraform-artifactapi (#167)
ci/woodpecker/push/apply Pipeline was canceled
terraform-artifactapi CI needs a Vault-signed identity token that artifactapi can verify, so the issuer must be a fixed address reachable from pods rather than per-node api_addr.

- set the identity token issuer to https://vault.service.consul:8200
- add RS256 named key artifactapi
- add role terraform-artifactapi (aud artifactapi, 15m ttl)
- grant read on identity/oidc/token/terraform-artifactapi to the terraform_artifactapi approle and woodpecker_terraform_artifactapi k8s role

Requires terraform-vault #165 and #166.

Reviewed-on: #167
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-16 22:09:20 +11:00
unkin-agent 9c1f05ed60 Add identity OIDC modules and YAML discovery (#166)
ci/woodpecker/push/apply Pipeline was successful
Identity OIDC (token roles, provider clients, scopes, assignments) is not managed from YAML yet, and role/client names share one global credential path namespace that is easy to collide on.

- add identity_oidc{,_key,_role,_client,_scope,_assignment,_provider} modules and config discovery; roles/clients live under config/<kind>/<key>/
- allow each role/client client_id on its key via vault_identity_oidc_key_allowed_client_id
- resolve provider allowed_clients from client names
- add a test rejecting duplicate role/client names and references to missing keys, clients, scopes or assignments

Reviewed-on: #166
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-16 22:00:23 +11:00
unkin-agent c64f3f90b3 Add deployer policy for identity OIDC objects (#165)
ci/woodpecker/push/apply Pipeline was successful
Terraform is about to manage Vault identity OIDC keys, roles, clients, scopes, assignments and providers. The deployer token capabilities are fixed at login, so the grant must apply before the resources land.

- add policies/identity/oidc/admin.yaml for tf_vault and woodpecker_terraform_vault
- grant create/read/update on identity/oidc/config
- grant create/read/update/delete on identity/oidc/{key,role,client,scope,assignment,provider}/*

Reviewed-on: #165
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-16 21:54:04 +11:00
unkin-agent 4f3036218d Add Vault/Consul access for terraform-binarylane (#164)
ci/woodpecker/push/apply Pipeline was successful
The new terraform-binarylane repo provisions the BinaryLane mail gateways from Woodpecker and needs an identity, state storage, its provider token and somewhere to keep the WireGuard keypairs it generates.

- add the terraform_binarylane approle and woodpecker_terraform_binarylane k8s role
- add the terraform-binarylane consul role with write on infra/terraform/binarylane/
- grant the runner read on kv/service/terraform/binarylane (API token)
- grant the runner create/read/update/delete on kv/service/wireguard/binarylane/*
- let the agents approle seed kv/service/terraform/binarylane (no delete)

Needs the terraform-binarylane woodpecker ServiceAccount in argocd-apps before CI can auth.

Reviewed-on: #164
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-12 00:36:17 +11:00
unkin-agent b454bcb41a feat: litellm creds for mail/rspamd (#163)
ci/woodpecker/push/apply Pipeline was successful
rspamd in the `mail` namespace needs a LiteLLM key for LLM-assisted spam scoring, limited to the cheap Haiku model. The `rspamd` litellm role existed but also allowed Sonnet and had no consumer binding.

- limit litellm role `rspamd` to `claude-haiku-4-5`
- add policy `litellm/creds/rspamd` reading `litellm/creds/rspamd`
- add k8s auth role `rspamd` bound to SA `rspamd` in `mail`

Reviewed-on: #163
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-12 00:27:43 +11:00
unkin-agent b1d6f67161 ci: use container-opentofu image (#162)
ci/woodpecker/push/apply Pipeline was successful
CI images move off the packer-images monorepo to semver-released container-* repos.

- run CI steps on docker-internal/opentofu:0.1.0

Reviewed-on: #162
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-05 14:10:19 +11:00
unkin-agent e2c07a8c83 Replace the terraform-infra Vault identity with terraform-netbox (#161)
ci/woodpecker/push/apply Pipeline was successful
terraform-netbox supersedes terraform-infra but has no identity to run as: the terraform-infra policies bind to a terraform_infra approle and a woodpecker_terraform_infra k8s role that were never created.

- rename the netbox and consul creds policies, the engine role and the consul ACL rules to terraform-netbox
- add the terraform_netbox approle and woodpecker_terraform_netbox k8s role
- grant the engine role extras.customfield, dcim.platform and the device inventory types the module creates (manufacturer, devicetype, devicerole, tag, ipam.role) — the old scope would have 403ed on first apply
- drop the kv/service/terraform/infra policy: the kea_token is gone with Kea and the NetBox token is minted per run

Needs the terraform-netbox woodpecker ServiceAccount in argocd-apps before CI can auth.

Reviewed-on: #161
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-10-03 09:39:10 +10:00
unkin-agent 096d677129 Remove the vlogs one-off oauth-credentials policy (#160)
ci/woodpecker/push/apply Pipeline was successful
The vlogs OIDC client secret moves to its own Kubernetes namespace under service account `default`, so it lands on `kv/data/kubernetes/namespace/vlogs/default/oauth-credentials`. The shared per-namespace rule already matches that path, leaving the vlogs-specific policy with nothing to grant.

- Delete `policies/kv/kubernetes/namespace/logging/default/vlogs-oauth-credentials/read.yaml`.

The shared oauth-credentials policy is untouched.

Reviewed-on: #160
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-09-28 22:47:51 +10:00
unkin-agent 890d666a53 Keep policy rule paths within their own directory (#158)
ci/woodpecker/push/apply Pipeline was successful
Nothing stopped a policy under policies/x/y/ from granting a rule path outside its own directory, so an over-broad grant read as ordinary review noise and only surfaced once applied to Vault.

- add tests/test_policies.py: a pydantic model rejecting unknown keys, empty rules and non-Vault capabilities
- check every rule path segment-wise against the policy's own directory, stripping the kv-v2 data/metadata segment
- relocate the rules that reached outside their directory, carrying capabilities and auth bindings verbatim
- run the suite from a local pre-commit hook and from make test

Reviewed-on: #158
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-09-28 22:12:14 +10:00
unkin-agent 2ec552d6fd Add agent-observability kubernetes creds role and policy (#156)
ci/woodpecker/push/apply Pipeline was successful
No agent Vault role covers the VictoriaMetrics/VictoriaLogs stack, so a scoped Kubernetes token cannot be issued for it and writes there fall back to an admin context.

- add the agent-observability kubernetes secret backend role, allowed in vm-system, observability and logging
- add its generated role rules: read plus patch/update on VictoriaMetrics CRs and workloads, pod delete for rolling restarts, read-only on services, configmaps, endpoints, events and Gateway API routes
- add a policy granting update on kubernetes/au/syd1/creds/agent-observability to the cluster_operator LDAP group and the agents approle

Reviewed-on: #156
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-09-27 11:23:36 +10:00
unkin-agent 563b2164c7 Let terraform-authentik read the vlogs OIDC client secret (#157)
ci/woodpecker/push/apply Pipeline was successful
vlogs is the first app needing a second OIDC secret in a namespace that already has one, so the one-per-namespace `oauth-credentials` wildcard does not cover it and the terraform-authentik plan fails on a denied kv read.

- grant the runner read on `kv/kubernetes/namespace/logging/default/vlogs-oauth-credentials`

Unblocks terraform-authentik #40.

Reviewed-on: #157
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-09-27 10:35:05 +10:00
unkin-agent b576524553 Accept IP and short-hostname principals on sshca/signhost (#155)
ci/woodpecker/push/apply Pipeline was successful
Puppet signs host certs with principals hostname, FQDN and IP (plus extra IPs on k8s nodes). The signhost role only matched allowed_domains entries exactly or by suffix, so every agent run failed with `198.18.29.56 is not a valid value for valid_principals`.

- Set `allowed_domains` on `sshca/signhost` to `*`, the only value OpenBao treats as unrestricted for host principals (per-entry globs are not honoured).
- Note the sole-entry requirement in the config.

Role stays host-only (`allow_user_certificates: false`); the CA key is untouched.

Reviewed-on: #155
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-09-24 22:26:55 +10:00
unkin-agent 14144584e3 Fix SSH host certificate signing for the sshca role (#153)
ci/woodpecker/push/apply Pipeline was successful
Host signing returns 403 even though login succeeds: the policy grants the literal path sshca/sign/host, but the only role on the sshca mount is signhost, so the grant matches nothing. Hosts named directly under unkin.net also fall outside the role's allowed domains.

- Rename the policy to sshca/sign/signhost and grant that path
- Allow unkin.net alongside main.unkin.net and consul on the signhost role

Reviewed-on: #153
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-09-19 15:48:44 +10:00
unkin-agent c1e60dad83 Add kubernetes auth roles for the puppet compilers (#152)
ci/woodpecker/push/apply Pipeline was successful
The certmanager and sshsigner approles are CIDR-bound to the six legacy VM puppet-master IPs, so the HPA-autoscaled k8s compilers cannot log in and any catalog compile needing a cert or a signed host key fails.

- Add k8s auth roles `puppet_certmanager` and `puppet_sshsigner` on `k8s/au/syd1`, bound to the `default` service account in namespace `puppet`
- Attach the existing pki/pki_int certmanager and sshca signing policies to them, keeping the approle token TTLs
- Leave the approle roles and their CIDR bindings untouched

Follow-up ships the scripts into the compiler pods.

Reviewed-on: #152
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-09-13 22:54:44 +10:00
unkin-agent 9e18627567 Grant the agents approle read+write on the woodpecker agent token (#151)
ci/woodpecker/push/apply Pipeline was successful
Agents query the Woodpecker API to inspect pipeline runs and failing steps while reviewing PRs. That token is currently pasted into agent config by hand, so it lives in plaintext on disk instead of in Vault.

- add `policies/kv/service/woodpecker/tokens/agents.yaml`
- grant the `agents` approle create/read/update on `kv/data/service/woodpecker/tokens/agents`
- grant read/list on the matching metadata path; no delete, mirroring the `kv/kubernetes/*` grant

Token seeding follows once this is applied.

Reviewed-on: #151
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-09-12 13:19:56 +10:00
benvin 94e8ac1b2a chore: extend oidc login to 1 day (#150)
ci/woodpecker/push/apply Pipeline was successful
- 1 day / 7 days for oidc logins

---------

Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Reviewed-on: #150
2026-09-08 22:34:16 +10:00
unkin-agent a19256fdba Grant the vault deployer sudo to enable the oidc auth mount (#149)
ci/woodpecker/push/apply Pipeline was successful
## Why

The deployer identities cannot enable the `oidc` auth mount: `POST /v1/sys/auth/oidc` returns 403 because `sys/auth/<path>` (and its `/tune`) is sudo-protected, and `policies/sys/auth/admin.yaml` granted create/update/delete/read/list without `sudo`.

## How

- Add exact-path rules for `sys/auth/oidc` and `sys/auth/oidc/tune` to `policies/sys/auth/admin.yaml` with the wildcard's capability set plus `sudo` (exact match wins over the glob, so the set is repeated in full); auth block unchanged.

Merge order: apply this, then re-run the master apply so `module.auth_oidc_backend["oidc"]` can create the mount.

Reviewed-on: #149
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-31 22:21:01 +10:00
unkin-agent a1e7029615 Add Authentik OIDC SSO as the default human login for OpenBao (#147)
ci/woodpecker/push/apply Pipeline failed
## Why

Human login to OpenBao is LDAP-only, so operators keep a second credential set outside Authentik and group membership is maintained twice.

## How

- Add `auth_oidc_backend` module: `oidc`-type JWT auth mount, Authentik discovery URL, `listing_visibility: unauth`, credentials from `kv/service/authentik/oidc-vault`.
- Add `auth_oidc_role` module: oidc role with `user_claim` email, `groups_claim` `ak_groups`, scopes `openid profile email ak_groups`, the registered redirect URIs, `bound_audiences` `[vault]`.
- Add `auth_oidc_group` module: external identity group plus group alias on the OIDC mount accessor, policies from `policy_auth_map`.
- Add config under `config/auth_oidc_{backend,role,group}/`, discovery locals in `config/config.hcl`, `vault_cluster` variables and wiring, and terragrunt inputs.
- Bind `akP-vault-admin` on the `oidc` mount to `global-root`, alongside the existing LDAP `vault_admin` binding.
- Pin the mount path to the literal `oidc`: the registered redirect URIs embed `/ui/vault/auth/oidc/oidc/callback`.

Requires #146, terraform-authentik #33 and #148 applied first.

---------

Co-authored-by: BenVincent <benvin@main.unkin.net>
Reviewed-on: #147
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-30 22:38:05 +10:00
unkin-agent a3a8854a16 Grant the vault deployer auth/oidc and identity group capabilities (#148)
ci/woodpecker/push/apply Pipeline was successful
## Why

AppRole capabilities are fixed at login, so the deployer needs `auth/oidc/*` and identity-group grants in an apply that precedes the one creating those resources.

## How

- Add `policies/auth/oidc/admin.yaml`: full `auth/oidc/*` administration (mount config and login roles), mirroring `policies/auth/ldap/admin.yaml`.
- Add `policies/identity/group/admin.yaml`: manage external identity groups, group aliases and `identity/lookup/group`, on both the collection and per-id endpoints.
- Grant both policies to the `tf_vault` approle and the `woodpecker_terraform_vault` k8s role.

Apply before #147.

Reviewed-on: #148
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-30 22:14:41 +10:00
unkin-agent 67e79e72dc Grant the vault deployer read on the Authentik OIDC client secret (#146)
ci/woodpecker/push/apply Pipeline was successful
**Why:** the terraform-vault deployer must read the OpenBao OIDC client credentials that Authentik's provider module generates before it can configure `auth/oidc`, and AppRole capabilities are fixed at login so the grant has to exist in a prior apply.

**How:**
- Add `policies/kv/service/authentik/oidc-vault/read.yaml`: read on `kv/data/service/authentik/oidc-vault` for the deployer identities (approle `tf_vault`, k8s/au/syd1 `woodpecker_terraform_vault`); `terraform_authentik` still owns the write side of `kv/service/authentik/*`.

**Merge order:** this PR must merge and apply *before* the follow-up PR that adds the `auth/oidc` modules. OIDC becomes the default human auth path; approle/k8s (CI and agents) and break-glass are unchanged.

Reviewed-on: #146
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-30 21:50:57 +10:00
unkin-agent 1f03bcdc67 Bump vault-secrets-arrstack provider to 0.2.0 and plumb methods (#145)
ci/woodpecker/push/apply Pipeline was successful
## Why

Engine plugin v0.2.0 (catalog bumped in #144) added a `methods` field to arrstack roles, pinning a minted arrproxy key to a set of HTTP methods so a read-only integration can hold a key that cannot write. Provider v0.2.0 (just published to the `terraform-unkin` registry) exposes it as an optional set attribute, but the module had no input for it, so no role yaml could use it.

## How

- Bumps the `vault-secrets-arrstack` provider pin from 0.1.1 to 0.2.0 in `environments/root.hcl` and both arrstack modules.
- Adds an optional `methods` input to `modules/vault_cluster/modules/arrstack_secret_backend_role` and passes it through to the resource.
- Threads `methods` through the `vault_cluster` `arrstack_secret_backend_role` object type, so a role yaml may now carry a `methods:` list and it flows via the existing config.hcl merge with no discovery change.

`methods` defaults to `null` rather than `[]`: the provider reads an unrestricted role back as null, so a null default keeps a role yaml that omits the field drift-free. An empty-set default would plan `null -> []` on every existing role.

**Expected plan: no resource changes.** No role yaml changes here, so the plan should be a provider-version-only diff (provider upgrade, zero add/change/destroy).

Follow-up PR scopes the mediamark role to GET/HEAD.

Reviewed-on: #145
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-30 18:19:04 +10:00
unkin-agent 6c489c6003 Bump arrstack plugin catalog to v0.2.0 (#144)
ci/woodpecker/push/apply Pipeline was successful
## Why

The v0.2.0 arrstack plugin binary is live on all five OpenBao nodes (RPM applied via post-merge puppet runs), and the catalog still pins the v0.1.0 sha — OpenBao refuses to launch a plugin whose binary hash does not match the catalog entry.

## Changes

- `config/plugins/vault-plugin-secrets-arrstack.yaml`: `version` -> `0.2.0` and `sha256` -> `9ea7f160…12fa1`, computed from the binary extracted from `openbao-plugin-secrets-arrstack-0.2.0-1.x86_64.rpm` (the same RPM puppet pins).

## Post-apply

Run `vault plugin reload -plugin=vault-plugin-secrets-arrstack` after the apply so the running mount swaps to the v0.2.0 binary.

Reviewed-on: #144
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-30 17:07:28 +10:00
unkin-agent bcbf121818 Grant terraform-rancher read on rancher/creds/ci (#143)
ci/woodpecker/push/apply Pipeline was successful
## Why

`terraform-rancher` authenticates the rancher2 provider with a static 90-day admin API token stored in `kv/service/terraform/rancher` — the repo carries its own Makefile TODO to retire it. The Rancher secrets engine is already mounted at `rancher/` with a `ci` role (seeded `admin` service account, ttl 1h / max 8h), but no policy grants read on `rancher/creds/*`, so nothing can use it yet.

## What

Adds `policies/rancher/creds/ci.yaml`: `read` on `rancher/creds/ci`, bound to the same runner identities as the existing kv policy — approle `terraform_rancher` and k8s/au/syd1 role `woodpecker_terraform_rancher`.

Minted tokens are lease-bound and deleted from Rancher on revoke. They inherit the seeded admin service account's RBAC, so this is the same privilege as the static token it replaces, just short-lived.

## Follow-up

A terraform-rancher Makefile PR swapping `vault kv get kv/service/terraform/rancher` for `vault read -field=token rancher/creds/ci` must merge **only after** this one applies.

Reviewed-on: #143
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-30 09:42:00 +10:00
unkin-agent 9fa51f401a Add arrstack creds role and k8s auth for mediamark (#141)
ci/woodpecker/push/apply Pipeline was canceled
## Why

mediamark (kids-content marking UI, namespace `mediamark`) needs Sonarr/Radarr access to list series/movies and read metadata + artwork. It should get ephemeral virtual arrproxy keys from the arrstack secrets engine via arrproxy, not a copy of the static app API keys.

## How

- `config/arrstack_secret_backend_role/arrstack/mediamark.yaml` — role minting keys scoped to `sonarr` + `radarr` (no prowlarr), `ttl: 60` / `max_ttl: 86400`, mirroring the existing per-app roles.
- `config/auth_kubernetes_role/k8s/au/syd1/mediamark.yaml` — k8s auth role `mediamark`, bound to serviceaccount `default` in namespace `mediamark`, `token_ttl`/`token_max_ttl` 600, audience `vault`.
- `policies/arrstack/creds/mediamark.yaml` — `read` on `arrstack/creds/mediamark`, granted to `k8s/au/syd1: [mediamark]` only (deliberately not the shared `default` k8s role, which would expose the creds to every namespace).

Engine mount/config and the existing roles are untouched.

## Note

The companion argocd-apps change consumes `arrstack/creds/mediamark` via a `VaultDynamicSecret` (response fields: `token`, `id`, `apps`, `subject`, `expires_at`).

**GET/HEAD-only is not expressible today.** `arrstack_secret_backend_role` carries `apps`/`ttl`/`max_ttl` only, and arrproxy scopes machine tokens by app — the GET/HEAD restriction on the cheeztv/kids tier is a grant on an OIDC *group*, not on a minted token. The role is scoped as tightly as the engine allows and the limitation is documented in the yaml; per-token method scoping needs a plugin + arrproxy feature.

Reviewed-on: #141
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-30 09:40:26 +10:00
unkin-agent 5879fbd2d8 Add ephemeral Gitea creds for repospawner (#142)
ci/woodpecker/push/apply Pipeline was successful
## Why

`repospawner` creates and seeds Gitea repositories on demand from in-cluster. It needs a Gitea token, and it should not carry a static one -- it gets ephemeral, lease-bound creds like every other service. The `agents` AppRole is CIDR-bound to Ben's workstation, so pods authenticate via Kubernetes auth instead.

## How

- `config/gitea_secret_backend_role/gitea/repospawner.yaml` -- gitea engine role for the `repospawner` user. Scopes `write:repository`, `write:issue`, `read:user` (`read:user` is mandatory: clients validate the login via `GET /api/v1/user`, which 403s without it). ttl 1h / max_ttl 4h. Mirrors `unkin-agent.yaml`.
- `config/auth_kubernetes_role/k8s/au/syd1/repospawner.yaml` -- k8s auth role bound to serviceaccount `repospawner` in namespace `repospawner`, 600s ttl, `audience: vault` (VSO/projected-token flavor, same as `media-apps` / `logging_logarchiver`).
- `policies/gitea/creds/repospawner.yaml` -- `read` on `gitea/creds/repospawner`, bound to `k8s/au/syd1: [repospawner]` only. Deliberately **not** bound to the `agents` AppRole: the service runs in-cluster only.

## Depends on

The terraform-git PR that creates the `repospawner` Gitea user. The engine role cannot mint creds until the user exists -- **merge that one first**.

Reviewed-on: #142
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-30 09:29:26 +10:00
unkin-agent f3a3e4b874 Grant terraform-authentik write on the kv/service/authentik subtree (#140)
ci/woodpecker/push/apply Pipeline was successful
## Why

`kv/service/authentik/agent-api-token` is seeded by hand today. terraform-authentik should own it as IaC (`vault_kv_secret_v2`), along with any future Authentik automation tokens, but its runner identities only hold read on `kv/service/terraform/authentik` and the per-namespace oauth-credentials paths.

This must land and **apply** first: an AppRole/k8s token's capabilities are fixed at login, so the companion terraform-authentik PR would fail its very first plan against a policy that is not yet live.

## How

- Adds `policies/kv/service/authentik/write.yaml`, granting:
  - `kv/data/service/authentik/*` — create, read, update, delete
  - `kv/metadata/service/authentik/*` — read, list, delete
- Assigned to the same identities that already hold the terraform-authentik read policy: approle `terraform_authentik` and `k8s/au/syd1` role `woodpecker_terraform_authentik`.
- `delete` is included (unlike the `kv/kubernetes` agents grant) so `terraform destroy` and resource replacement clean up both the data and the metadata; metadata `read`/`list` is what `vault_kv_secret_v2` hits on every plan.
- Scope note in the file header: the ask was to scope to `*-token` paths, but Vault ACL paths only support a trailing glob, so the whole `kv/service/authentik/` subtree is granted. terraform-authentik is the owner of everything under that prefix.
- Existing `policies/kv/service/authentik/agent-api-token/read.yaml` (agents approle) is untouched.

## Order

Merge + apply this first; the companion terraform-authentik PR merges only afterwards.

Reviewed-on: #140
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-29 23:01:43 +10:00
unkin-agent 7c7826997e Grant agents approle read on kv/service/authentik/agent-api-token (#139)
ci/woodpecker/push/apply Pipeline was successful
## Summary
- Grants the agents approle read on kv/service/authentik/agent-api-token

## Why
Automation seeds oauth client secrets and LDAP outpost tokens; fetching outpost tokens needs a scoped Authentik API token, seeded at this path by the operator.

Reviewed-on: #139
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-29 12:56:06 +10:00
unkin-agent 36d2b99255 Revert temporary agents read grant on Authentik provider token (#138)
ci/woodpecker/push/apply Pipeline was successful
## Why
The one-off terragrunt import in terraform-authentik that required this grant is complete (jellyfin provider, groups, application, and policy bindings are all reconciled into state; apply pipeline is green). Per the recovery plan the temporary read grant is removed again.

## Changes
- Reverts de9d6e5: removes policies/kv/service/terraform/authentik/read.yaml (agents AppRole read on kv/data/service/terraform/authentik)

Reviewed-on: #138
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-25 21:35:57 +10:00
unkin-agent 9fcd9d7ab5 Grant agents AppRole read on the Authentik provider token (#137)
ci/woodpecker/push/apply Pipeline was successful
A one-off `terragrunt import` in terraform-authentik is needed to reconcile the Authentik resources orphaned by the jellyfin apply failure. The agents AppRole must be able to read the Authentik provider token (`kv/service/terraform/authentik`) to run the import; this grant is read-only on that single path and can be reverted once the import is done.

- Add `kv/service/terraform/authentik/read` policy (read on `kv/data/service/terraform/authentik`) bound to the `agents` AppRole

Reviewed-on: #137
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-23 22:34:31 +10:00
unkin-agent 57fe279d7a Run plan without acquiring the Consul state lock (#136)
ci/woodpecker/push/apply Pipeline was successful
PR plan pipelines were failing with "Error acquiring the state lock ... OperationTypePlan" when a plan collided with an apply (or another plan) holding the lock on the same Consul-backed state. Plans are read-only and don't need the lock.

- `plan`: pass `-lock=false` to `terragrunt ... plan`; `apply` is unchanged and still locks.

Reviewed-on: #136
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-23 22:31:58 +10:00
unkin-agent 6c68057e73 operator RO creds: read operator CRD API groups (#135)
ci/woodpecker/push/apply Pipeline was successful
## Why

The `operator` kube context is a Vault-minted, read-only credential (Kubernetes
secret engine role `cluster-operator`, bound to a `get/list/watch`-only
ClusterRole). It is currently RBAC-forbidden from listing operator-owned CRDs —
the immediate breakage is `valkeyclusters.valkey.io` — and likewise every other
operator CRD group deployed via `argocd-apps`. This extends the RO ruleset so the
context can read those CRDs. Still strictly read-only: no create/update/delete.

## Change

- Extend the `cluster-operator` generated_role_rules
  (`resources/secret_backend/kubernetes/au/syd1/roles/cluster-operator.yaml`)
  with `get/list/watch` on the CRD API groups of the operators deployed via
  `argocd-apps` (verbs and `resources: "*"` unchanged; same single rule block).

## API groups added

- `valkey.io` (valkey-operator — immediate need)
- `ceph.unkin.net` (cephrgw-operator)
- `bind.unkin.net` (bind-operator)
- `kea.unkin.net` (kea/dhcp operator)
- `k8up.io` (k8up)
- `grafana.integreatly.org` (grafana-operator)
- `operator.victoriametrics.com` (VictoriaMetrics operator)
- `clickhouse.altinity.com`, `clickhouse-keeper.altinity.com` (altinity clickhouse-operator)
- `acme.cert-manager.io` (cert-manager companion CRD group)
- `deviceplugin.intel.com`, `fpga.intel.com` (intel device plugins operator)
- `autoscaling.k8s.io` (VPA)
- `apm.k8s.elastic.co`, `beat.k8s.elastic.co`, `agent.k8s.elastic.co`,
  `maps.k8s.elastic.co`, `enterprisesearch.k8s.elastic.co`,
  `autoscaling.k8s.elastic.co`, `stackconfigpolicy.k8s.elastic.co` (ECK — the
  `elasticsearch`/`kibana`/`logstash` ECK groups were already granted)
- `snapshot.storage.k8s.io`, `groupsnapshot.storage.k8s.io` (CSI external-snapshotter, deployed via csi-cephfs/csi-cephrbd)

Groups already present (`postgresql.cnpg.io`, `cert-manager.io`,
`externaldns.k8s.io`, `secrets.hashicorp.com`, `purelb.io`, `nfd.k8s-sigs.io`,
`elasticsearch/kibana/logstash.k8s.elastic.co`, `gateway.networking.k8s.io`,
etc.) are unchanged. Rancher/RKE/Calico/cluster-api/fleet management-layer CRD
groups are intentionally excluded — they are not `argocd-apps` operators.

---------

Co-authored-by: unkin-agent <agent@unkin.net>
Reviewed-on: #135
Co-authored-by: Unkin Agent <unkin-agent@unkin.net>
Co-committed-by: Unkin Agent <unkin-agent@unkin.net>
2026-08-23 12:29:02 +10:00
unkin-agent aa8d41a7bb Bump vault-secrets-arrstack provider to 0.1.1 (#134)
ci/woodpecker/push/apply Pipeline was successful
v0.1.1 models the role apps attribute as a Set instead of a List, fixing the ordering-based "inconsistent result after apply" error and superseding the interim alphabetical yaml sort (#133).

- Bumps the vault-secrets-arrstack provider pin from 0.1.0 to 0.1.1 in root.hcl and both arrstack modules

Reviewed-on: #134
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-23 11:30:21 +10:00
unkin-agent 36fbfb86bc Sort arrstack role apps alphabetically (#133)
ci/woodpecker/push/apply Pipeline was successful
The master apply (pipeline 202) fails with "Provider produced inconsistent result after apply": the arrstack Vault engine returns apps alphabetically sorted while the provider models apps as an ordered List, so the declared order [sonarr, radarr, prowlarr] never matches the read-back. This is an interim unblock while the provider moves apps to a Set.

- Reorders apps in config/arrstack_secret_backend_role/arrstack/all.yaml to alphabetical order to match the engine read-back

Reviewed-on: #133
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-22 23:25:44 +10:00
unkin-agent a33fc2b42f Allow CSI auth to read ceph-mediafs-secret KV (#132)
ci/woodpecker/push/apply Pipeline failed
A new VaultStaticSecret `ceph-mediafs-secret` in ns `csi-cephfs` (for the legacy mediafs CephFS static PV) gets 403 on `kv/data/service/kubernetes/au/syd1/csi/ceph-mediafs-secret` — the `ceph-csi` role can already read the sibling `ceph-cephfs-secret` path via the same `ceph-csi-cephfs` VaultAuth, but no policy covers the new path.

- Adds `policies/kv/service/kubernetes/au/syd1/csi/ceph-mediafs-secret/read.yaml` granting read on `kv/data/service/kubernetes/au/syd1/csi/ceph-mediafs-secret`, bound to role `ceph-csi` on mount `k8s/au/syd1` (mirrors the existing ceph-cephfs-secret/ceph-rbd-secret policies)

Reviewed-on: #132
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-22 23:17:18 +10:00
unkin-agent 0e82cda02d vault: mount arrstack engine + config + roles (3/3) (#127)
ci/woodpecker/push/apply Pipeline failed
## Why

Creates the arrstack secrets engine itself: the mount + config and the per-scope roles that mint arrproxy API keys. **PR 3 of 3 (resources)**, stacked on #126 (policy). Final step of the register -> policy -> resources split (was #124).

## Change

- Adds `config/arrstack_secret_backend/arrstack.yaml`: mounts the engine at `arrstack` and writes its config (`base_url`, timeout). The arrproxy admin token stays out of git and is read from KV by the module.
- Adds `config/arrstack_secret_backend_role/arrstack/{all,sonarr,radarr,prowlarr}.yaml`: roles scoped to each arr app (plus one covering all three). Default `ttl` is **60s** (short-lived, renewed on demand); `max_ttl` 86400 mirrors the litellm sibling convention. The engine additionally caps renewal at the arrproxy admin token's fixed mint expiry.
- Adds `modules/vault_cluster/modules/arrstack_secret_backend{,_role}` and wires them in: `config/config.hcl` maps, `modules/vault_cluster/main.tf`, `variables.tf`, the environment inputs, and the root provider block.
- Provider source is `artifactapi.k8s.syd1.au.unkin.net/terraform-unkin/vault-secrets-arrstack` (repo `terraform-provider-vault-secrets-arrstack`), local name `arrstack`.

## Apply order

Apply **after PR #126 (policy) AND after `terraform-provider-vault-secrets-arrstack` v0.1.0 is published** to the artifactapi terraform registry. Until the provider is published, `tofu init` cannot resolve it, so **CI/plan on this PR is red by design** — that is expected, not a regression.

Note **plan-green != apply-green**: the KV-sourced `admin_token` is only fetched at apply time, so a green plan does not prove the seeded token is readable.

## Stack

1. register -> #125
2. policy -> #126
3. **resources (this PR)** -> `benvin/arrstack-resources` off `benvin/arrstack-policy`

Supersedes #124.

---------

Co-authored-by: unkin-agent <unkin-agent@git.unkin.net>
Co-authored-by: BenVincent <benvin@main.unkin.net>
Reviewed-on: #127
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-08-21 00:09:47 +10:00