dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.54k stars 457 forks source link

[Enhancement] Force new domain if there is any change in cloud init disk #931

Open rishi-anand opened 2 years ago

rishi-anand commented 2 years ago

Whenever there is a change in user-data, network-config etc, cloud-init gets replaced.

"user_data": {
    Type:     schema.TypeString,
    Optional: true,
    ForceNew: true,
},

https://github.com/dmacvicar/terraform-provider-libvirt/blob/main/libvirt/resource_libvirt_cloud_init.go#L28-L32

But, if cloud-init is already finished for the domain then the domain won't get values from the new cloud-init disk until cloud-init gets triggered. Thus, the domain should also have ForceNew: true for cloud-init.

"cloudinit": {
    Type:     schema.TypeString,
    Optional: true,
    ForceNew: true,
},
anthr76 commented 2 years ago

Somewhat related. This functionality works as expected for domains with ignition but not for the underlying disk which means unless the domain is completely ephemeral recycling the domain without the underlying backing store is meaning-less.