locals { # Erste IPv4 der Gast-Netzkarte laut qemu-guest-agent (ohne lo, Docker- und Bridge-Interfaces) gpu_vm_ipv4 = { for k, v in proxmox_virtual_environment_vm.gpu : k => try(flatten([ for i, name in v.network_interface_names : v.ipv4_addresses[i] if !contains(["lo"], name) && !startswith(name, "docker") && !startswith(name, "br-") && !startswith(name, "veth") ])[0], null) } } output "gpu_vms" { value = { for k, v in proxmox_virtual_environment_vm.gpu : k => { node = v.node_name, vmid = v.vm_id, ipv4 = local.gpu_vm_ipv4[k] } } } output "infra_containers" { value = { for k, v in proxmox_virtual_environment_container.infra : k => { node = v.node_name, vmid = v.vm_id } } } # tofu output -raw ansible_inventory > ../ansible/inventory.generated.yml output "ansible_inventory" { value = yamlencode({ all = { children = { gpu_vms = { hosts = { for k, ip in local.gpu_vm_ipv4 : k => { ansible_host = ip } if ip != null } } } } }) }