-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathnxos_vpc.tf
More file actions
68 lines (66 loc) · 7.49 KB
/
Copy pathnxos_vpc.tf
File metadata and controls
68 lines (66 loc) · 7.49 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
locals {
vpc_interfaces_map = { for device in local.devices : device.name =>
{ for int in try(local.device_config[device.name].interfaces.port_channels, []) : tostring(int.vpc_id) => {
port_channel_interface_dn = "sys/intf/aggr-[po${int.id}]"
} if try(int.vpc_id, null) != null }
}
vpc_keepalive = { for device in local.devices : device.name => {
precedence_is_string = try(local.device_config[device.name].vpc.keepalive.precedence, null) != null ? can(tonumber(try(local.device_config[device.name].vpc.keepalive.precedence))) == false : false
precedence_is_number = try(local.device_config[device.name].vpc.keepalive.precedence, null) != null ? can(tonumber(try(local.device_config[device.name].vpc.keepalive.precedence))) : false
precedence_value = try(local.device_config[device.name].vpc.keepalive.precedence, null)
tos_is_string = try(local.device_config[device.name].vpc.keepalive.tos, null) != null ? can(tonumber(try(local.device_config[device.name].vpc.keepalive.tos))) == false : false
tos_is_number = try(local.device_config[device.name].vpc.keepalive.tos, null) != null ? can(tonumber(try(local.device_config[device.name].vpc.keepalive.tos))) : false
tos_value = try(local.device_config[device.name].vpc.keepalive.tos, null)
tos_byte_value = try(local.device_config[device.name].vpc.keepalive.tos_byte, null)
} }
}
resource "nxos_vpc" "vpc" {
for_each = { for device in local.devices : device.name => device
if try(local.device_config[device.name].vpc.domain_id, null) != null }
device = each.key
admin_state = null
instance_admin_state = null
domain_id = try(local.device_config[each.key].vpc.domain_id, null)
auto_recovery = try(local.device_config[each.key].vpc.auto_recovery, null) == null ? null : (try(local.device_config[each.key].vpc.auto_recovery) ? "enabled" : "disabled")
auto_recovery_interval = try(local.device_config[each.key].vpc.auto_recovery_reload_delay, null)
delay_restore_orphan_port = try(local.device_config[each.key].vpc.delay_restore_orphan_port, null)
delay_restore_svi = try(local.device_config[each.key].vpc.delay_restore_interface_vlan, null)
delay_restore_vpc = try(local.device_config[each.key].vpc.delay_restore, null)
dscp = try(local.device_config[each.key].vpc.dscp, null)
fast_convergence = try(local.device_config[each.key].vpc.fast_convergence, null) == null ? null : (try(local.device_config[each.key].vpc.fast_convergence) ? "enabled" : "disabled")
graceful_consistency_check = try(local.device_config[each.key].vpc.graceful_consistency_check, null) == null ? null : (try(local.device_config[each.key].vpc.graceful_consistency_check) ? "enabled" : "disabled")
l3_peer_router = try(local.device_config[each.key].vpc.layer3_peer_router, null) == null ? null : (try(local.device_config[each.key].vpc.layer3_peer_router) ? "enabled" : "disabled")
l3_peer_router_syslog = try(local.device_config[each.key].vpc.layer3_peer_router_syslog, null) == null ? null : (try(local.device_config[each.key].vpc.layer3_peer_router_syslog) ? "enabled" : "disabled")
l3_peer_router_syslog_interval = try(local.device_config[each.key].vpc.layer3_peer_router_syslog_interval, null)
peer_gateway = try(local.device_config[each.key].vpc.peer_gateway, null) == null ? null : (try(local.device_config[each.key].vpc.peer_gateway) ? "enabled" : "disabled")
peer_ip = try(local.device_config[each.key].vpc.virtual_peer_link_destination, null)
peer_switch = try(local.device_config[each.key].vpc.peer_switch, null) == null ? null : (try(local.device_config[each.key].vpc.peer_switch) ? "enabled" : "disabled")
role_priority = try(local.device_config[each.key].vpc.role_priority, null)
sys_mac = try(local.device_config[each.key].vpc.system_mac, null)
system_priority = try(local.device_config[each.key].vpc.system_priority, null)
track = try(local.device_config[each.key].vpc.track, null)
virtual_ip = try(local.device_config[each.key].vpc.virtual_peer_link_source, null)
delay_peer_link_bringup = try(local.device_config[each.key].vpc.delay_peer_link, null)
exclude_svi = try(provider::utils::normalize_vlans(try(local.device_config[each.key].vpc.dual_active_exclude_interface_vlans), "string-nxos"), null)
mac_bpdu_source_version_2 = try(local.device_config[each.key].vpc.mac_address_bpdu_source_version_2, null)
peer_gateway_exclude_vlan = try(provider::utils::normalize_vlans(try(local.device_config[each.key].vpc.peer_gateway_exclude_vlans), "string-nxos"), null)
keepalive_destination_ip = try(local.device_config[each.key].vpc.keepalive.destination_ip, null)
keepalive_flush_timeout = try(local.device_config[each.key].vpc.keepalive.hold_timeout, null)
keepalive_interval = try(local.device_config[each.key].vpc.keepalive.interval, null)
keepalive_precedence_type = local.vpc_keepalive[each.key].precedence_is_string ? tostring(local.vpc_keepalive[each.key].precedence_value) : null
keepalive_precedence_value = local.vpc_keepalive[each.key].precedence_is_number ? tonumber(local.vpc_keepalive[each.key].precedence_value) : null
keepalive_source_ip = try(local.device_config[each.key].vpc.keepalive.source_ip, null)
keepalive_timeout = try(local.device_config[each.key].vpc.keepalive.timeout, null)
keepalive_type_of_service_byte = local.vpc_keepalive[each.key].tos_byte_value
keepalive_type_of_service_configuration_type = local.vpc_keepalive[each.key].tos_byte_value != null ? "tos-byte" : local.vpc_keepalive[each.key].tos_is_string ? "tos-type" : local.vpc_keepalive[each.key].tos_is_number ? "tos-value" : local.vpc_keepalive[each.key].precedence_is_string ? "precedence-type" : local.vpc_keepalive[each.key].precedence_is_number ? "precedence-value" : null
keepalive_type_of_service_type = local.vpc_keepalive[each.key].tos_is_string ? tostring(local.vpc_keepalive[each.key].tos_value) : null
keepalive_type_of_service_value = local.vpc_keepalive[each.key].tos_is_number ? tonumber(local.vpc_keepalive[each.key].tos_value) : null
keepalive_udp_port = try(local.device_config[each.key].vpc.keepalive.udp_port, null)
keepalive_vrf = try(local.device_config[each.key].vpc.keepalive.vrf, null)
peerlink_interface_id = try(local.device_config[each.key].vpc.peer_link_port_channel, null) != null ? "po${try(local.device_config[each.key].vpc.peer_link_port_channel)}" : null
interfaces = length(local.vpc_interfaces_map[each.key]) > 0 ? local.vpc_interfaces_map[each.key] : null
depends_on = [
nxos_feature.feature,
nxos_port_channel_interface.port_channel_interface,
]
}