Make enabling cloud_init optionnal

For cloud images that needs it, cloud_init can be enabled in the main.tf file. This change will allow deployments that does not require cloud_init to be supported
This commit is contained in:
Lukas Greve
2025-09-18 20:24:38 +02:00
parent 75b2ae6b40
commit 902420a3ea
6 changed files with 18 additions and 4 deletions

View File

@@ -1,8 +1,11 @@
# Only create the cloudinit disk if enabled
resource "libvirt_cloudinit_disk" "commoninit" {
name = var.cloudinit_filename
count = var.enable_cloudinit ? var.instance_count : 0
name = "${var.cloudinit_filename}-${count.index}"
user_data = templatefile("${path.module}/cloud_init.yaml", {
ssh_key = var.ssh_key
})
pool = "${var.vm_name}-pool"
pool = "${var.vm_name}-pool"
depends_on = [libvirt_pool.tf_tmp_storage]
}