add terraform project
This commit is contained in:
32
terraform/locals.tf
Normal file
32
terraform/locals.tf
Normal file
@@ -0,0 +1,32 @@
|
||||
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"]
|
||||
])[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"]
|
||||
])[0]
|
||||
]
|
||||
|
||||
# Use DHCP IPs for initial connection and configuration apply
|
||||
# Note: If static IPs are configured via var.controlplane_ips/var.worker_ips,
|
||||
# Talos will reconfigure the network after initial apply, but we connect via DHCP
|
||||
controlplane_ips = local.controlplane_dhcp_ips
|
||||
worker_ips = local.worker_dhcp_ips
|
||||
|
||||
# For client config and bootstrap, use static IPs if configured, otherwise 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?:\\/\\//", "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user