32 lines
1.3 KiB
HCL
32 lines
1.3 KiB
HCL
locals {
|
|
# Get current DHCP IPs from QEMU guest agent (from VM resource computed attribute)
|
|
# Find first non-loopback, non-empty IP address from any interface
|
|
controlplane_dhcp_ips = [
|
|
for vm in proxmox_virtual_environment_vm.controlplane :
|
|
flatten([
|
|
for iface_ips in vm.ipv4_addresses :
|
|
[for ip in iface_ips : ip if ip != "127.0.0.1" && ip != "169.254.116.108"]
|
|
])[0]
|
|
]
|
|
|
|
worker_dhcp_ips = [
|
|
for vm in proxmox_virtual_environment_vm.worker :
|
|
flatten([
|
|
for iface_ips in vm.ipv4_addresses :
|
|
[for ip in iface_ips : ip if ip != "127.0.0.1" && ip != "169.254.116.108"]
|
|
])[0]
|
|
]
|
|
|
|
# Use configured static IPs if set, otherwise use IPs from QEMU guest agent
|
|
# (On first run, uses DHCP from guest agent; after config, uses static IPs)
|
|
controlplane_ips = length(var.controlplane_ips) > 0 ? var.controlplane_ips : local.controlplane_dhcp_ips
|
|
worker_ips = length(var.worker_ips) > 0 ? var.worker_ips : local.worker_dhcp_ips
|
|
|
|
# For client config and bootstrap, use static IPs if configured, otherwise current DHCP
|
|
controlplane_endpoints = length(var.controlplane_ips) > 0 ? var.controlplane_ips : local.controlplane_dhcp_ips
|
|
|
|
# Extract Proxmox API URL without protocol for node labeling
|
|
proxmox_host = replace(var.proxmox_endpoint, "/^https?:\\/\\//", "")
|
|
}
|
|
|