Compare commits

...

3 Commits

Author SHA1 Message Date
Lukas Greve
41302119a7 increase vCPU to 2 and make variable ssh_key optional 2025-10-06 12:08:45 +02:00
Lukas Greve
d0dc1f02f6 phyllome os support 2025-10-06 12:07:48 +02:00
Lukas Greve
1f1f2ce12f q35 chipset by default 2025-10-06 12:07:19 +02:00
4 changed files with 56 additions and 1 deletions

View 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 = "phyllome-42-uefi"
image_location = "/var/lib/libvirt/images/virtual-desktop-hypervisor.img"
enable_cloudinit = false
# ---- 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"
# ----------------------------------------------------------------
}

View File

@@ -3,6 +3,17 @@ resource "libvirt_domain" "domain" {
name = "${var.vm_name}-${count.index}"
memory = var.memory
vcpu = var.vcpu
machine = "q35"
# The chipset q35, which does not support the IDE bus, does not work with the terraform-provider-libvirt cloud-init implementation,
# which creates an ISO attached to an IDE bus by default. Workaround is implemented
# https://github.com/dmacvicar/terraform-provider-libvirt/issues/1137#issuecomment-2592329846
# A cleaner solution might be the following :
# https://github.com/dmacvicar/terraform-provider-libvirt/pull/895#issuecomment-1911167872
xml {
xslt = file("${path.module}/q35-workaround.xslt")
}
# Only include cloudinit if enabled
cloudinit = var.enable_cloudinit ? libvirt_cloudinit_disk.commoninit[count.index].id : null

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/domain/devices/disk[@device='cdrom']/target/@bus">
<xsl:attribute name="bus">
<xsl:value-of select="'sata'"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="/domain/devices/disk[@device='cdrom']/alias" />
</xsl:stylesheet>

View File

@@ -49,6 +49,7 @@ variable "enable_cloudinit" {
variable "ssh_key" {
description = "SSH authorized keys for cloud-init"
type = string
default = ""
}
variable "user_data" {
@@ -70,7 +71,7 @@ variable "memory" {
variable "vcpu" {
description = "Number of virtual CPUs"
type = number
default = 1
default = 2
}
variable "network_mode" {