84 lines
2.0 KiB
HCL
84 lines
2.0 KiB
HCL
resource "proxmox_virtual_environment_vm" "this" {
|
|
for_each = var.nodes
|
|
|
|
node_name = each.value.host_node
|
|
|
|
name = each.key
|
|
description = each.value.machine_type == "controlplane" ? "Talos Control Plane" : "Talos Worker"
|
|
tags = each.value.machine_type == "controlplane" ? ["k8s", "control-plane"] : ["k8s", "worker"]
|
|
on_boot = true
|
|
vm_id = each.value.vm_id
|
|
|
|
machine = "q35"
|
|
scsi_hardware = "virtio-scsi-single"
|
|
bios = "seabios"
|
|
|
|
agent {
|
|
enabled = true
|
|
}
|
|
|
|
cpu {
|
|
cores = each.value.cpu
|
|
type = "host"
|
|
}
|
|
|
|
memory {
|
|
dedicated = each.value.ram_dedicated
|
|
}
|
|
|
|
network_device {
|
|
bridge = "vmbr0"
|
|
mac_address = each.value.mac_address
|
|
vlan_id = var.cluster.node_network_vlan
|
|
}
|
|
|
|
disk {
|
|
datastore_id = each.value.datastore_id
|
|
interface = "scsi0"
|
|
iothread = true
|
|
cache = "writethrough"
|
|
discard = "on"
|
|
ssd = true
|
|
file_format = "raw"
|
|
size = each.value.system_disk_size
|
|
file_id = proxmox_virtual_environment_download_file.this["${each.value.host_node}_${each.value.update == true ? local.update_image_id : local.image_id}"].id
|
|
}
|
|
|
|
boot_order = ["scsi0"]
|
|
|
|
operating_system {
|
|
type = "l26" # Linux Kernel 2.6 - 6.X.
|
|
}
|
|
|
|
# We use DHCP with static mappings --> Not needed
|
|
# initialization {
|
|
# datastore_id = each.value.datastore_id
|
|
|
|
# # Optional DNS Block. Update Nodes with a list value to use.
|
|
# dynamic "dns" {
|
|
# for_each = try(each.value.dns, null) != null ? { "enabled" = each.value.dns } : {}
|
|
# content {
|
|
# servers = each.value.dns
|
|
# }
|
|
# }
|
|
|
|
# ip_config {
|
|
# ipv4 {
|
|
# address = "${each.value.ip}/${var.cluster.subnet_mask}"
|
|
# gateway = var.cluster.gateway
|
|
# }
|
|
# }
|
|
# }
|
|
|
|
dynamic "hostpci" {
|
|
for_each = each.value.igpu ? [1] : []
|
|
content {
|
|
# Passthrough iGPU
|
|
device = "hostpci0"
|
|
mapping = "iGPU"
|
|
pcie = true
|
|
rombar = true
|
|
xvga = false
|
|
}
|
|
}
|
|
} |