Created
December 13, 2023 21:38
-
-
Save thatfunkymunki/93837f688f47d121a8d37e41dbdcf9fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_providers { | |
libvirt = { | |
source = "dmacvicar/libvirt" | |
} | |
macaddress = { | |
source = "ivoronin/macaddress" | |
} | |
} | |
} | |
provider "macaddress" { | |
} | |
provider "libvirt" { | |
uri = "qemu:///system" | |
} | |
locals { | |
name = "home_assistant" | |
} | |
resource "macaddress" "ext_int_mac" { | |
} | |
resource "libvirt_volume" "home_assistant_root" { | |
name = "${local.name}_root" | |
pool = "internal-ssd-xfs" | |
# download and unxz https://github.com/home-assistant/operating-system/releases/download/11.2/haos_ova-11.2.qcow2.xz | |
source = "file:///var/internal-storage/haos_ova-11.2.qcow2" | |
} | |
resource "libvirt_domain" "home_assistant" { | |
name = local.name | |
memory = 2048 | |
vcpu = 2 | |
machine = "q35" | |
qemu_agent = true | |
cpu { | |
mode = "host-passthrough" | |
} | |
firmware = "/usr/share/edk2/ovmf/OVMF_CODE_4M.qcow2" | |
nvram { | |
file = "/var/lib/libvirt/qemu/nvram/${local.name}_VARS.qcow2" | |
template = "/usr/share/edk2/ovmf/OVMF_VARS_4M.qcow2" | |
} | |
graphics { | |
type = "vnc" | |
listen_type = "address" | |
websocket = 0 | |
} | |
console { | |
type = "pty" | |
target_type = "serial" | |
target_port = 0 | |
} | |
network_interface { | |
macvtap = "enp1s0" | |
mac = macaddress.ext_int_mac.address | |
wait_for_lease = true | |
} | |
disk { | |
volume_id = libvirt_volume.home_assistant_root.id | |
} | |
} | |
output "result" { | |
value = { | |
(libvirt_domain.home_assistant.name) = libvirt_domain.home_assistant.network_interface[*].addresses[*], | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment