From 02348bb05f948e013a054b4d032442a33a203560 Mon Sep 17 00:00:00 2001 From: Marcus Weiner Date: Sat, 21 Sep 2024 22:02:54 +0200 Subject: [PATCH] Sort core routers to establish stable tunnel interfaces on sites (#31) --- data.tf | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/data.tf b/data.tf index 388f5d7..4427536 100644 --- a/data.tf +++ b/data.tf @@ -63,18 +63,20 @@ locals { devices = { for dev in data.netbox_devices.devices.devices : dev.name => dev } - core_devices = concat( - [for dev in data.netbox_devices.core_routers.devices : { + core_devices_unsorted = merge( + { for dev in data.netbox_devices.core_routers.devices : dev.name => { id = dev.device_id name = dev.name device = dev - }], - [for vm in data.netbox_virtual_machines.core_routers.vms : { + } }, + { for vm in data.netbox_virtual_machines.core_routers.vms : vm.name => { id = vm.vm_id name = vm.name vm = vm - }], + } }, ) + core_device_names_sorted = sort(keys(local.core_devices_unsorted)) + core_devices = [for name in local.core_device_names_sorted : local.core_devices_unsorted[name]] } data "netbox_ip_addresses" "core_primary" {