# moved.tf — state-address migration for the count -> for_each refactor (T-1.5 F1). # # The node resources changed from positional `count` indexes ([0],[1],[2]) to # name-keyed `for_each` (["k3s-dev-1"], …). Without these `moved` blocks OpenTofu # would read the address change as "destroy the old, create the new" and rebuild # every node. Each block tells tofu the resource is the SAME object under a new # address, so the plan is a pure in-state rename: NO destroy, NO recreate. # # LOCKED mapping (node_count = 3, prefix "k3s-dev-"): index i -> "k3s-dev-${i+1}". # `moved` blocks are static config (no for_each), so they are written explicitly. # Safe to KEEP indefinitely (harmless once applied) or delete after one apply on # every environment that held count-indexed state. # --- OS disks --------------------------------------------------------------- moved { from = libvirt_volume.os[0] to = libvirt_volume.os["k3s-dev-1"] } moved { from = libvirt_volume.os[1] to = libvirt_volume.os["k3s-dev-2"] } moved { from = libvirt_volume.os[2] to = libvirt_volume.os["k3s-dev-3"] } # --- data disks ------------------------------------------------------------- moved { from = libvirt_volume.data[0] to = libvirt_volume.data["k3s-dev-1"] } moved { from = libvirt_volume.data[1] to = libvirt_volume.data["k3s-dev-2"] } moved { from = libvirt_volume.data[2] to = libvirt_volume.data["k3s-dev-3"] } # --- cloud-init seeds ------------------------------------------------------- moved { from = libvirt_cloudinit_disk.seed[0] to = libvirt_cloudinit_disk.seed["k3s-dev-1"] } moved { from = libvirt_cloudinit_disk.seed[1] to = libvirt_cloudinit_disk.seed["k3s-dev-2"] } moved { from = libvirt_cloudinit_disk.seed[2] to = libvirt_cloudinit_disk.seed["k3s-dev-3"] } # --- domains (VMs) ---------------------------------------------------------- moved { from = libvirt_domain.node[0] to = libvirt_domain.node["k3s-dev-1"] } moved { from = libvirt_domain.node[1] to = libvirt_domain.node["k3s-dev-2"] } moved { from = libvirt_domain.node[2] to = libvirt_domain.node["k3s-dev-3"] }