locals { domain = "network.tjo.cloud" nodes = { for k, v in var.nodes : k => merge(v, { domain = local.domain id = 700 + index(keys(var.nodes), k) hash = sha1(v.host) wan_mac_address = v.mac_address != null ? v.mac_address : "AA:BB:00:00:${format("%v:%v", substr(sha1(v.host), 0, 2), substr(sha1(v.host), 2, 2))}" private_mac_address = "AA:BB:00:11:${format("%v:%v", substr(sha1(v.host), 0, 2), substr(sha1(v.host), 2, 2))}" }) } } resource "proxmox_virtual_environment_network_linux_bridge" "vmbr0" { for_each = local.nodes node_name = each.value.host name = "vmbr0" comment = "Main interface bridge for VMs." address = each.value.address gateway = each.value.gateway ports = each.value.bridge_ports } resource "proxmox_virtual_environment_network_linux_bridge" "vmbr1" { for_each = local.nodes node_name = each.value.host name = "vmbr1" comment = "Private network for VMs." } resource "proxmox_virtual_environment_file" "iso" { for_each = local.nodes content_type = "iso" datastore_id = each.value.iso_storage node_name = each.value.host source_file { path = "${path.module}/../iso/openwrt-23.05.5-x86-64-generic-ext4-combined-efi.img" } } resource "proxmox_virtual_environment_vm" "nodes" { for_each = local.nodes vm_id = each.value.id name = "${each.value.host}.${each.value.domain}" node_name = each.value.host description = <