Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add l3out svi encap scope #89

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aci_tenants.tf
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ locals {
ip_a = try(int.ip_a, null)
ip_b = try(int.ip_b, null)
ip_shared = try(int.ip_shared, null)
scope = try(int.scope, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.scope)
multipod_direct = tenant.name == "infra" ? try(int.multipod_direct, false) : false
bgp_peers = [for peer in try(int.bgp_peers, []) : {
ip = peer.ip
Expand Down Expand Up @@ -1071,6 +1072,7 @@ module "aci_l3out_interface_profile_manual" {
ip_shared = int.ip_shared
bgp_peers = int.bgp_peers
paths = int.paths
scope = int.scope
multipod_direct = int.multipod_direct
}]

Expand Down Expand Up @@ -1124,6 +1126,7 @@ locals {
ip_a = try(int.ip_a, null)
ip_b = try(int.ip_b, null)
ip_shared = try(int.ip_shared, null)
scope = try(int.scope, local.defaults.apic.tenants.l3outs.node_profiles.interface_profiles.interfaces.scope)
multipod_direct = tenant.name == "infra" ? try(int.multipod_direct, false) : false
bgp_peers = [for peer in try(int.bgp_peers, []) : {
ip = peer.ip
Expand Down Expand Up @@ -1210,6 +1213,7 @@ module "aci_l3out_interface_profile_auto" {
ip_shared = int.ip_shared
bgp_peers = int.bgp_peers
paths = int.paths
scope = int.scope
multipod_direct = int.multipod_direct
}]

Expand Down
2 changes: 2 additions & 0 deletions defaults/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ defaults:
mac: 00:22:BD:F8:19:FF
mtu: inherit
mode: regular
scope: local
bgp_peers:
allow_self_as: false
as_override: false
Expand Down Expand Up @@ -869,6 +870,7 @@ defaults:
mac: 00:22:BD:F8:19:FF
mtu: inherit
mode: regular
scope: local
bgp_peers:
allow_self_as: false
as_override: false
Expand Down
3 changes: 2 additions & 1 deletion modules/terraform-aci-l3out-interface-profile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module "aci_l3out_interface_profile" {
description = "Interface 1"
type = "vpc"
svi = true
scope = "local"
vlan = 5
mac = "12:34:56:78:90:AB"
mtu = "1500"
Expand Down Expand Up @@ -109,7 +110,7 @@ module "aci_l3out_interface_profile" {
| <a name="input_igmp_interface_policy"></a> [igmp\_interface\_policy](#input\_igmp\_interface\_policy) | IGMP interface policy name. | `string` | `""` | no |
| <a name="input_qos_class"></a> [qos\_class](#input\_qos\_class) | QoS class. Choices: `level1`, `level2`, `level3`, `level4`, `level5`, `level6`, `unspecified`. | `string` | `"unspecified"` | no |
| <a name="input_custom_qos_policy"></a> [custom\_qos\_policy](#input\_custom\_qos\_policy) | Custom QoS policy name. | `string` | `""` | no |
| <a name="input_interfaces"></a> [interfaces](#input\_interfaces) | List of interfaces. Default value `svi`: false. Default value `floating_svi`: false. Choices `type`. `access`, `pc`, `vpc`. Default value `type`: `access`. Allowed values `vlan`: 1-4096. Format `mac`: `12:34:56:78:9A:BC`. `mtu`: Allowed values are `inherit` or a number between 576 and 9216. Allowed values `node_id`, `node2_id`: 1-4000. Allowed values `pod_id`: 1-255. Default value `pod_id`: 1. Allowed values `module`: 1-9. Default value `module`: 1. Allowed values `port`: 1-127. Default value `bgp_peers.bfd`: false. Allowed values `bgp_peers.ttl`: 1-255. Default value `bgp_peers.ttl`: 1. Allowed values `bgp_peers.weight`: 0-65535. Default value `bgp_peers.weight`: 0. Allowed values `bgp_peers.remote_as`: 0-4294967295. | <pre>list(object({<br> description = optional(string, "")<br> type = optional(string, "access")<br> node_id = number<br> node2_id = optional(number)<br> pod_id = optional(number, 1)<br> module = optional(number, 1)<br> port = optional(number)<br> channel = optional(string)<br> ip = optional(string)<br> svi = optional(bool, false)<br> autostate = optional(bool, false)<br> floating_svi = optional(bool, false)<br> vlan = optional(number)<br> mac = optional(string, "00:22:BD:F8:19:FF")<br> mtu = optional(string, "inherit")<br> mode = optional(string, "regular")<br> ip_a = optional(string)<br> ip_b = optional(string)<br> ip_shared = optional(string)<br> multipod_direct = optional(bool, false)<br> bgp_peers = optional(list(object({<br> ip = string<br> remote_as = string<br> description = optional(string, "")<br> allow_self_as = optional(bool, false)<br> as_override = optional(bool, false)<br> disable_peer_as_check = optional(bool, false)<br> next_hop_self = optional(bool, false)<br> send_community = optional(bool, false)<br> send_ext_community = optional(bool, false)<br> password = optional(string)<br> allowed_self_as_count = optional(number, 3)<br> bfd = optional(bool, false)<br> disable_connected_check = optional(bool, false)<br> ttl = optional(number, 1)<br> weight = optional(number, 0)<br> remove_all_private_as = optional(bool, false)<br> remove_private_as = optional(bool, false)<br> replace_private_as_with_local_as = optional(bool, false)<br> unicast_address_family = optional(bool, true)<br> multicast_address_family = optional(bool, true)<br> admin_state = optional(bool, true)<br> local_as = optional(number)<br> as_propagate = optional(string, "none")<br> peer_prefix_policy = optional(string)<br> export_route_control = optional(string)<br> import_route_control = optional(string)<br> })), [])<br> paths = optional(list(object({<br> physical_domain = optional(string)<br> vmware_vmm_domain = optional(string)<br> elag = optional(string)<br> floating_ip = string<br> })), [])<br> }))</pre> | `[]` | no |
| <a name="input_interfaces"></a> [interfaces](#input\_interfaces) | List of interfaces. Default value `svi`: false. Default value `floating_svi`: false. Choices `type`. `access`, `pc`, `vpc`. Default value `type`: `access`. Allowed values `vlan`: 1-4096. Format `mac`: `12:34:56:78:9A:BC`. `mtu`: Allowed values are `inherit` or a number between 576 and 9216. Allowed values `node_id`, `node2_id`: 1-4000. Allowed values `pod_id`: 1-255. Default value `pod_id`: 1. Allowed values `module`: 1-9. Default value `module`: 1. Allowed values `port`: 1-127. Default value `bgp_peers.bfd`: false. Allowed values `bgp_peers.ttl`: 1-255. Default value `bgp_peers.ttl`: 1. Allowed values `bgp_peers.weight`: 0-65535. Default value `bgp_peers.weight`: 0. Allowed values `bgp_peers.remote_as`: 0-4294967295. | <pre>list(object({<br> description = optional(string, "")<br> type = optional(string, "access")<br> node_id = number<br> node2_id = optional(number)<br> pod_id = optional(number, 1)<br> module = optional(number, 1)<br> port = optional(number)<br> channel = optional(string)<br> ip = optional(string)<br> svi = optional(bool, false)<br> autostate = optional(bool, false)<br> floating_svi = optional(bool, false)<br> vlan = optional(number)<br> mac = optional(string, "00:22:BD:F8:19:FF")<br> mtu = optional(string, "inherit")<br> mode = optional(string, "regular")<br> ip_a = optional(string)<br> ip_b = optional(string)<br> ip_shared = optional(string)<br> scope = optional(string, "local")<br> multipod_direct = optional(bool, false)<br> bgp_peers = optional(list(object({<br> ip = string<br> remote_as = string<br> description = optional(string, "")<br> allow_self_as = optional(bool, false)<br> as_override = optional(bool, false)<br> disable_peer_as_check = optional(bool, false)<br> next_hop_self = optional(bool, false)<br> send_community = optional(bool, false)<br> send_ext_community = optional(bool, false)<br> password = optional(string)<br> allowed_self_as_count = optional(number, 3)<br> bfd = optional(bool, false)<br> disable_connected_check = optional(bool, false)<br> ttl = optional(number, 1)<br> weight = optional(number, 0)<br> remove_all_private_as = optional(bool, false)<br> remove_private_as = optional(bool, false)<br> replace_private_as_with_local_as = optional(bool, false)<br> unicast_address_family = optional(bool, true)<br> multicast_address_family = optional(bool, true)<br> admin_state = optional(bool, true)<br> local_as = optional(number)<br> as_propagate = optional(string, "none")<br> peer_prefix_policy = optional(string)<br> export_route_control = optional(string)<br> import_route_control = optional(string)<br> })), [])<br> paths = optional(list(object({<br> physical_domain = optional(string)<br> vmware_vmm_domain = optional(string)<br> elag = optional(string)<br> floating_ip = string<br> })), [])<br> }))</pre> | `[]` | no |
| <a name="input_multipod"></a> [multipod](#input\_multipod) | Multipod L3out flag. | `bool` | `false` | no |
| <a name="input_remote_leaf"></a> [remote\_leaf](#input\_remote\_leaf) | Remote leaf L3out flag. | `bool` | `false` | no |
| <a name="input_sr_mpls"></a> [sr\_mpls](#input\_sr\_mpls) | SR MPLS L3out flag. | `bool` | `false` | no |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module "aci_l3out_interface_profile" {
description = "Interface 1"
type = "vpc"
svi = true
scope = "local"
vlan = 5
mac = "12:34:56:78:90:AB"
mtu = "1500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module "aci_l3out_interface_profile" {
description = "Interface 1"
type = "vpc"
svi = true
scope = "local"
vlan = 5
mac = "12:34:56:78:90:AB"
mtu = "1500"
Expand Down
6 changes: 4 additions & 2 deletions modules/terraform-aci-l3out-interface-profile/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ locals {
ip_shared = int.ip_shared
tDn = int.type == "vpc" ? "topology/pod-${int.pod_id}/protpaths-${int.node_id}-${int.node2_id}/pathep-[${int.channel}]" : (int.type == "pc" ? "topology/pod-${int.pod_id}/paths-${int.node_id}/pathep-[${int.channel}]" : "topology/pod-${int.pod_id}/paths-${int.node_id}/pathep-[eth${int.module}/${int.port}]")
multipod_direct = int.multipod_direct
scope = int.scope
}
} if int.floating_svi == false
])
Expand Down Expand Up @@ -76,6 +77,7 @@ locals {
mtu = int.mtu
node_id = int.node_id
pod_id = int.pod_id
scope = int.scope
}
} if int.floating_svi == true
])
Expand Down Expand Up @@ -263,7 +265,6 @@ resource "aci_rest_managed" "l3extRsPathL3OutAtt" {
content = {
addr = each.value.ip
descr = each.value.description
encapScope = "local"
ifInstT = each.value.vlan != null ? (each.value.svi == "yes" ? "ext-svi" : "sub-interface") : "l3-port"
autostate = each.value.autostate
encap = each.value.vlan != null ? "vlan-${each.value.vlan}" : null
Expand All @@ -274,6 +275,7 @@ resource "aci_rest_managed" "l3extRsPathL3OutAtt" {
mtu = each.value.mtu
tDn = each.value.tDn
isMultiPodDirect = each.value.multipod_direct ? "yes" : null
encapScope = each.value.svi == "yes" ? each.value.scope == "vrf" ? "ctx" : "local" : null
}
}

Expand Down Expand Up @@ -332,7 +334,6 @@ resource "aci_rest_managed" "l3extVirtualLIfP" {
addr = each.value.ip
autostate = each.value.autostate
descr = each.value.description
encapScope = "local"
ifInstT = "ext-svi"
encap = "vlan-${each.value.vlan}"
ipv6Dad = "enabled"
Expand All @@ -341,6 +342,7 @@ resource "aci_rest_managed" "l3extVirtualLIfP" {
mode = each.value.mode
mtu = each.value.mtu
nodeDn = "topology/pod-${each.value.pod_id}/node-${each.value.node_id}"
encapScope = each.value.scope == "vrf" ? "ctx" : "local"
}
}

Expand Down
8 changes: 8 additions & 0 deletions modules/terraform-aci-l3out-interface-profile/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ variable "interfaces" {
ip_a = optional(string)
ip_b = optional(string)
ip_shared = optional(string)
scope = optional(string, "local")
multipod_direct = optional(bool, false)
bgp_peers = optional(list(object({
ip = string
Expand Down Expand Up @@ -321,6 +322,13 @@ variable "interfaces" {
error_message = "`channel`: Allowed characters: `a`-`z`, `A`-`Z`, `0`-`9`, `_`, `.`, `-`, `:`. Maximum characters: 64."
}

validation {
condition = alltrue([
for i in var.interfaces : i.scope == null || try(contains(["local", "vrf"], i.scope), false)
])
error_message = "`scope`: Allowed values are `local` or `vrf`"
}

validation {
condition = alltrue(flatten([
for i in var.interfaces : [for b in coalesce(i.bgp_peers, []) : b.remote_as >= 0 && b.remote_as <= 4294967295]
Expand Down