fix: wire all Woodpecker secrets through terraform helm values #84
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-platform#84
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Lineage
plan-pal-e-platform→ Phase 17a (Woodpecker Secrets Hardening)Repo
forgejo_admin/pal-e-platformUser Story
As a platform operator
I want all Woodpecker secrets permanently wired through terraform
So that
tofu applynever breaks Woodpecker, and DB migrations don't invalidate API tokensContext
Every Woodpecker CNPG DB migration breaks 4 secrets across 5 consumers. This has happened TWICE. Root cause: Woodpecker generates a random
jwt-secretinserver_configstable on every fresh DB. The helm values don't wire secrets from terraform variables — DB password is empty in the connection string, agent secret has no value, and there's no persistent encryption key.Current
k3s.tfvarsalready has all the values:But the helm template doesn't use them properly.
File Targets
Files the agent should modify:
terraform/main.tf— Woodpecker helm_release resource:WOODPECKER_ENCRYPTION_KEYenv var to server (new terraform variablewoodpecker_encryption_key, 32-byte hex)woodpecker_db_passwordintoWOODPECKER_DATABASE_DATASOURCEURL: changepostgres://woodpecker:@topostgres://woodpecker:${var.woodpecker_db_password}@WOODPECKER_AGENT_SECRETenv var on agent tovar.woodpecker_agent_secret(currently empty)terraform/variables.tf— Addwoodpecker_encryption_keyvariable (sensitive string)Makefile— Addwoodpecker_db_password,woodpecker_agent_secret,woodpecker_encryption_keytoTF_SECRET_VARSFiles the agent should NOT touch:
k3s.tfvars— already has the values (exceptwoodpecker_encryption_keywhich Lucas will add manually).woodpecker.yaml— CI pipeline doesn't need these secretsAcceptance Criteria
WOODPECKER_DATABASE_DATASOURCEcontains${var.woodpecker_db_password}in the connection stringWOODPECKER_AGENT_SECRETenv var on agent is set tovar.woodpecker_agent_secretWOODPECKER_ENCRYPTION_KEYenv var on server is set tovar.woodpecker_encryption_keywoodpecker_encryption_keydeclared invariables.tfas sensitiveTF_SECRET_VARSincludes all 3 new entriestofu validatepassestofu fmtproduces no changestofu plan -lock=falseshows only Woodpecker helm release changes (use placeholder values for missing vars)Test Expectations
tofu validate— must passtofu plan -lock=false— review for expected Woodpecker changes onlyConstraints
tofu fmtbefore committingtofu validatebefore committingtofu applytofu plan -lock=falseoutput in PR descriptionwoodpecker_encryption_keyvariable won't have a value yet ink3s.tfvars— use a default empty string with a validation block or pass-var="woodpecker_encryption_key=placeholder"for planChecklist
tofu validatepassesRelated
phase-platform-17a-woodpecker-secrets— parent phasetodo-woodpecker-secrets-terraform— the TODO this resolvespal-e-platform— projectPR #85 Review
DOMAIN REVIEW
Tech stack: Terraform/Helm (OpenTofu). Three files changed:
Makefile,terraform/main.tf,terraform/variables.tf. 14 additions, 1 deletion.Terraform style:
set_sensitiveblock forWOODPECKER_ENCRYPTION_KEYis correctly placed atserver.env.WOODPECKER_ENCRYPTION_KEYwithin thehelm_release.woodpeckerresource (line ~767-771). It sits between the Forgejo OAuth secrets and the existingWOODPECKER_AGENT_SECRETset_sensitiveblock. Correct Helm value path (server.env.*), correcttype = "string".variables.tffollows the established pattern:sensitive = true, descriptivedescriptionfield,type = string. Placed afterwoodpecker_agent_secret-- logical grouping.TF_SECRET_VARSaddition: the three new entries (woodpecker_db_password,woodpecker_agent_secret,woodpecker_encryption_key) are appended as a single new line with proper backslash continuation on the previous line. No duplicates -- verifiedwoodpecker_forgejo_clientandwoodpecker_forgejo_secretwere already there, and none of the three new entries existed previously.Pre-existing patterns confirmed (not part of this diff):
WOODPECKER_DATABASE_DATASOURCEon line 718 interpolatesvar.woodpecker_db_passworddirectly in thevaluesblock (notset_sensitive). This means the password appears in plan output and state. Pre-existing -- not introduced here, and fixing it would be scope creep for this issue.WOODPECKER_AGENT_SECRETalready hasset_sensitiveon bothserver.env(line 774) andagent.env(line 780). Correct.BLOCKERS
None.
NITS
Salt pillar gaps (pre-existing, out of scope):
woodpecker_db_passwordandwoodpecker_encryption_keyare not insalt/pillar/secrets/platform.sls(GPG-encrypted values) orsalt/pillar/secrets_registry.sls(metadata). Onlywoodpecker_agent_secrethas both. The PR acknowledges this as an operator step in the Review Checklist ("Salt pillar updated withwoodpecker_encryption_key"). This meansmake tofu-secretswill silently skip these two variables until pillar is updated -- Terraform will then fail on missing required variables. The operator is warned.k3s.tfvars.exampleincomplete (pre-existing): The example file haswoodpecker_db_passwordbut is missingwoodpecker_agent_secretandwoodpecker_encryption_key. Not part of this diff, but worth tracking as a follow-up nit.WOODPECKER_DATABASE_DATASOURCEnot usingset_sensitive(pre-existing): The DB password is interpolated in thevaluesyamlencode block (line 718) rather than viaset_sensitive. This leaks the password intofu planoutput and state. Consider extracting toset_sensitivein a future PR. Not in scope here.SOP COMPLIANCE
84-fix-wire-all-woodpecker-secrets-through(starts with84)plan-pal-e-platformPhase 17aCloses #84present in PR bodytofu fmtandtofu validateconfirmed passing per PR bodytofu planoutput not included -- acknowledged in PR body as requiring server-side execution with real state. Operator step.PROCESS OBSERVATIONS
set_sensitiveblock and Makefile entries. No destructive changes. Existing Helm release will get one new env var (WOODPECKER_ENCRYPTION_KEY). The Woodpecker pod will restart on nexttofu apply, which is expected.woodpecker_encryption_keyto Salt pillar with a GPG-encrypted value, (2) add registry entries for bothwoodpecker_db_passwordandwoodpecker_encryption_keytosecrets_registry.sls, and (3) runmake tofu-secretsbeforetofu apply. The PR Review Checklist correctly surfaces these as unchecked operator steps.VERDICT: APPROVED
Clean, minimal, correctly scoped fix. All three secrets properly wired. No blockers. Three pre-existing nits noted for follow-up.