opentofu: a ssh_public_key change must not replace the instances #611
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
priority
high
priority
low
priority
medium
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-infra#611
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "%!s()"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
What
var.ssh_public_keyis rendered into the instanceuser_data(opentofu/compute.tofu:136-148,monitoring.tofu:164-176).user_datais ForceNew. The hostname was already decoupled for this reason (variables.tofu). Neither instance has alifecycleblock. Only the volumes do.Why
A key rotation should not rebuild the host.
Failing case
Change
ssh_public_keyinterraform.tfvarsand runpnpm tofu:apply. The plan shows both instancesmust be replacedplus the volume attachments, which is prod downtime. cloud-init on the retained root disk only appends the new key toadmin. The old key is not revoked, so the rebuild does not even do the job.Fix
Add
lifecycle { ignore_changes = [user_data] }to both instances, with a one-line why-comment. Rotate keys through the Ansibleauthorized_keytask.Done when
tofu planafter a key change shows no instance replacement.pnpm tofu:validateandtofu:checkpass.