diff options
Diffstat (limited to 'libvirt.tf')
| -rw-r--r-- | libvirt.tf | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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 } +} + |
