Compare commits
3 Commits
bfb5f780c8
...
75b2ae6b40
Author | SHA1 | Date | |
---|---|---|---|
|
75b2ae6b40 | ||
|
3ae8b81859 | ||
|
3da3aa5cc4 |
@@ -15,7 +15,7 @@ provider "libvirt" {
|
||||
module "shared_modules" {
|
||||
source = "../../shared_modules"
|
||||
|
||||
vm_name = "ubuntu-cloud-server-2404-bios"
|
||||
vm_name = "u24-bios"
|
||||
image_location = "/var/lib/libvirt/images/noble-server-cloudimg-amd64.img"
|
||||
ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDMSuVlvOsMqx9qOrKKB1295FjCf2QhHfR1qola9brGkUcFL9dAztG2qdQnpiuPQ4OJpkedrO3C/ixEw1MLTL8l12SvYy/Q9QFguwylp35Nbw1p8h7jrX1FcNLRYltxkMgVhCs1InT5m0lf56bu1h7JfsMs7Ovsy3lU5OdK4h2MysTSKOLctsE4jDJ+XbJYQzj4rbfB/U7/9ple366cGl6xlaHxVfI4BUFWUOiVU4HWvZjrOM5fqPt+AUFRx1l2D7hLUZgOdVQwgO8GFn0sCyCIw0NCXbDn/H05pvWtTUPnyhj5TiseF8qW1byrrT5G8saxwvx8nbIK2tpPfKFdIiL7aj9bYQdltn1knJtvk3hpTPy4QvAbaoGfnfrPAsyU1A/CTw9SD/idvDT2wt1hVsm8EsnpovF7WT5z22fcgoFLDo+QCQrp7t1Wx0/Djay2nThi3FO3N051y5fQWoKOvTsm+rRhrzpDoc+Wtrtss3ua54qnQxHRx3YC0M5Xl9DINkwrcunbZBhozsDG2DzX9qcyzJsSfm9Zt5yM2lpcq+dGPRO1wedw4ogoOpobRr9Cja9W/lJvxmjgIiHz2HbSFPtk/VGjL6M7aQor/GDNN3ugSsfUoTTmNaS9+lWeg+tQWcFUPhYQtQB4/gHQ2u7+mQ0H3hVybsIKIh5XBpAdHQ7pww=="
|
||||
}
|
27
multiple/environments/ubuntu-cloud-server-2404-uefi/main.tf
Normal file
27
multiple/environments/ubuntu-cloud-server-2404-uefi/main.tf
Normal file
@@ -0,0 +1,27 @@
|
||||
terraform {
|
||||
required_version = ">= 0.13"
|
||||
required_providers {
|
||||
libvirt = {
|
||||
source = "dmacvicar/libvirt"
|
||||
version = "0.8.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "libvirt" {
|
||||
uri = "qemu:///system"
|
||||
}
|
||||
|
||||
module "shared_modules" {
|
||||
source = "../../shared_modules"
|
||||
|
||||
vm_name = "u24-uefi"
|
||||
image_location = "/var/lib/libvirt/images/noble-server-cloudimg-amd64.img"
|
||||
ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDMSuVlvOsMqx9qOrKKB1295FjCf2QhHfR1qola9brGkUcFL9dAztG2qdQnpiuPQ4OJpkedrO3C/ixEw1MLTL8l12SvYy/Q9QFguwylp35Nbw1p8h7jrX1FcNLRYltxkMgVhCs1InT5m0lf56bu1h7JfsMs7Ovsy3lU5OdK4h2MysTSKOLctsE4jDJ+XbJYQzj4rbfB/U7/9ple366cGl6xlaHxVfI4BUFWUOiVU4HWvZjrOM5fqPt+AUFRx1l2D7hLUZgOdVQwgO8GFn0sCyCIw0NCXbDn/H05pvWtTUPnyhj5TiseF8qW1byrrT5G8saxwvx8nbIK2tpPfKFdIiL7aj9bYQdltn1knJtvk3hpTPy4QvAbaoGfnfrPAsyU1A/CTw9SD/idvDT2wt1hVsm8EsnpovF7WT5z22fcgoFLDo+QCQrp7t1Wx0/Djay2nThi3FO3N051y5fQWoKOvTsm+rRhrzpDoc+Wtrtss3ua54qnQxHRx3YC0M5Xl9DINkwrcunbZBhozsDG2DzX9qcyzJsSfm9Zt5yM2lpcq+dGPRO1wedw4ogoOpobRr9Cja9W/lJvxmjgIiHz2HbSFPtk/VGjL6M7aQor/GDNN3ugSsfUoTTmNaS9+lWeg+tQWcFUPhYQtQB4/gHQ2u7+mQ0H3hVybsIKIh5XBpAdHQ7pww=="
|
||||
# ---- OPTIONAL UEFI SETTINGS ----------------------------------------------
|
||||
uefi_firmware = "/usr/share/edk2/x64/OVMF_CODE.4m.fd"
|
||||
uefi_nvram_template = "/usr/share/edk2/x64/OVMF_VARS.4m.fd"
|
||||
uefi_nvram_file_suffix = "-uefi"
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
}
|
@@ -4,6 +4,26 @@ resource "libvirt_domain" "domain" {
|
||||
memory = var.memory
|
||||
vcpu = var.vcpu
|
||||
cloudinit = libvirt_cloudinit_disk.commoninit.id
|
||||
|
||||
# ---- 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
|
||||
|
||||
# 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] : []
|
||||
|
||||
content {
|
||||
# The NVRAM filename is per‑VM, 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
|
||||
}
|
||||
}
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
cpu {
|
||||
mode = "host-passthrough"
|
||||
}
|
||||
|
@@ -102,3 +102,33 @@ variable "dns_local_only" {
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "uefi_firmware" {
|
||||
description = <<EOT
|
||||
Path to the UEFI firmware binary (OVMF_CODE.fd, QEMU_CODE.fd, …).
|
||||
Leave empty (or omit on the module call) to create a plain BIOS VM.
|
||||
EOT
|
||||
type = string
|
||||
default = "" # “BIOS only” when empty
|
||||
}
|
||||
|
||||
variable "uefi_nvram_template" {
|
||||
description = <<EOT
|
||||
Path to an NV‑RAM template that backs the UEFI NVRAM.
|
||||
If you specify a template, the VM will get a writable NVRAM block.
|
||||
Leave empty for a plain BIOS VM or if you don’t need UEFI NVRAM.
|
||||
EOT
|
||||
type = string
|
||||
default = "" # no NVRAM when empty
|
||||
}
|
||||
|
||||
variable "uefi_nvram_file_suffix" {
|
||||
description = <<EOT
|
||||
Optional file‑suffix fragment that is appended to the
|
||||
generated NVRAM file name. Useful when you want to put the
|
||||
files under a dedicated directory (`/var/lib/libvirt/qemu/uefi/nvram/…`).
|
||||
Empty string means “no suffix” (default behaviour).
|
||||
EOT
|
||||
type = string
|
||||
default = ""
|
||||
}
|
Reference in New Issue
Block a user