Pim Kunis
721623c8fc
enable static IP for terraformed VMs restructure legacy code move hermes code to this repo don't use data disk for hermes leases
57 lines
1.1 KiB
HCL
57 lines
1.1 KiB
HCL
terraform {
|
|
required_providers {
|
|
libvirt = {
|
|
source = "dmacvicar/libvirt"
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "libvirt_volume" "os" {
|
|
name = "${var.name}.qcow2"
|
|
pool = "disks"
|
|
size = 1024 * 1024 * 1024 * var.storage
|
|
base_volume_name = "debian-bookworm.qcow2"
|
|
base_volume_pool = "images"
|
|
|
|
lifecycle {
|
|
replace_triggered_by = [
|
|
libvirt_cloudinit_disk.main.id
|
|
]
|
|
}
|
|
}
|
|
|
|
resource "libvirt_cloudinit_disk" "main" {
|
|
name = "${var.name}.iso"
|
|
pool = "cloudinit"
|
|
user_data = templatefile("${path.module}/files/cloud_init.cfg.tftpl", {
|
|
hostname = var.name
|
|
})
|
|
network_config = templatefile("${path.module}/files/network_config.cfg.tftpl", {
|
|
static_ip = var.static_ip
|
|
})
|
|
}
|
|
|
|
resource "libvirt_domain" "main" {
|
|
name = var.name
|
|
memory = var.ram
|
|
vcpu = 4
|
|
autostart = true
|
|
|
|
disk {
|
|
volume_id = libvirt_volume.os.id
|
|
}
|
|
|
|
network_interface {
|
|
bridge = "bridgedmz"
|
|
hostname = var.name
|
|
mac = var.mac
|
|
}
|
|
|
|
cloudinit = libvirt_cloudinit_disk.main.id
|
|
|
|
lifecycle {
|
|
replace_triggered_by = [
|
|
libvirt_cloudinit_disk.main.id
|
|
]
|
|
}
|
|
}
|