resource "libvirt_domain" "cs10-repo" { name = "cs10-repo.mx-os" memory = var.guest_memory memory_unit = "MiB" vcpu = var.guest_vcpu running = true autostart = true type = "kvm" os = { type = "hvm" arch = "x86_64" machine = "q35" firmware = "efi" loader_path = "/usr/share/edk2/ovmf/OVMF_CODE_4M.secboot.qcow2" loader_readonly = true loader_secure = true loader_type = "pflash" nvram = { path = "/var/lib/libvirt/qemu/nvram/cs10-repo.mx-os_VARS.qcow2" template = "/usr/share/edk2/ovmf/OVMF_VARS_4M.secboot.qcow2" format = "qcow2" } } cpu = { mode = "host-passthrough" } features = { acpi = true apic = {} } devices = { disks = [ { type = "volume" driver = { type = "qcow2" } source = { volume = { pool = var.pool_name volume = libvirt_volume.cs10-repo-system.name } } target = { dev = "vda" bus = "virtio" } }, { type = "volume" device = "cdrom" readonly = true driver = { type = "raw" } source = { volume = { pool = var.pool_name volume = libvirt_cloudinit_disk.cs10-repo-cloudinit.name } } target = { dev = "sda" bus = "sata" } } ] interfaces = [ { type = "network" model = { type = "virtio" } source = { network = { network = "default" } } } ] consoles = [ { type = "pty" target_type = "virtio" target_port = "1" } ] video = { type = "virtio" } } } resource "libvirt_volume" "cs10-repo-system" { name = "cs10-repo.mx-os-system.qcow2" pool = var.pool_name capacity = 536870912000 # 500 GiB (500 * 1024 * 1024 * 1024) target = { format = { type = "qcow2" } } create = { content = { url = "file://${var.base_image_path}" } } } resource "libvirt_cloudinit_disk" "cs10-repo-cloudinit" { name = "cs10-repo.mx-os-cloudinit.iso" user_data = templatefile("templates/cloudinit.cfg.tftpl", { root_password = var.root_password hostname = "cs10-repo.mx-os" }) meta_data = yamlencode({ instance-id = "cs10-repo.mx-os" local-hostname = "cs10-repo.mx-os" }) } resource "libvirt_volume" "cs10-repo-cloudinit-volume" { name = "cs10-repo.mx-os-cloudinit.iso" pool = var.pool_name target = { format = { type = "iso" } } create = { content = { url = libvirt_cloudinit_disk.cs10-repo-cloudinit.path } } }