add logic to automatically detect firmware irrespective of the Linux distribution

This commit is contained in:
Lukas Greve
2025-10-20 11:28:28 +02:00
parent 7317e390c9
commit 8271e05336
2 changed files with 74 additions and 12 deletions

View File

@@ -20,19 +20,15 @@ resource "libvirt_domain" "domain" {
# ---- optional UEFI support ------------------------------------
# Firmware only add the string when a path is supplied
firmware = can(var.uefi_firmware) && length(var.uefi_firmware) > 0 ? var.uefi_firmware : null
firmware = local.detected_firmware
# NVRAM block dynamic block that is evaluated once per VM
dynamic "nvram" {
# create the block once if a firmware path *and* a template were given
for_each = (can(var.uefi_firmware) && length(var.uefi_firmware) > 0
&& can(var.uefi_nvram_template) && length(var.uefi_nvram_template) > 0
) ? [1] : []
for_each = (local.detected_firmware != null && local.detected_nvram != null) ? [1] : []
content {
# The NVRAM filename is perVM, but we can honour an optional suffix
file = "/var/lib/libvirt/qemu/nvram/${var.vm_name}-${count.index}${var.uefi_nvram_file_suffix}_VARS.fd"
template = var.uefi_nvram_template
template = local.detected_nvram
}
}
# ----------------------------------------------------------------