fix: use ip address map indexed by server key #4
14
main.tf
14
main.tf
@ -1,19 +1,19 @@
|
|||||||
locals {
|
locals {
|
||||||
ipv4_addresses = flatten([
|
ipv4_addresses = {
|
||||||
for server_key, server in var.server : [
|
for server_key, server in var.server : server.name => flatten([
|
||||||
for k, v in coalescelist(proxmox_virtual_environment_vm.server[server.name].ipv4_addresses, []) :
|
for k, v in coalescelist(proxmox_virtual_environment_vm.server[server.name].ipv4_addresses, []) :
|
||||||
v if length(regexall("^(lo|docker|veth).*", proxmox_virtual_environment_vm.server[server.name].network_interface_names[k])) == 0
|
v if length(regexall("^(lo|docker|veth).*", proxmox_virtual_environment_vm.server[server.name].network_interface_names[k])) == 0
|
||||||
]
|
|
||||||
])
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
ipv6_addresses = flatten([
|
ipv6_addresses = {
|
||||||
for server_key, server in var.server : [
|
for server_key, server in var.server : server.name => flatten([
|
||||||
for k, v in coalescelist(proxmox_virtual_environment_vm.server[server.name].ipv6_addresses, []) :
|
for k, v in coalescelist(proxmox_virtual_environment_vm.server[server.name].ipv6_addresses, []) :
|
||||||
v if length(regexall("^(lo|docker|veth).*", proxmox_virtual_environment_vm.server[server.name].network_interface_names[k])) == 0
|
v if length(regexall("^(lo|docker|veth).*", proxmox_virtual_environment_vm.server[server.name].network_interface_names[k])) == 0
|
||||||
]
|
|
||||||
])
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "proxmox_virtual_environment_vm" "server" {
|
resource "proxmox_virtual_environment_vm" "server" {
|
||||||
@ -113,7 +113,7 @@ resource "restapi_object" "ucs_server" {
|
|||||||
"position" : var.ucs_zones[try(each.value.dns_zone, var.server_dns_zone)],
|
"position" : var.ucs_zones[try(each.value.dns_zone, var.server_dns_zone)],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"name" : each.value.name,
|
"name" : each.value.name,
|
||||||
"a" : concat(local.ipv4_addresses, local.ipv6_addresses),
|
"a" : concat(local.ipv4_addresses[each.key]),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,7 @@ output "output" {
|
|||||||
value = {
|
value = {
|
||||||
for server_key, server in proxmox_virtual_environment_vm.server : server_key => merge(
|
for server_key, server in proxmox_virtual_environment_vm.server : server_key => merge(
|
||||||
server,
|
server,
|
||||||
{ ipv4_addresses = local.ipv4_addresses },
|
{ ipv4_addresses = local.ipv4_addresses[server_key] },
|
||||||
{ ipv6_addresses = local.ipv6_addresses }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user