-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathiosxe_bgp.tf
More file actions
685 lines (626 loc) · 40.2 KB
/
Copy pathiosxe_bgp.tf
File metadata and controls
685 lines (626 loc) · 40.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
resource "iosxe_bgp" "bgp" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp, null) != null }
device = each.value.name
asn = try(local.device_config[each.value.name].routing.bgp.as_number, null)
default_ipv4_unicast = try(local.device_config[each.value.name].routing.bgp.default_ipv4_unicast, null)
log_neighbor_changes = try(local.device_config[each.value.name].routing.bgp.log_neighbor_changes, null)
router_id_loopback = try(local.device_config[each.value.name].routing.bgp.router_id_interface_type, null) == "Loopback" ? try(local.device_config[each.value.name].routing.bgp.router_id_interface_id, null) : null
router_id_ip = try(local.device_config[each.value.name].routing.bgp.router_id, null)
bgp_graceful_restart = try(local.device_config[each.value.name].routing.bgp.graceful_restart, null)
bgp_update_delay = try(local.device_config[each.value.name].routing.bgp.update_delay, null)
depends_on = [
iosxe_interface_loopback.loopback,
iosxe_system.system
]
}
locals {
bgp_peer_session_templates = flatten([
for device in local.devices : [
for template in try(local.device_config[device.name].routing.bgp.peer_session_templates, []) : {
key = format("%s/%s", device.name, template.template_name)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
template_name = try(template.template_name, null)
remote_as = try(template.remote_as, null)
description = try(template.description, null)
disable_connected_check = try(template.disable_connected_check, null)
ebgp_multihop = try(template.ebgp_multihop, null)
ebgp_multihop_max_hop = try(template.ebgp_multihop_max_hop, null)
update_source_interface_loopback = try(template.update_source_interface_type, null) == "Loopback" ? try(template.update_source_interface_id, null) : null
inherit_peer_session = try(template.inherit_peer_session, null)
ao_keychain = try(template.ao_keychain, null)
ao_include_tcp_options = try(template.ao_include_tcp_options, null)
ao_accept_mismatch_connections = try(template.ao_accept_mismatch_connections, null)
}
]
])
}
resource "iosxe_bgp_peer_session_template" "bgp_peer_session_template" {
for_each = { for e in local.bgp_peer_session_templates : e.key => e }
device = each.value.device
asn = each.value.asn
template_name = each.value.template_name
remote_as = each.value.remote_as
description = each.value.description
disable_connected_check = each.value.disable_connected_check
ebgp_multihop = each.value.ebgp_multihop
ebgp_multihop_max_hop = each.value.ebgp_multihop_max_hop
update_source_interface_loopback = each.value.update_source_interface_loopback
inherit_peer_session = each.value.inherit_peer_session
ao_keychain = each.value.ao_keychain
ao_include_tcp_options = each.value.ao_include_tcp_options
ao_accept_mismatch_connections = each.value.ao_accept_mismatch_connections
depends_on = [
iosxe_bgp.bgp,
iosxe_interface_loopback.loopback
]
}
locals {
bgp_neighbors = flatten([
for device in local.devices : [
for neighbor in try(local.device_config[device.name].routing.bgp.neighbors, []) : {
key = format("%s/%s", device.name, neighbor.ip)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
ip = try(neighbor.ip, null)
remote_as = try(neighbor.remote_as, null)
description = try(neighbor.description, null)
shutdown = try(neighbor.shutdown, null)
cluster_id = try(neighbor.cluster_id, null)
disable_connected_check = try(neighbor.disable_connected_check, null)
fall_over_default_enable = try(neighbor.fall_over_default_enable, null)
fall_over_default_route_map = try(neighbor.fall_over_default_route_map, null)
fall_over_bfd = try(neighbor.fall_over_bfd, null)
fall_over_bfd_multi_hop = try(neighbor.fall_over_bfd_multi_hop, null)
fall_over_bfd_single_hop = try(neighbor.fall_over_bfd_single_hop, null)
fall_over_bfd_check_control_plane_failure = try(neighbor.fall_over_bfd_check_control_plane_failure, null)
fall_over_bfd_strict_mode = try(neighbor.fall_over_bfd_strict_mode, null)
fall_over_maximum_metric_route_map = try(neighbor.fall_over_maximum_metric_route_map, null)
local_as = try(neighbor.local_as, null)
local_as_no_prepend = try(neighbor.local_as_no_prepend, null)
local_as_replace_as = try(neighbor.local_as_replace_as, null)
local_as_dual_as = try(neighbor.local_as_dual_as, null)
log_neighbor_changes = try(neighbor.log_neighbor_changes, null)
password_type = try(neighbor.password_type, null)
password = try(neighbor.password, null)
peer_group = try(neighbor.peer_group, null)
timers_keepalive_interval = try(neighbor.timers_keepalive, null)
timers_holdtime = try(neighbor.timers_holdtime, null)
timers_minimum_neighbor_hold = try(neighbor.timers_minimum_neighbor_holdtime, null)
ttl_security_hops = try(neighbor.ttl_security_hops, null)
update_source_interface_loopback = try(neighbor.update_source_interface_type, null) == "Loopback" ? try(neighbor.update_source_interface_id, null) : null
ebgp_multihop = try(neighbor.ebgp_multihop, null)
ebgp_multihop_max_hop = try(neighbor.ebgp_multihop_max_hop, null)
inherit_peer_session = try(neighbor.inherit_peer_session, null)
ao_keychain = try(neighbor.ao_keychain, null)
ao_include_tcp_options = try(neighbor.ao_include_tcp_options, null)
ao_accept_mismatch_connections = try(neighbor.ao_accept_mismatch_connections, null)
}
]
])
}
resource "iosxe_bgp_neighbor" "bgp_neighbor" {
for_each = { for e in local.bgp_neighbors : e.key => e }
device = each.value.device
asn = each.value.asn
ip = each.value.ip
remote_as = each.value.remote_as
description = each.value.description
shutdown = each.value.shutdown
cluster_id = each.value.cluster_id
disable_connected_check = each.value.disable_connected_check
fall_over_default_enable = each.value.fall_over_default_enable
fall_over_default_route_map = each.value.fall_over_default_route_map
fall_over_bfd = each.value.fall_over_bfd
fall_over_bfd_multi_hop = each.value.fall_over_bfd_multi_hop
fall_over_bfd_single_hop = each.value.fall_over_bfd_single_hop
fall_over_bfd_check_control_plane_failure = each.value.fall_over_bfd_check_control_plane_failure
fall_over_bfd_strict_mode = each.value.fall_over_bfd_strict_mode
fall_over_maximum_metric_route_map = each.value.fall_over_maximum_metric_route_map
local_as = each.value.local_as
local_as_no_prepend = each.value.local_as_no_prepend
local_as_replace_as = each.value.local_as_replace_as
local_as_dual_as = each.value.local_as_dual_as
log_neighbor_changes = each.value.log_neighbor_changes
password_type = each.value.password_type
password = each.value.password
peer_group = each.value.peer_group
timers_keepalive_interval = each.value.timers_keepalive_interval
timers_holdtime = each.value.timers_holdtime
timers_minimum_neighbor_hold = each.value.timers_minimum_neighbor_hold
ttl_security_hops = each.value.ttl_security_hops
update_source_interface_loopback = each.value.update_source_interface_loopback
ebgp_multihop = each.value.ebgp_multihop
ebgp_multihop_max_hop = each.value.ebgp_multihop_max_hop
inherit_peer_session = each.value.inherit_peer_session
ao_keychain = each.value.ao_keychain
ao_include_tcp_options = each.value.ao_include_tcp_options
ao_accept_mismatch_connections = each.value.ao_accept_mismatch_connections
depends_on = [
iosxe_bgp.bgp,
iosxe_bgp_peer_session_template.bgp_peer_session_template,
iosxe_bgp_address_family_ipv4.bgp_address_family_ipv4
]
}
locals {
template_peer_policies = flatten([
for device in local.devices : [
for peer_policy in try(local.device_config[device.name].routing.bgp.template_peer_policies, []) : {
key = format("%s/%s", device.name, peer_policy.name)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
name = try(peer_policy.name, null)
send_community = try(peer_policy.send_community, null)
route_reflector_client = try(peer_policy.route_reflector_client, null)
allowas_in_as_number = try(peer_policy.allowas_in_as_number, null)
as_override_split_horizon = try(peer_policy.as_override_split_horizon, null)
route_maps = try(length(peer_policy.route_maps) == 0, true) ? null : [for route_map in peer_policy.route_maps : {
in_out = try(route_map.direction, null)
route_map_name = try(route_map.route_map_name, null)
}]
}
]
])
}
resource "iosxe_bgp_peer_policy_template" "bgp_peer_policy_template" {
for_each = { for e in local.template_peer_policies : e.key => e }
device = each.value.device
asn = each.value.asn
name = each.value.name
send_community = each.value.send_community
route_reflector_client = each.value.route_reflector_client
allowas_in_as_number = each.value.allowas_in_as_number
as_override_split_horizon = each.value.as_override_split_horizon
route_maps = each.value.route_maps
depends_on = [iosxe_route_map.route_map]
}
resource "iosxe_bgp_address_family_ipv4" "bgp_address_family_ipv4" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp.address_family.ipv4_unicast, null) != null }
device = each.value.name
asn = iosxe_bgp.bgp[each.value.name].asn
af_name = "unicast"
ipv4_unicast_redistribute_connected = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.redistribute.connected, null)
ipv4_unicast_redistribute_connected_route_map = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.redistribute.connected_route_map, null)
ipv4_unicast_redistribute_connected_metric = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.redistribute.connected_metric, null)
ipv4_unicast_redistribute_static = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.redistribute.static, null)
ipv4_unicast_redistribute_static_route_map = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.redistribute.static_route_map, null)
ipv4_unicast_redistribute_static_metric = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.redistribute.static_metric, null)
ipv4_unicast_distance_bgp_external = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.distance_bgp_external, null)
ipv4_unicast_distance_bgp_internal = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.distance_bgp_internal, null)
ipv4_unicast_distance_bgp_local = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.distance_bgp_local, null)
ipv4_unicast_aggregate_addresses = try(length(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.aggregate_addresses) == 0, true) ? null : [for agg in local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.aggregate_addresses : {
ipv4_address = try(agg.address, null)
ipv4_mask = try(agg.mask, null)
}]
ipv4_unicast_networks_mask = try(length(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.networks) == 0, true) ? null : [for net in local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.networks : {
network = try(net.network, null)
mask = try(net.mask, null)
route_map = try(net.route_map, null)
backdoor = try(net.backdoor, null)
} if try(net.mask, null) != null]
ipv4_unicast_networks = try(length(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.networks) == 0, true) ? null : [for net in local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.networks : {
network = try(net.network, null)
route_map = try(net.route_map, null)
backdoor = try(net.backdoor, null)
} if try(net.mask, null) == null]
ipv4_unicast_admin_distances = try(length(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.admin_distances) == 0, true) ? null : [for ad in local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.admin_distances : {
distance = try(ad.distance, null)
source_ip = try(ad.source_ip, null)
wildcard = try(ad.wildcard, null)
acl = try(ad.acl, null)
}]
ipv4_unicast_maximum_paths_ebgp = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.ipv4_unicast_maximum_paths_ebgp, null)
ipv4_unicast_maximum_paths_ibgp = try(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.ipv4_unicast_maximum_paths_ibgp, null)
depends_on = [
iosxe_access_list_standard.access_list_standard,
iosxe_access_list_extended.access_list_extended
]
}
resource "iosxe_bgp_address_family_ipv6" "bgp_address_family_ipv6" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp.address_family.ipv6_unicast, null) != null }
device = each.value.name
asn = iosxe_bgp.bgp[each.value.name].asn
af_name = "unicast"
ipv6_unicast_redistribute_connected = try(local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.redistribute.connected, null)
ipv6_unicast_redistribute_connected_route_map = try(local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.redistribute.connected_route_map, null)
ipv6_unicast_redistribute_connected_metric = try(local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.redistribute.connected_metric, null)
ipv6_unicast_redistribute_static = try(local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.redistribute.static, null)
ipv6_unicast_redistribute_static_route_map = try(local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.redistribute.static_route_map, null)
ipv6_unicast_redistribute_static_metric = try(local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.redistribute.static_metric, null)
ipv6_unicast_networks = try(length(local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.networks) == 0, true) ? null : [for net in local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.networks : {
network = try(net.network, null)
route_map = try(net.route_map, null)
backdoor = try(net.backdoor, null)
}]
}
resource "iosxe_bgp_address_family_l2vpn" "bgp_address_family_l2vpn" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp.address_family.l2vpn_evpn, null) != null }
device = each.value.name
asn = iosxe_bgp.bgp[each.value.name].asn
af_name = "evpn"
rewrite_evpn_rt_asn = try(local.device_config[each.value.name].routing.bgp.address_family.l2vpn_evpn.rewrite_evpn_rt_asn, null)
bgp_nexthop_trigger_delay = try(local.device_config[each.value.name].routing.bgp.address_family.l2vpn_evpn.bgp_nexthop_trigger_delay, null)
}
resource "iosxe_bgp_address_family_ipv4_mvpn" "bgp_address_family_ipv4_mvpn" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp.address_family.ipv4_mvpn, null) != null }
device = each.value.name
asn = iosxe_bgp.bgp[each.value.name].asn
af_name = "mvpn"
}
resource "iosxe_bgp_address_family_vpnv4" "bgp_address_family_vpnv4" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp.address_family.vpnv4_unicast.enable, null) != null }
device = each.value.name
asn = iosxe_bgp.bgp[each.value.name].asn
af_name = "unicast"
}
resource "iosxe_bgp_address_family_vpnv6" "bgp_address_family_vpnv6" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp.address_family.vpnv6_unicast.enable, null) != null }
device = each.value.name
asn = iosxe_bgp.bgp[each.value.name].asn
af_name = "unicast"
}
resource "iosxe_bgp_address_family_ipv4_vrf" "bgp_address_family_ipv4_vrf" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp.address_family.ipv4_unicast.vrfs, null) != null }
device = each.value.name
asn = iosxe_bgp.bgp[each.value.name].asn
af_name = "unicast"
vrfs = try(length(local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.vrfs) == 0, true) ? null : [for vrf in local.device_config[each.value.name].routing.bgp.address_family.ipv4_unicast.vrfs : {
name = vrf.vrf
ipv4_unicast_advertise_l2vpn_evpn = try(vrf.advertise_l2vpn_evpn, null)
ipv4_unicast_redistribute_connected = try(vrf.redistribute.connected, null)
ipv4_unicast_redistribute_connected_route_map = try(vrf.redistribute.connected_route_map, null)
ipv4_unicast_redistribute_connected_metric = try(vrf.redistribute.connected_metric, null)
ipv4_unicast_router_id_ip = try(vrf.router_id, null)
ipv4_unicast_router_id_loopback = try(vrf.router_id_interface_type, null) == "Loopback" ? try(vrf.router_id_interface_id, null) : null
ipv4_unicast_distance_bgp_external = try(vrf.distance_bgp_external, null)
ipv4_unicast_distance_bgp_internal = try(vrf.distance_bgp_internal, null)
ipv4_unicast_distance_bgp_local = try(vrf.distance_bgp_local, null)
ipv4_unicast_aggregate_addresses = try(length(vrf.aggregate_addresses) == 0, true) ? null : [for agg in vrf.aggregate_addresses : {
ipv4_address = try(agg.address, null)
ipv4_mask = try(agg.mask, null)
summary_only = try(agg.summary_only, null)
}]
ipv4_unicast_admin_distances = try(length(vrf.admin_distances) == 0, true) ? null : [for ad in vrf.admin_distances : {
distance = try(ad.distance, null)
source_ip = try(ad.source_ip, null)
wildcard = try(ad.wildcard, null)
acl = try(ad.acl, null)
}]
ipv4_unicast_redistribute_static = try(vrf.redistribute.static, null)
ipv4_unicast_redistribute_static_route_map = try(vrf.redistribute.static_route_map, null)
ipv4_unicast_redistribute_static_metric = try(vrf.redistribute.static_metric, null)
ipv4_unicast_networks_mask = try(length(vrf.networks) == 0, true) ? null : [for net in vrf.networks : {
network = try(net.network, null)
mask = try(net.mask, null)
route_map = try(net.route_map, null)
backdoor = try(net.backdoor, null)
} if try(net.mask, null) != null]
ipv4_unicast_networks = try(length(vrf.networks) == 0, true) ? null : [for net in vrf.networks : {
network = try(net.network, null)
route_map = try(net.route_map, null)
backdoor = try(net.backdoor, null)
} if try(net.mask, null) == null]
ipv4_unicast_maximum_paths_ebgp = try(vrf.ipv4_unicast_maximum_paths_ebgp, null)
ipv4_unicast_maximum_paths_ibgp = try(vrf.ipv4_unicast_maximum_paths_ibgp, null)
ipv4_unicast_import_path_selection_all = try(vrf.import_path_selection_all, null)
}]
depends_on = [
iosxe_vrf.vrf,
iosxe_access_list_standard.access_list_standard,
iosxe_access_list_extended.access_list_extended
]
}
resource "iosxe_bgp_address_family_ipv6_vrf" "bgp_address_family_ipv6_vrf" {
for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].routing.bgp.address_family.ipv6_unicast.vrfs, null) != null }
device = each.value.name
asn = iosxe_bgp.bgp[each.value.name].asn
af_name = "unicast"
vrfs = try(length(local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.vrfs) == 0, true) ? null : [for vrf in local.device_config[each.value.name].routing.bgp.address_family.ipv6_unicast.vrfs : {
name = vrf.vrf
ipv6_unicast_advertise_l2vpn_evpn = try(vrf.advertise_l2vpn_evpn, null)
ipv6_unicast_redistribute_connected = try(vrf.redistribute.connected, null)
ipv6_unicast_redistribute_connected_route_map = try(vrf.redistribute.connected_route_map, null)
ipv6_unicast_redistribute_connected_metric = try(vrf.redistribute.connected_metric, null)
ipv6_unicast_redistribute_static = try(vrf.redistribute.static, null)
ipv6_unicast_redistribute_static_route_map = try(vrf.redistribute.static_route_map, null)
ipv6_unicast_redistribute_static_metric = try(vrf.redistribute.static_metric, null)
ipv6_unicast_networks = try(length(vrf.networks) == 0, true) ? null : [for net in vrf.networks : {
network = try(net.network, null)
route_map = try(net.route_map, null)
backdoor = try(net.backdoor, null)
evpn = try(net.evpn, null)
}]
}]
depends_on = [
iosxe_vrf.vrf
]
}
locals {
bgp_ipv4_unicast_neighbors = flatten([
for device in local.devices : [
for neighbor in try(local.device_config[device.name].routing.bgp.address_family.ipv4_unicast.neighbors, []) : {
key = format("%s/%s", device.name, neighbor.ip)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
ip = neighbor.ip
activate = try(neighbor.activate, true)
send_community = try(neighbor.send_community, null)
route_reflector_client = try(neighbor.route_reflector_client, null)
soft_reconfiguration = try(neighbor.soft_reconfiguration, null)
default_originate = try(neighbor.default_originate, null)
default_originate_route_map = try(neighbor.default_originate_route_map, null)
route_maps = try(length(neighbor.route_maps) == 0, true) ? null : [for rm in neighbor.route_maps : {
in_out = try(rm.direction, null)
route_map_name = try(rm.name, null)
}]
inherit_peer_policy = try(neighbor.inherit_peer_policy, null)
}
]
])
}
resource "iosxe_bgp_ipv4_unicast_neighbor" "bgp_ipv4_unicast_neighbor" {
for_each = { for e in local.bgp_ipv4_unicast_neighbors : e.key => e }
device = each.value.device
asn = each.value.asn
ip = each.value.ip
activate = each.value.activate
send_community = each.value.send_community
route_reflector_client = each.value.route_reflector_client
soft_reconfiguration = each.value.soft_reconfiguration
default_originate = each.value.default_originate
default_originate_route_map = each.value.default_originate_route_map
route_maps = each.value.route_maps
inherit_peer_policy = each.value.inherit_peer_policy
depends_on = [
iosxe_bgp_neighbor.bgp_neighbor,
iosxe_bgp_address_family_ipv4.bgp_address_family_ipv4
]
}
locals {
bgp_ipv6_unicast_neighbors = flatten([
for device in local.devices : [
for neighbor in try(local.device_config[device.name].routing.bgp.address_family.ipv6_unicast.neighbors, []) : {
key = format("%s/%s", device.name, neighbor.ip)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
ip = neighbor.ip
activate = try(neighbor.activate, true)
send_community = try(neighbor.send_community, null)
route_reflector_client = try(neighbor.route_reflector_client, null)
soft_reconfiguration = try(neighbor.soft_reconfiguration, null)
default_originate = try(neighbor.default_originate, null)
default_originate_route_map = try(neighbor.default_originate_route_map, null)
route_maps = try(length(neighbor.route_maps) == 0, true) ? null : [for rm in neighbor.route_maps : {
in_out = try(rm.direction, null)
route_map_name = try(rm.name, null)
}]
}
]
])
}
resource "iosxe_bgp_ipv6_unicast_neighbor" "bgp_ipv6_unicast_neighbor" {
for_each = { for e in local.bgp_ipv6_unicast_neighbors : e.key => e }
device = each.value.device
asn = each.value.asn
ip = each.value.ip
activate = each.value.activate
send_community = each.value.send_community
route_reflector_client = each.value.route_reflector_client
soft_reconfiguration = each.value.soft_reconfiguration
default_originate = each.value.default_originate
default_originate_route_map = each.value.default_originate_route_map
route_maps = each.value.route_maps
depends_on = [
iosxe_bgp_neighbor.bgp_neighbor,
iosxe_bgp_address_family_ipv6.bgp_address_family_ipv6
]
}
locals {
bgp_l2vpn_evpn_neighbors = flatten([
for device in local.devices : [
for neighbor in try(local.device_config[device.name].routing.bgp.address_family.l2vpn_evpn.neighbors, []) : {
key = format("%s/%s", device.name, neighbor.ip)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
ip = neighbor.ip
activate = try(neighbor.activate, true)
send_community = try(neighbor.send_community, null)
route_reflector_client = try(neighbor.route_reflector_client, null)
soft_reconfiguration = try(neighbor.soft_reconfiguration, null)
inherit_peer_policy = try(neighbor.inherit_peer_policy, null)
route_maps = try(length(neighbor.route_maps) == 0, true) ? null : [for rm in neighbor.route_maps : {
in_out = try(rm.in_out, null)
route_map_name = try(rm.name, null)
}]
}
]
])
}
resource "iosxe_bgp_l2vpn_evpn_neighbor" "bgp_l2vpn_evpn_neighbor" {
for_each = { for e in local.bgp_l2vpn_evpn_neighbors : e.key => e }
device = each.value.device
asn = each.value.asn
ip = each.value.ip
activate = each.value.activate
send_community = each.value.send_community
route_reflector_client = each.value.route_reflector_client
soft_reconfiguration = each.value.soft_reconfiguration
inherit_peer_policy = each.value.inherit_peer_policy
route_maps = each.value.route_maps
depends_on = [
iosxe_bgp_neighbor.bgp_neighbor,
iosxe_bgp_address_family_l2vpn.bgp_address_family_l2vpn,
iosxe_route_map.route_map
]
}
locals {
bgp_ipv4_mvpn_neighbors = flatten([
for device in local.devices : [
for neighbor in try(local.device_config[device.name].routing.bgp.address_family.ipv4_mvpn.neighbors, []) : {
key = format("%s/%s", device.name, neighbor.ip)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
ip = neighbor.ip
activate = try(neighbor.activate, null)
send_community = try(neighbor.send_community, null)
}
]
])
}
resource "iosxe_bgp_ipv4_mvpn_neighbor" "bgp_ipv4_mvpn_neighbor" {
for_each = { for e in local.bgp_ipv4_mvpn_neighbors : e.key => e }
device = each.value.device
asn = each.value.asn
ip = each.value.ip
activate = each.value.activate
send_community = each.value.send_community
depends_on = [iosxe_bgp_neighbor.bgp_neighbor]
}
locals {
bgp_ipv4_unicast_vrf_neighbors = flatten([
for device in local.devices : [
for vrf in try(local.device_config[device.name].routing.bgp.address_family.ipv4_unicast.vrfs, []) : [
for neighbor in try(vrf.neighbors, []) : {
key = format("%s/%s/%s", device.name, vrf.vrf, neighbor.ip)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
vrf = vrf.vrf
ip = neighbor.ip
remote_as = try(neighbor.remote_as, null)
description = try(neighbor.description, null)
shutdown = try(neighbor.shutdown, null)
cluster_id = try(neighbor.cluster_id, null)
log_neighbor_changes_disable = try(!neighbor.log_neighbor_changes, null)
password_type = try(neighbor.password_type, null)
password = try(neighbor.password, null)
timers_keepalive_interval = try(neighbor.timers_keepalive, null)
timers_holdtime = try(neighbor.timers_holdtime, null)
timers_minimum_neighbor_hold = try(neighbor.timers_minimum_neighbor_holdtime, null)
fall_over_default_route_map = try(neighbor.fall_over_default_route_map, null)
fall_over_bfd = try(neighbor.fall_over_bfd, null)
fall_over_bfd_multi_hop = try(neighbor.fall_over_bfd_multi_hop, null)
fall_over_bfd_single_hop = try(neighbor.fall_over_bfd_single_hop, null)
fall_over_bfd_check_control_plane_failure = try(neighbor.fall_over_bfd_check_control_plane_failure, null)
fall_over_bfd_strict_mode = try(neighbor.fall_over_bfd_strict_mode, null)
fall_over_maximum_metric_route_map = try(neighbor.fall_over_maximum_metric_route_map, null)
disable_connected_check = try(neighbor.disable_connected_check, null)
ttl_security_hops = try(neighbor.ttl_security_hops, null)
local_as = try(neighbor.local_as, null)
local_as_no_prepend = try(neighbor.local_as_no_prepend, null)
local_as_replace_as = try(neighbor.local_as_replace_as, null)
local_as_dual_as = try(neighbor.local_as_dual_as, null)
update_source_interface_loopback = try(neighbor.update_source_interface_type, null) == "Loopback" ? try(neighbor.update_source_interface_id, null) : null
activate = try(neighbor.activate, true)
send_community = try(neighbor.send_community, null)
route_reflector_client = try(neighbor.route_reflector_client, null)
soft_reconfiguration = try(neighbor.soft_reconfiguration, null)
default_originate = try(neighbor.default_originate, null)
default_originate_route_map = try(neighbor.default_originate_route_map, null)
route_maps = try(length(neighbor.route_maps) == 0, true) ? null : [for rm in neighbor.route_maps : {
in_out = try(rm.direction, null)
route_map_name = try(rm.name, null)
}]
ebgp_multihop = try(neighbor.ebgp_multihop, null)
ebgp_multihop_max_hop = try(neighbor.ebgp_multihop_max_hop, null)
ha_mode_graceful_restart = try(neighbor.ha_mode_graceful_restart, null)
next_hop_self = try(neighbor.next_hop_self, null)
next_hop_self_all = try(neighbor.next_hop_self_all, null)
advertisement_interval = try(neighbor.advertisement_interval, null)
}
]
]
])
}
resource "iosxe_bgp_ipv4_unicast_vrf_neighbor" "bgp_ipv4_unicast_vrf_neighbor" {
for_each = { for e in local.bgp_ipv4_unicast_vrf_neighbors : e.key => e }
device = each.value.device
asn = each.value.asn
vrf = each.value.vrf
ip = each.value.ip
remote_as = each.value.remote_as
description = each.value.description
shutdown = each.value.shutdown
cluster_id = each.value.cluster_id
log_neighbor_changes_disable = each.value.log_neighbor_changes_disable
password_type = each.value.password_type
password = each.value.password
timers_keepalive_interval = each.value.timers_keepalive_interval
timers_holdtime = each.value.timers_holdtime
timers_minimum_neighbor_hold = each.value.timers_minimum_neighbor_hold
fall_over_default_route_map = each.value.fall_over_default_route_map
fall_over_bfd = each.value.fall_over_bfd
fall_over_bfd_multi_hop = each.value.fall_over_bfd_multi_hop
fall_over_bfd_single_hop = each.value.fall_over_bfd_single_hop
fall_over_bfd_check_control_plane_failure = each.value.fall_over_bfd_check_control_plane_failure
fall_over_bfd_strict_mode = each.value.fall_over_bfd_strict_mode
fall_over_maximum_metric_route_map = each.value.fall_over_maximum_metric_route_map
disable_connected_check = each.value.disable_connected_check
ttl_security_hops = each.value.ttl_security_hops
local_as = each.value.local_as
local_as_no_prepend = each.value.local_as_no_prepend
local_as_replace_as = each.value.local_as_replace_as
local_as_dual_as = each.value.local_as_dual_as
update_source_interface_loopback = each.value.update_source_interface_loopback
activate = each.value.activate
send_community = each.value.send_community
route_reflector_client = each.value.route_reflector_client
soft_reconfiguration = each.value.soft_reconfiguration
default_originate = each.value.default_originate
default_originate_route_map = each.value.default_originate_route_map
route_maps = each.value.route_maps
ebgp_multihop = each.value.ebgp_multihop
ebgp_multihop_max_hop = each.value.ebgp_multihop_max_hop
ha_mode_graceful_restart = each.value.ha_mode_graceful_restart
next_hop_self = each.value.next_hop_self
next_hop_self_all = each.value.next_hop_self_all
advertisement_interval = each.value.advertisement_interval
depends_on = [
iosxe_vrf.vrf,
iosxe_bgp_address_family_ipv4_vrf.bgp_address_family_ipv4_vrf
]
}
locals {
bgp_bmp_servers = flatten([
for device in local.devices : [
for server in try(local.device_config[device.name].routing.bgp.bmp_servers, []) : {
key = format("%s/%s", device.name, server.id)
device = device.name
asn = iosxe_bgp.bgp[device.name].asn
server_id = try(server.id, null)
address = try(server.address, null)
port_number = try(server.port_number, null)
activate = try(server.activate, null)
description = try(server.description, null)
failure_retry_delay = try(server.failure_retry_delay, null)
flapping_delay = try(server.flapping_delay, null)
initial_delay = try(server.initial_delay, null)
stats_reporting_period = try(server.stats_reporting_period, null)
update_source_loopback = try(server.update_source_interface_type, null) == "Loopback" ? try(server.update_source_interface_id, null) : null
update_source_gigabit_ethernet = try(server.update_source_interface_type, null) == "GigabitEthernet" ? try(server.update_source_interface_id, null) : null
update_source_ten_gigabit_ethernet = try(server.update_source_interface_type, null) == "TenGigabitEthernet" ? try(server.update_source_interface_id, null) : null
update_source_vlan = try(server.update_source_interface_type, null) == "Vlan" ? try(server.update_source_interface_id, null) : null
}
]
])
}
resource "iosxe_bgp_bmp_server" "bgp_bmp_server" {
for_each = { for e in local.bgp_bmp_servers : e.key => e }
device = each.value.device
asn = each.value.asn
server_id = each.value.server_id
address = each.value.address
port_number = each.value.port_number
activate = each.value.activate
description = each.value.description
failure_retry_delay = each.value.failure_retry_delay
flapping_delay = each.value.flapping_delay
initial_delay = each.value.initial_delay
stats_reporting_period = each.value.stats_reporting_period
update_source_loopback = each.value.update_source_loopback
update_source_gigabit_ethernet = each.value.update_source_gigabit_ethernet
update_source_ten_gigabit_ethernet = each.value.update_source_ten_gigabit_ethernet
update_source_vlan = each.value.update_source_vlan
depends_on = [
iosxe_bgp.bgp
]
}