gitea: add the gitea token secrets engine (mount, config, teabot roles) #101
Reference in New Issue
Block a user
Delete Branch "benvin/gitea-secret-engine"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
teabot's implementer and reviewer bot users should mint ephemeral, scoped Gitea tokens on demand rather than holding standing personal access tokens — Gitea tokens never expire on their own, so a leak lasts until someone notices. This registers and mounts the new
vault-plugin-secrets-giteaengine (released v0.1.0) and declares its roles, mirroring the rancher engine wiring.Change
config/plugins/vault-plugin-secrets-gitea.yaml), pinned to the released v0.1.0 binarysha256 8f67fbc216effada5fd7399888a710b62fad83be0b31761a439e7dec3d56509b(sha256 of/opt/openbao-plugins/vault-plugin-secrets-giteafrom the releasedopenbao-plugin-secrets-gitea-0.1.0RPM).gitea_secret_backend+gitea_secret_backend_rolemodules and wire them throughconfig.hcl,environments/au/syd1/terragrunt.hcl, andmodules/vault_clustervariables/main, using thegiteavaultsecretprovider from theterraform-unkinregistry (v0.1.0).gitea/againsthttps://git.unkin.net; seeded site-admin credentials are read from KV (service/vault/au/syd1/secret_backend/gitea/config, keysadmin_username/admin_password) — not stored in git.lifecycle ignore_changesonadmin_username/admin_passwordmeans the engine reads the KV seed only when first creatinggitea/config. Afterrotate-rootdiverges the live password from the seed, a later apply never pushes the stale seed back.teabot-implementer—write:repository,write:issue(clone/push, open PRs, comment).teabot-reviewer—read:repository,write:issue(read diffs, post PR reviews/comments).ttl1h /max_ttl4h on both roles.The site-admin bot + KV seed are now provisioned by Terraform (no manual gap)
Per Ben's review, creating the site-admin bot and seeding its credential is no longer a manual step:
gitea-vault-adminsite-admin bot and writes its generated password once tokv/service/vault/au/syd1/secret_backend/gitea/config(create-only KV write; never updated).Ordering (merge + apply)
benvin/gitea-deployer-access) — deployer access to the gitea mount.benvin/gitea-kv-writer) — terraform-git KV write grant.benvin/gitea-vault-admin) — creates the bot + seeds KV.Files here are disjoint from #100 and #102 (no conflict).
CI note: the plan for this PR may hard-fail in CI if the plugin isn't yet registered/installed or the KV seed isn't present in the plan's target. If CI plan fails for that ordering reason, that is expected — do not force; apply only once steps 1–4 are live.
Remaining manual step (one, ordered)
After this PR's first apply, run
vault write -f gitea/config/rotate-rootso the standing seed password is replaced by one only Vault holds. (On future binary upgrades, bump the RPM version in puppet-prod and the catalogsha256here together, thenvault write sys/plugins/reload/backend plugin=vault-plugin-secrets-gitea.)https://claude.ai/code/session_015ur3i7D2azsMAWTSVABApv
Seed the KV admin credential BEFORE apply: write admin_username + admin_password to kv/service/vault/au/syd1/secret_backend/gitea/config for a purpose-built Gitea site-admin bot with 2FA disabled (local user). GAP for a human: creating that site-admin bot account in Gitea is out of scope for this PR chain and does not exist yet — it must be provisioned before this applies.Can this not be done by terraform-git? It should be able to write git user passwords to vault. The vault gitea module in the vault repo should only use the password/user kv when initially creating the secret engine. After that it’s ignored. In terraform git, we should be able to write a random password once and not update it after that
Yes — done in Terraform, no manual gap:
gitea-vault-adminsite-admin bot and writes its generated password tokv/service/vault/au/syd1/secret_backend/gitea/config. The write is create-only (random_passwordnever regenerates, andlifecycle ignore_changes = [data_json]on thevault_kv_secret_v2), so the password is seeded once and never updated after.ignore_changesonadmin_username/admin_password, so oncegitea/configexists, a later apply won't push the (post-rotate-root stale) seed back over the live password.Apply order: #100 → #102 → terraform-git #46 → this.
vault write -f gitea/config/rotate-rootafter first apply is the only remaining manual step.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.