Compare commits

..

No commits in common. "main" and "v1.0.3" have entirely different histories.
main ... v1.0.3

3 changed files with 15 additions and 19 deletions

22
main.tf
View File

@ -1,19 +1,19 @@
locals {
ipv4_addresses = {
for server_key, server in var.server : server.name => flatten([
for k, v in try(proxmox_virtual_environment_vm.server[server.name].ipv4_addresses, []) :
v if length(regexall(try(server.netif_filter, var.server_netif_filter), proxmox_virtual_environment_vm.server[server.name].network_interface_names[k])) > 0
ipv4_addresses = flatten([
for server_key, server in var.server : [
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
]
])
}
}
locals {
ipv6_addresses = {
for server_key, server in var.server : server.name => flatten([
for k, v in try(proxmox_virtual_environment_vm.server[server.name].ipv6_addresses, []) :
v if length(regexall(try(server.netif_filter, var.server_netif_filter), proxmox_virtual_environment_vm.server[server.name].network_interface_names[k])) > 0
ipv6_addresses = flatten([
for server_key, server in var.server : [
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
]
])
}
}
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)],
"properties" : {
"name" : each.value.name,
"a" : concat(local.ipv4_addresses[each.key]),
"a" : concat(local.ipv4_addresses, local.ipv6_addresses),
}
})
}

View File

@ -2,7 +2,8 @@ output "output" {
value = {
for server_key, server in proxmox_virtual_environment_vm.server : server_key => merge(
server,
{ ipv4_addresses = local.ipv4_addresses[server_key] },
{ ipv4_addresses = local.ipv4_addresses },
{ ipv6_addresses = local.ipv6_addresses }
)
}
}

View File

@ -43,8 +43,3 @@ variable "server_guest_agent" {
type = bool
default = false
}
variable "server_netif_filter" {
type = string
default = "^(eth|ens|enp).+"
}