@@ -24,21 +24,23 @@ locals {
2424 l3_handoffs_ip_transit = flatten ([
2525 for border_device in try (local. catalyst_center . fabric . border_devices , []) : [
2626 for transit in try (border_device. l3_handoffs , []) : [
27- for vn in try (transit. virtual_networks ) : {
28- key = format (" %s/%s/%s" , vn. name , border_device. name , transit. name )
29- transit_name = try (transit. name , null )
30- device_name = try (border_device. name , null )
31- device_ip = try (local. all_devices [border_device . name ]. device_ip , null )
32- interface_name = try (transit. interface_name , null )
33- virtual_network_name = try (vn. name , null )
34- vlan_id = try (vn. vlan , null )
35- local_ip_address = try (vn. local_ip_address , null )
36- local_ipv6_address = try (vn. local_ipv6_address , null )
37- peer_ipv6_address = try (vn. peer_ipv6_address , null )
38- peer_ip_address = try (vn. peer_ip_address , null )
39- tcp_mss_adjustment = try (vn. tcp_mss_adjustment , null )
40- external_handoff_pool = try (border_device. external_handoff_pool , null )
41- }
27+ for interface in try (transit. interfaces , []) : [
28+ for vn in try (interface. virtual_networks ) : {
29+ key = format (" %s/%s/%s/%s" , vn. name , interface. name , transit. name , border_device. name )
30+ transit_name = try (transit. name , null )
31+ device_name = try (border_device. name , null )
32+ device_ip = try (local. all_devices [border_device . name ]. device_ip , null )
33+ interface_name = try (interface. name , null )
34+ virtual_network_name = try (vn. name , null )
35+ vlan_id = try (vn. vlan , null )
36+ local_ip_address = try (vn. local_ip_address , null )
37+ local_ipv6_address = try (vn. local_ipv6_address , null )
38+ peer_ipv6_address = try (vn. peer_ipv6_address , null )
39+ peer_ip_address = try (vn. peer_ip_address , null )
40+ tcp_mss_adjustment = try (vn. tcp_mss_adjustment , null )
41+ external_handoff_pool = try (border_device. external_handoff_pool , null )
42+ }
43+ ]
4244 ]
4345 ]
4446 ])
@@ -61,6 +63,10 @@ locals {
6163 l2_handoff_vlan_id_map = {
6264 for item in local . anycast_gateways : item . vlan_name => catalystcenter_anycast_gateway . anycast_gateway [item . name ]. vlan_id if try (item. vlan_name , null ) != null
6365 }
66+
67+ provisioned_devices = [
68+ for device in try (local. catalyst_center . inventory . devices , []) : device if strcontains (device. state , " PROVISION" )
69+ ]
6470}
6571
6672data "catalystcenter_network_devices" "all_devices" {
@@ -88,7 +94,7 @@ resource "catalystcenter_fabric_provision_device" "non_fabric_device" {
8894}
8995
9096resource "catalystcenter_fabric_provision_device" "border_device" {
91- for_each = { for device in try (local. catalyst_center . inventory . devices , []) : device . name => device if strcontains (device. state , " PROVISION" ) && device . device_role == " BORDER ROUTER" }
97+ for_each = { for device in try (local. catalyst_center . inventory . devices , []) : device . name => device if strcontains (device. state , " PROVISION" ) && device . device_role == " BORDER ROUTER" && try (device . fabric_roles , null ) != null }
9298
9399 site_id = try (local. site_id_list [each . value . site ], null )
94100 network_device_id = lookup (local. device_ip_to_id , each. value . device_ip , " " )
@@ -225,5 +231,13 @@ resource "catalystcenter_fabric_port_assignments" "port_assignments" {
225231 network_device_id = try (local. device_ip_to_id [each . value . device_ip ], " " )
226232 port_assignments = try (local. device_port_assignments [each . key ], null )
227233
228- depends_on = [catalystcenter_fabric_device . edge_device , catalystcenter_fabric_device . border_device , catalystcenter_fabric_provision_device . edge_device , catalystcenter_fabric_provision_device . edge_device , catalystcenter_anycast_gateway . anycast_gateway ]
234+ depends_on = [catalystcenter_fabric_device . edge_device , catalystcenter_fabric_device . border_device , catalystcenter_fabric_provision_device . edge_device , catalystcenter_anycast_gateway . anycast_gateway ]
229235}
236+
237+ resource "time_sleep" "provision_device_wait" {
238+ count = length (try (local. provisioned_devices , [])) > 0 ? 1 : 0
239+
240+ create_duration = " 10s"
241+
242+ depends_on = [catalystcenter_fabric_provision_device . edge_device , catalystcenter_wireless_device_provision . wireless_controller , catalystcenter_fabric_provision_device . non_fabric_device , catalystcenter_fabric_provision_device . border_device ]
243+ }
0 commit comments