From c35d757a172e561cbc3d5426fc2e89241fb2c2a5 Mon Sep 17 00:00:00 2001 From: Cameron Schaeffer Date: Tue, 25 Nov 2025 20:08:35 +0000 Subject: [PATCH] Add MPLS label mode Terraform module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds Terraform mapping logic to translate MPLS label mode configurations from the NaC schema into the terraform-provider-iosxe iosxe_mpls resource attributes. Features: - MPLS label protocol configuration mapping - Label mode configuration for all address families - Label mode configuration for BGP VPNv4 address family - Label mode configuration for BGP VPNv6 address family - Multi-device deployment support with for_each iteration - Three-tier fallback hierarchy: device config → global defaults → null Changes: - Added iosxe_mpls.tf module with 13 attribute mappings - Updated README.md with iosxe_mpls resource reference - Validated with pre-commit hooks (terraform fmt, tflint, terraform-docs) - Tested on Cat8kv router and Cat9kv switch platforms (IOS-XE 17.15) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- README.md | 1 + iosxe_mpls.tf | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 iosxe_mpls.tf diff --git a/README.md b/README.md index 94121fa..ec179bd 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ module "iosxe" { | [iosxe_lldp.lldp](https://registry.terraform.io/providers/CiscoDevNet/iosxe/0.10.2/docs/resources/lldp) | resource | | [iosxe_logging.logging](https://registry.terraform.io/providers/CiscoDevNet/iosxe/0.10.2/docs/resources/logging) | resource | | [iosxe_mdt_subscription.mdt_subscription](https://registry.terraform.io/providers/CiscoDevNet/iosxe/0.10.2/docs/resources/mdt_subscription) | resource | +| [iosxe_mpls.mpls](https://registry.terraform.io/providers/CiscoDevNet/iosxe/0.10.2/docs/resources/mpls) | resource | | [iosxe_msdp.msdp](https://registry.terraform.io/providers/CiscoDevNet/iosxe/0.10.2/docs/resources/msdp) | resource | | [iosxe_nat.nat](https://registry.terraform.io/providers/CiscoDevNet/iosxe/0.10.2/docs/resources/nat) | resource | | [iosxe_ntp.ntp](https://registry.terraform.io/providers/CiscoDevNet/iosxe/0.10.2/docs/resources/ntp) | resource | diff --git a/iosxe_mpls.tf b/iosxe_mpls.tf new file mode 100644 index 0000000..61a5aa1 --- /dev/null +++ b/iosxe_mpls.tf @@ -0,0 +1,18 @@ +resource "iosxe_mpls" "mpls" { + for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].mpls, null) != null } + device = each.value.name + + label_protocol = try(local.device_config[each.value.name].mpls.label_protocol, local.defaults.iosxe.configuration.mpls.label_protocol, null) + label_mode_all_vrfs_protocol_all_afs_per_vrf = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_all_afs_per_vrf, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_all_afs_per_vrf, null) + label_mode_all_vrfs_protocol_all_afs_per_prefix = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_all_afs_per_prefix, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_all_afs_per_prefix, null) + label_mode_all_vrfs_protocol_all_afs_per_ce = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_all_afs_per_ce, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_all_afs_per_ce, null) + label_mode_all_vrfs_protocol_all_afs_vrf_conn_aggr = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_all_afs_vrf_conn_aggr, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_all_afs_vrf_conn_aggr, null) + label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_vrf, null) + label_mode_all_vrfs_protocol_bgp_vpnv4_per_prefix = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_prefix, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_prefix, null) + label_mode_all_vrfs_protocol_bgp_vpnv4_per_ce = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_ce, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_per_ce, null) + label_mode_all_vrfs_protocol_bgp_vpnv4_vrf_conn_aggr = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_vrf_conn_aggr, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_bgp_vpnv4_vrf_conn_aggr, null) + label_mode_all_vrfs_protocol_bgp_vpnv6_per_vrf = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_vrf, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_vrf, null) + label_mode_all_vrfs_protocol_bgp_vpnv6_per_prefix = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_prefix, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_prefix, null) + label_mode_all_vrfs_protocol_bgp_vpnv6_per_ce = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_ce, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_per_ce, null) + label_mode_all_vrfs_protocol_bgp_vpnv6_vrf_conn_aggr = try(local.device_config[each.value.name].mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_vrf_conn_aggr, local.defaults.iosxe.configuration.mpls.label_mode_all_vrfs_protocol_bgp_vpnv6_vrf_conn_aggr, null) +}