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

Please elaborate on libvirt_cloudinit_disk #996

Closed troelsarvin closed 1 year ago

troelsarvin commented 1 year ago

I ask documentation be improved regarding the libvirt_cloudinit_disk resource:

Documentation states that it "can be used to customize". Does this mean that the libvirt_cloudinit_disk resource is optional? Can any customization be done without it?

Can the defined disk be removed after having run terraform, or is the resulting server dependent on the cloudinit disk?

Magnitus- commented 1 year ago

Honestly, I've never tried to remove a cloud-init volume after domain creation so I can't back that statement with empirical experience, but I don't see why you couldn't. Its the virtualization equivalent of having a usb stick in the server during setup and then removing it on subsequent boots. If you do a dumpxml on the generated domain, it evens sets the "device" property of the cloud-init disk as "cdrom".

Whether or not you need cloud-init is highly contingent on how the base image you boot your vm from is setup. If it already has everything you need for your to access it and operate it, then obviously cloud-init is optional at that point. And actually, some images don't even have it (the guest os has to run cloud-init for it to work, otherwise nothing will happen).

However, cloud-init has been a game changer for me and I highly recommend exploring the features it provides if your guest image supports it (https://cloudinit.readthedocs.io/en/latest/reference/modules.html). It is a little finicky at first, but great once you get familiar with its quirks.

ghuntley commented 1 year ago

I use cloud-init to generate an iso which is mounted onto a provisioned windows machine. the contents are sourced as a bootstrap.ps1 script. works well :) https://gist.github.com/ghuntley/e3465784b4a91d07788f88ef48d86118#file-main-tf-L17

troelsarvin commented 1 year ago

OK, thanks, I now think I understand the concepts better. I'm closing this issue.