ci / test (push) Successful in 29s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.2 KiB
Terraform
30 lines
1.2 KiB
Terraform
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, ipv4 = try(v.ipv4["eth0"], null) } }
|
|
}
|
|
|
|
# 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 } }
|
|
infra = { hosts = {
|
|
for k, v in proxmox_virtual_environment_container.infra : k => { ansible_host = v.ipv4["eth0"] } if try(v.ipv4["eth0"], null) != null
|
|
} }
|
|
} }
|
|
})
|
|
}
|