diff options
| author | jerome <jerome@xlinfo.fr> | 2025-01-29 18:51:37 +0100 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2025-01-29 18:51:37 +0100 |
| commit | 51f8d2c817097492cd762f2a1b151b0efeba0315 (patch) | |
| tree | cbcc1fce7efc9d78d23d05a8a428b9505cfc1e29 /libvirt.tf | |
| parent | 81b6cff609c1f70a62fda6e437756875244e2c55 (diff) | |
| download | kvm-51f8d2c817097492cd762f2a1b151b0efeba0315.tar.gz kvm-51f8d2c817097492cd762f2a1b151b0efeba0315.zip | |
ajout de variables
Diffstat (limited to 'libvirt.tf')
| -rw-r--r-- | libvirt.tf | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -1,15 +1,18 @@ # Defining VM Volume -resource "libvirt_volume" "rocky-qcow2" { - name = "rocky.qcow2" +resource "libvirt_volume" "qcow2_vol" { + name = "${var.nom}.qcow2" pool = "default" - #source = "https://download.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2" - source = "/home/jerome/Téléchargements/isos/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2" + source = var.image format = "qcow2" } # get user data info data "template_file" "user_data" { template = file("${path.module}/cloud_init.cfg") + vars = { + nom = var.nom + package = var.package + } } # Use CloudInit to add the instance @@ -20,25 +23,25 @@ resource "libvirt_cloudinit_disk" "commoninit" { } # Define KVM domain to create -resource "libvirt_domain" "rocky" { - name = "rocky" - memory = "2048" - vcpu = 2 +resource "libvirt_domain" "vm_domain" { + name = var.nom + memory = "2048" + vcpu = 2 qemu_agent = true - cpu { + cpu { mode = "host-passthrough" } network_interface { #network_name = "default" - bridge = "nm-bridge" + bridge = "bridge0" wait_for_lease = true } disk { - volume_id = libvirt_volume.rocky-qcow2.id + volume_id = libvirt_volume.qcow2_vol.id } cloudinit = libvirt_cloudinit_disk.commoninit.id @@ -57,6 +60,7 @@ resource "libvirt_domain" "rocky" { } # Output Server IP +# Nécessite qemu-guest-agent sinon bloque la fin de l'installation !!! output "ip" { - value = libvirt_domain.rocky.network_interface.0.addresses + value = libvirt_domain.vm_domain.network_interface.0.addresses } |
