From 033952b3e69954e1bdaa8730a480a9537ce05fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jasi=C5=84ski=20=28pjasinsk=29?= Date: Wed, 24 Jul 2024 17:29:10 +0200 Subject: [PATCH 1/2] Add support for dual loopback addresses under tenant.l3outs.node_profiles (#389) --- aci_tenants.tf | 4 ++-- modules/terraform-aci-l3out-node-profile/README.md | 7 +++++-- .../examples/complete/README.md | 5 ++++- .../examples/complete/main.tf | 5 ++++- modules/terraform-aci-l3out-node-profile/main.tf | 14 +++++++++++--- .../terraform-aci-l3out-node-profile/variables.tf | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/aci_tenants.tf b/aci_tenants.tf index c5dc0b22..f5802092 100644 --- a/aci_tenants.tf +++ b/aci_tenants.tf @@ -938,7 +938,7 @@ locals { pod_id = try(node.pod_id, [for node_ in local.node_policies.nodes : node_.pod if node_.id == node.node_id][0], local.defaults.apic.tenants.l3outs.node_profiles.nodes.pod) router_id = node.router_id router_id_as_loopback = try(node.router_id_as_loopback, local.defaults.apic.tenants.l3outs.node_profiles.nodes.router_id_as_loopback) - loopback = try(node.loopback, null) + loopbacks = try(node.loopbacks, []) static_routes = [for sr in try(node.static_routes, []) : { description = try(sr.description, "") prefix = sr.prefix @@ -1019,7 +1019,7 @@ locals { pod_id = try(node.pod_id, [for node_ in local.node_policies.nodes : node_.pod if node_.id == node.node_id][0], local.defaults.apic.tenants.l3outs.nodes.pod) router_id = node.router_id router_id_as_loopback = try(node.router_id_as_loopback, local.defaults.apic.tenants.l3outs.nodes.router_id_as_loopback) - loopback = try(node.loopback, null) + loopbacks = try(node.loopbacks, null) static_routes = [for sr in try(node.static_routes, []) : { description = try(sr.description, "") prefix = sr.prefix diff --git a/modules/terraform-aci-l3out-node-profile/README.md b/modules/terraform-aci-l3out-node-profile/README.md index 4226b9bf..5ff1abc0 100644 --- a/modules/terraform-aci-l3out-node-profile/README.md +++ b/modules/terraform-aci-l3out-node-profile/README.md @@ -23,7 +23,10 @@ module "aci_l3out_node_profile" { pod_id = 2 router_id = "2.2.2.2" router_id_as_loopback = false - loopback = "12.12.12.12" + loopbacks = [ + "12.12.12.12", + "fd12:3456:789a:1::1" + ] static_routes = [{ prefix = "0.0.0.0/0" description = "Default Route" @@ -87,7 +90,7 @@ module "aci_l3out_node_profile" { | [tenant](#input\_tenant) | Tenant name. | `string` | n/a | yes | | [l3out](#input\_l3out) | L3out name. | `string` | n/a | yes | | [name](#input\_name) | Node profile name. | `string` | n/a | yes | -| [nodes](#input\_nodes) | List of nodes. Allowed values `node_id`: 1-4000. Allowed values `pod_id`: 1-255. Default value `pod_id`: 1. Default value `router_id_as_loopback`: true. Allowed values `static_routes.preference`: 1-255. Default value `static_routes.preference`: 1. Default value `static_routes.bfd`: false. Allowed values `static_routes.next_hops.preference`: 0-255. Default value `static_routes.next_hops.preference`: 1. Choices `type`: `prefix`, `none`. Default value `type`: `prefix`. |
list(object({
node_id = number
pod_id = optional(number, 1)
router_id = string
router_id_as_loopback = optional(bool, true)
loopback = optional(string)
mpls_transport_loopback = optional(string)
segment_id = optional(number)
static_routes = optional(list(object({
prefix = string
description = optional(string, "")
preference = optional(number, 1)
bfd = optional(bool, false)
track_list = optional(string)
next_hops = optional(list(object({
ip = string
preference = optional(number, 1)
type = optional(string, "prefix")
})), [])
})), [])
}))
| `[]` | no | +| [nodes](#input\_nodes) | List of nodes. Allowed values `node_id`: 1-4000. Allowed values `pod_id`: 1-255. Default value `pod_id`: 1. Default value `router_id_as_loopback`: true. Allowed values `static_routes.preference`: 1-255. Default value `static_routes.preference`: 1. Default value `static_routes.bfd`: false. Allowed values `static_routes.next_hops.preference`: 0-255. Default value `static_routes.next_hops.preference`: 1. Choices `type`: `prefix`, `none`. Default value `type`: `prefix`. |
list(object({
node_id = number
pod_id = optional(number, 1)
router_id = string
router_id_as_loopback = optional(bool, true)
loopbacks = optional(list(string))
mpls_transport_loopback = optional(string)
segment_id = optional(number)
static_routes = optional(list(object({
prefix = string
description = optional(string, "")
preference = optional(number, 1)
bfd = optional(bool, false)
track_list = optional(string)
next_hops = optional(list(object({
ip = string
preference = optional(number, 1)
type = optional(string, "prefix")
})), [])
})), [])
}))
| `[]` | no | | [bgp\_peers](#input\_bgp\_peers) | List of BGP peers. Allowed values `remote_as`: 0-4294967295. Default value `allow_self_as`: false. Default value `as_override`: false. Default value `disable_peer_as_check`: false. Default value `next_hop_self`: false. Default value `send_community`: false. Default value `send_ext_community`: false. Allowed values `allowed_self_as_count`: 1-10. Default value `allowed_self_as_count`: 3. Default value `bfd`: false. Default value `disable_connected_check`: false. Allowed values `ttl`: 1-255. Default value `ttl`: 1. Allowed values `weight`: 0-65535. Default value `weight`: 0. Default value `remove_all_private_as`: false. Default value `remove_private_as`: false. Default value `replace_private_as_with_local_as`: false. Default value `unicast_address_family`: true. Default value `multicast_address_family`: true. Default value `admin_state`: true. Allowed values `local_as`: 0-4294967295. Choices `as_propagate`: `none`, `no-prepend`, `replace-as`, `dual-as`. Default value `as_propagate`: `none`. |
list(object({
ip = string
remote_as = string
description = optional(string, "")
allow_self_as = optional(bool, false)
as_override = optional(bool, false)
disable_peer_as_check = optional(bool, false)
next_hop_self = optional(bool, false)
send_community = optional(bool, false)
send_ext_community = optional(bool, false)
password = optional(string)
allowed_self_as_count = optional(number, 3)
bfd = optional(bool, false)
disable_connected_check = optional(bool, false)
ttl = optional(number, 1)
weight = optional(number, 0)
remove_all_private_as = optional(bool, false)
remove_private_as = optional(bool, false)
replace_private_as_with_local_as = optional(bool, false)
unicast_address_family = optional(bool, true)
multicast_address_family = optional(bool, true)
admin_state = optional(bool, true)
local_as = optional(number)
as_propagate = optional(string, "none")
peer_prefix_policy = optional(string)
export_route_control = optional(string)
import_route_control = optional(string)
}))
| `[]` | no | | [multipod](#input\_multipod) | Multipod L3out flag. | `bool` | `false` | no | | [remote\_leaf](#input\_remote\_leaf) | Remote leaf L3out flag. | `bool` | `false` | no | diff --git a/modules/terraform-aci-l3out-node-profile/examples/complete/README.md b/modules/terraform-aci-l3out-node-profile/examples/complete/README.md index c4639760..a562a18f 100644 --- a/modules/terraform-aci-l3out-node-profile/examples/complete/README.md +++ b/modules/terraform-aci-l3out-node-profile/examples/complete/README.md @@ -26,7 +26,10 @@ module "aci_l3out_node_profile" { pod_id = 2 router_id = "2.2.2.2" router_id_as_loopback = false - loopback = "12.12.12.12" + loopbacks = [ + "12.12.12.12", + "fd12:3456:789a:1::1" + ] static_routes = [{ prefix = "0.0.0.0/0" description = "Default Route" diff --git a/modules/terraform-aci-l3out-node-profile/examples/complete/main.tf b/modules/terraform-aci-l3out-node-profile/examples/complete/main.tf index 9b14cd01..53a6386a 100644 --- a/modules/terraform-aci-l3out-node-profile/examples/complete/main.tf +++ b/modules/terraform-aci-l3out-node-profile/examples/complete/main.tf @@ -12,7 +12,10 @@ module "aci_l3out_node_profile" { pod_id = 2 router_id = "2.2.2.2" router_id_as_loopback = false - loopback = "12.12.12.12" + loopbacks = [ + "12.12.12.12", + "fd12:3456:789a:1::1" + ] static_routes = [{ prefix = "0.0.0.0/0" description = "Default Route" diff --git a/modules/terraform-aci-l3out-node-profile/main.tf b/modules/terraform-aci-l3out-node-profile/main.tf index c241a31e..66f140d8 100644 --- a/modules/terraform-aci-l3out-node-profile/main.tf +++ b/modules/terraform-aci-l3out-node-profile/main.tf @@ -29,6 +29,14 @@ locals { ] ] ]) + loopback_list = flatten([ + for node in var.nodes : [ + for lp in coalesce(node.loopbacks, []) : { + lp = lp + node = node.node_id + } + ] + ]) } resource "aci_rest_managed" "l3extLNodeP" { @@ -50,11 +58,11 @@ resource "aci_rest_managed" "l3extRsNodeL3OutAtt" { } resource "aci_rest_managed" "l3extLoopBackIfP" { - for_each = { for node in var.nodes : node.node_id => node if node.router_id_as_loopback == false && node.loopback != null } - dn = "${aci_rest_managed.l3extRsNodeL3OutAtt[each.key].dn}/lbp-[${each.value.loopback}]" + for_each = { for lp in local.loopback_list : "${lp.node}-[${lp.lp}]" => lp } + dn = "${aci_rest_managed.l3extRsNodeL3OutAtt[each.value.node].dn}/lbp-[${each.value.lp}]" class_name = "l3extLoopBackIfP" content = { - addr = each.value.loopback + addr = each.value.lp } } diff --git a/modules/terraform-aci-l3out-node-profile/variables.tf b/modules/terraform-aci-l3out-node-profile/variables.tf index 893dd5c1..a3a495bc 100644 --- a/modules/terraform-aci-l3out-node-profile/variables.tf +++ b/modules/terraform-aci-l3out-node-profile/variables.tf @@ -35,7 +35,7 @@ variable "nodes" { pod_id = optional(number, 1) router_id = string router_id_as_loopback = optional(bool, true) - loopback = optional(string) + loopbacks = optional(list(string)) mpls_transport_loopback = optional(string) segment_id = optional(number) static_routes = optional(list(object({ From 39190e71e8763c5124349d85b646f075eb0b490a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jasi=C5=84ski=20=28pjasinsk=29?= Date: Wed, 24 Jul 2024 21:36:46 +0200 Subject: [PATCH 2/2] Add support for dual loopback addresses for node_profiles --- modules/terraform-aci-l3out-node-profile/main.tf | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/terraform-aci-l3out-node-profile/main.tf b/modules/terraform-aci-l3out-node-profile/main.tf index 66f140d8..82dd201f 100644 --- a/modules/terraform-aci-l3out-node-profile/main.tf +++ b/modules/terraform-aci-l3out-node-profile/main.tf @@ -32,8 +32,11 @@ locals { loopback_list = flatten([ for node in var.nodes : [ for lp in coalesce(node.loopbacks, []) : { - lp = lp - node = node.node_id + key = "${node.node_id}/${lp}" + value = { + ip = lp + node = node.node_id + } } ] ]) @@ -58,11 +61,11 @@ resource "aci_rest_managed" "l3extRsNodeL3OutAtt" { } resource "aci_rest_managed" "l3extLoopBackIfP" { - for_each = { for lp in local.loopback_list : "${lp.node}-[${lp.lp}]" => lp } - dn = "${aci_rest_managed.l3extRsNodeL3OutAtt[each.value.node].dn}/lbp-[${each.value.lp}]" + for_each = { for item in local.loopback_list : item.key => item.value } + dn = "${aci_rest_managed.l3extRsNodeL3OutAtt[each.value.node].dn}/lbp-[${each.value.ip}]" class_name = "l3extLoopBackIfP" content = { - addr = each.value.lp + addr = each.value.ip } }