From 538ff0a46de955e65cb7f12c99ba566c76c19391 Mon Sep 17 00:00:00 2001 From: jerome Date: Wed, 21 May 2025 22:34:55 +0200 Subject: initial commit --- libvirt.tf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'libvirt.tf') diff --git a/libvirt.tf b/libvirt.tf index 102901e..51cfe10 100644 --- a/libvirt.tf +++ b/libvirt.tf @@ -7,7 +7,8 @@ resource "libvirt_volume" "base" { } resource "libvirt_volume" "image" { - name = "${var.nom}.qcow2" + count = var.vm_count + name = "${var.nom}-${count.index + 1}.qcow2" base_volume_id = libvirt_volume.base.id pool = "default" size = 10 * 1024 * 1024 * 1024 @@ -31,7 +32,8 @@ resource "libvirt_cloudinit_disk" "commoninit" { # Define KVM domain to create resource "libvirt_domain" "vm_domain" { - name = var.nom + count = var.vm_count + name = "${var.nom}-${count.index + 1}" memory = "2048" vcpu = 2 qemu_agent = true @@ -48,7 +50,7 @@ resource "libvirt_domain" "vm_domain" { } disk { - volume_id = libvirt_volume.image.id + volume_id = libvirt_volume.image[count.index].id } cloudinit = libvirt_cloudinit_disk.commoninit.id @@ -73,7 +75,11 @@ resource "libvirt_domain" "vm_domain" { # Output Server IP # Nécessite qemu-guest-agent sinon bloque la fin de l'installation !!! output "ip" { - value = "libvirt_domain.vm_domain.network_interface.0.addresses" + value = { + for vm in libvirt_domain.vm_domain.* : + vm.name => vm.network_interface.0.addresses } +} + -- cgit v1.2.3