Compare commits
No commits in common. "main" and "use-tofu" have entirely different histories.
25
main.tf
25
main.tf
@ -1,21 +1,3 @@
|
|||||||
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
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "proxmox_virtual_environment_vm" "server" {
|
resource "proxmox_virtual_environment_vm" "server" {
|
||||||
for_each = { for row in var.server : row.name => row }
|
for_each = { for row in var.server : row.name => row }
|
||||||
|
|
||||||
@ -113,7 +95,12 @@ 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[each.key]),
|
"a" : concat(
|
||||||
|
[
|
||||||
|
for k, v in flatten(coalesce(proxmox_virtual_environment_vm.server[each.value.name].ipv4_addresses, [])) :
|
||||||
|
v if length(regexall(proxmox_virtual_environment_vm.server[each.value.name].network_interface_names[k], "^(lo|docker).*")) == 0
|
||||||
|
],
|
||||||
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
output "output" {
|
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 => server
|
||||||
server,
|
|
||||||
{ ipv4_addresses = local.ipv4_addresses[server_key] },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,3 @@ variable "server_guest_agent" {
|
|||||||
type = bool
|
type = bool
|
||||||
default = false
|
default = false
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "server_netif_filter" {
|
|
||||||
type = string
|
|
||||||
default = "^(eth|ens|enp).+"
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user