hklbgd-infra/tofu/service-vm/main.tf

63 lines
1.3 KiB
Terraform
Raw Permalink Normal View History

2024-03-01 16:34:20 +01:00
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.7.6"
}
}
}
resource "libvirt_volume" "rootfs" {
name = "${var.domain_name}-rootfs.qcow2"
pool = var.domain_pool
base_volume_id = var.domain_base_volume_id
}
resource "libvirt_volume" "data" {
name = "${var.domain_name}-data.qcow2"
pool = var.domain_pool
size = var.domain_data_volume_size
format = "qcow2"
lifecycle {
prevent_destroy = true
}
}
resource "libvirt_ignition" "ign" {
name = "${var.domain_name}-service.ign"
pool = var.domain_pool
content = "${var.domain_ignition_path}"
}
resource "libvirt_domain" "service" {
name = var.domain_name
autostart = true
memory = var.domain_memory
vcpu = var.domain_vcpu
coreos_ignition = libvirt_ignition.ign.id
disk {
volume_id = libvirt_volume.rootfs.id
}
disk {
volume_id = libvirt_volume.data.id
}
network_interface {
network_id = var.domain_network.network_id
hostname = var.domain_network.hostname
addresses = var.domain_network.addresses
mac = var.domain_network.mac_address
wait_for_lease = true
}
console {
type = "pty"
target_port = "0"
target_type = "serial"
}
graphics {
type = "spice"
}
}