Skip to content

Instantly share code, notes, and snippets.

@thatfunkymunki
Created December 12, 2023 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thatfunkymunki/d61db0baf8821fe299e6cad9d163aaad to your computer and use it in GitHub Desktop.
Save thatfunkymunki/d61db0baf8821fe299e6cad9d163aaad to your computer and use it in GitHub Desktop.
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
}
macaddress = {
source = "ivoronin/macaddress"
version = "0.3.2"
}
}
}
provider "macaddress" {
}
provider "libvirt" {
uri = "qemu:///system"
}
resource "macaddress" "ext_int_mac" {
}
resource "libvirt_volume" "home_assistant_root" {
name = "home_assistant_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 = "home_assistant"
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/home_assistant_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