From 48a0b7e9362be86b7b9b490f6827dd4720652c8d Mon Sep 17 00:00:00 2001 From: laxmikantchintakindi <159624484+laxmikantchintakindi@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:18:48 +0530 Subject: [PATCH 1/5] Feat(eos_designs): Add support to use router general for router id (#4687) --- .../intended/structured_configs/pe1.yml | 2 +- .../intended/structured_configs/pe2.yml | 2 +- .../intended/structured_configs/pe3.yml | 2 +- .../structured_configs/SITE1-LER1.yml | 2 +- .../structured_configs/SITE2-LER1.yml | 2 +- .../intended/configs/DC1-BL1A.cfg | 12 +++---- .../intended/configs/DC1-SPINE4.cfg | 5 ++- .../intended/configs/core-1-isis-sr-ldp.cfg | 7 ++-- .../intended/configs/core-2-ospf-ldp.cfg | 7 ++-- .../intended/structured_configs/DC1-BL1A.yml | 11 ++---- .../intended/structured_configs/DC1-BL1B.yml | 2 +- .../structured_configs/DC1-LEAF1A.yml | 2 +- .../structured_configs/DC1-LEAF2A.yml | 2 +- .../structured_configs/DC1-LEAF2B.yml | 2 +- .../structured_configs/DC1-SPINE4.yml | 4 ++- .../structured_configs/SVI_PROFILE_NODE_1.yml | 2 +- .../structured_configs/SVI_PROFILE_NODE_2.yml | 2 +- .../structured_configs/core-1-isis-sr-ldp.yml | 6 ++-- .../structured_configs/core-2-ospf-ldp.yml | 6 ++-- .../evpn_services_l2_only_false.yml | 2 +- .../inventory/host_vars/DC1-BL1A.yml | 2 ++ .../inventory/host_vars/DC1-SPINE4.yml | 2 ++ .../host_vars/core-1-isis-sr-ldp.yml | 2 ++ .../inventory/host_vars/core-2-ospf-ldp.yml | 1 + .../use-router-general-for-router-id.md | 17 +++++++++ .../schema/eos_designs.schema.yml | 5 +++ ...se_router_general_for_router_id.schema.yml | 12 +++++++ .../pyavd/_eos_designs/shared_utils/misc.py | 4 +++ .../structured_config/base/__init__.py | 6 ++-- .../structured_config/base/router_general.py | 36 +++++++++++++++++++ .../network_services/router_bgp.py | 4 ++- .../network_services/router_ospf.py | 6 +++- .../structured_config/underlay/mpls.py | 22 +++++++----- .../structured_config/underlay/router_isis.py | 6 ++-- .../structured_config/underlay/router_ospf.py | 2 +- 35 files changed, 154 insertions(+), 55 deletions(-) create mode 100644 ansible_collections/arista/avd/roles/eos_designs/docs/tables/use-router-general-for-router-id.md create mode 100644 python-avd/pyavd/_eos_designs/schema/schema_fragments/use_router_general_for_router_id.schema.yml create mode 100644 python-avd/pyavd/_eos_designs/structured_config/base/router_general.py diff --git a/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe1.yml b/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe1.yml index 1f927fe118d..b1506dd46ce 100644 --- a/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe1.yml +++ b/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe1.yml @@ -241,9 +241,9 @@ router_ospf: - id: 10 vrf: C1_VRF1 passive_interface_default: true - router_id: 10.255.1.1 no_passive_interfaces: - Ethernet3.10 + router_id: 10.255.1.1 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe2.yml b/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe2.yml index 2195d7378c8..c6c490d5b1d 100644 --- a/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe2.yml +++ b/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe2.yml @@ -241,9 +241,9 @@ router_ospf: - id: 10 vrf: C1_VRF1 passive_interface_default: true - router_id: 10.255.1.2 no_passive_interfaces: - Ethernet4.10 + router_id: 10.255.1.2 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe3.yml b/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe3.yml index 7267680188d..44569f00201 100644 --- a/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe3.yml +++ b/ansible_collections/arista/avd/examples/isis-ldp-ipvpn/intended/structured_configs/pe3.yml @@ -236,9 +236,9 @@ router_ospf: - id: 10 vrf: C1_VRF1 passive_interface_default: true - router_id: 10.255.1.3 no_passive_interfaces: - Ethernet2 + router_id: 10.255.1.3 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs-mpls-isis-sr-ldp/intended/structured_configs/SITE1-LER1.yml b/ansible_collections/arista/avd/molecule/eos_designs-mpls-isis-sr-ldp/intended/structured_configs/SITE1-LER1.yml index 2cd3c083575..02e75c5e68e 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs-mpls-isis-sr-ldp/intended/structured_configs/SITE1-LER1.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs-mpls-isis-sr-ldp/intended/structured_configs/SITE1-LER1.yml @@ -470,10 +470,10 @@ router_ospf: - id: 19 vrf: TENANT_B_INTRA passive_interface_default: true - router_id: 10.123.1.0 no_passive_interfaces: - Ethernet6.10 max_lsa: 10000 + router_id: 10.123.1.0 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs-mpls-isis-sr-ldp/intended/structured_configs/SITE2-LER1.yml b/ansible_collections/arista/avd/molecule/eos_designs-mpls-isis-sr-ldp/intended/structured_configs/SITE2-LER1.yml index f02d1b3fb1f..e791e83476c 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs-mpls-isis-sr-ldp/intended/structured_configs/SITE2-LER1.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs-mpls-isis-sr-ldp/intended/structured_configs/SITE2-LER1.yml @@ -583,10 +583,10 @@ router_ospf: - id: 99 vrf: TENANT_B_WAN passive_interface_default: true - router_id: 192.168.48.4 no_passive_interfaces: - Ethernet6.100 max_lsa: 10000 + router_id: 192.168.48.4 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1A.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1A.cfg index c7778484981..800bf4490e1 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1A.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-BL1A.cfg @@ -312,7 +312,6 @@ router bfd multihop interval 1200 min-rx 1200 multiplier 3 ! router bgp 65104 - router-id 192.168.255.14 update wait-install no bgp default ipv4-unicast maximum-paths 4 ecmp 4 @@ -414,7 +413,6 @@ router bgp 65104 rd 192.168.254.14:15 route-target import evpn 65104:15 route-target export evpn 65104:15 - router-id 192.168.255.14 redistribute connected ! vrf Tenant_A_WAN_Zone @@ -425,7 +423,6 @@ router bgp 65104 route-target export evpn 65104:14 route-target export evpn 65000:789 route-target export vpn-ipv4 65000:123 - router-id 192.168.255.14 update wait-install neighbor 123.1.1.10 remote-as 1234 neighbor 123.1.1.10 shutdown @@ -475,31 +472,30 @@ router bgp 65104 rd 192.168.254.14:20 route-target import evpn 65104:20 route-target export evpn 65104:20 - router-id 192.168.255.14 redistribute connected ! vrf Tenant_B_WAN_Zone rd 192.168.254.14:21 route-target import evpn 65104:21 route-target export evpn 65104:21 - router-id 192.168.255.14 redistribute connected ! vrf Tenant_C_WAN_Zone rd 192.168.254.14:31 route-target import evpn 65104:31 route-target export evpn 65104:31 - router-id 192.168.255.14 redistribute connected ! vrf TENANT_D_WAN_ZONE rd 192.168.254.14:42 route-target import evpn 65104:42 route-target export evpn 65104:42 - router-id 192.168.255.14 +! +router general + router-id ipv4 192.168.255.14 + exit ! router ospf 14 vrf Tenant_A_WAN_Zone - router-id 192.168.255.14 passive-interface default no passive-interface Ethernet7 no passive-interface Vlan150 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-SPINE4.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-SPINE4.cfg index a87fc69811b..b2aebcd562d 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-SPINE4.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/DC1-SPINE4.cfg @@ -190,7 +190,6 @@ router bfd multihop interval 1200 min-rx 1200 multiplier 3 ! router bgp 65001 - router-id 192.168.255.4 update wait-install no bgp default ipv4-unicast maximum-paths 4 ecmp 4 @@ -300,4 +299,8 @@ router bgp 65001 no neighbor EVPN-OVERLAY-PEERS activate neighbor UNDERLAY-PEERS activate ! +router general + router-id ipv4 192.168.255.4 + exit +! end diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/core-1-isis-sr-ldp.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/core-1-isis-sr-ldp.cfg index 6611edb1697..8c44ae989cd 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/core-1-isis-sr-ldp.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/core-1-isis-sr-ldp.cfg @@ -299,14 +299,17 @@ ip route vrf MGMT 0.0.0.0/0 192.168.0.1 mpls ip ! mpls ldp - router-id 10.0.0.1 transport-address interface Loopback0 interface disabled default no shutdown ! +router general + router-id ipv4 10.0.0.1 + router-id ipv6 2000:1234:ffff:ffff::1 + exit +! router isis CORE net 49.0001.0100.0000.0001.00 - router-id ipv4 10.0.0.1 is-type level-2 log-adjacency-changes mpls ldp sync default diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/core-2-ospf-ldp.cfg b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/core-2-ospf-ldp.cfg index a831dbaa5f1..1114402b5d6 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/core-2-ospf-ldp.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/configs/core-2-ospf-ldp.cfg @@ -207,13 +207,16 @@ ip route vrf MGMT 0.0.0.0/0 192.168.0.1 mpls ip ! mpls ldp - router-id 10.0.0.2 transport-address interface Loopback0 interface disabled default no shutdown ! +router general + router-id ipv4 10.0.0.2 + router-id ipv6 2000:1234:ffff:ffff::2 + exit +! router ospf 101 - router-id 10.0.0.2 bfd default passive-interface default no passive-interface Ethernet1 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1A.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1A.yml index 0f70c4438b4..2e040a703a6 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1A.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1A.yml @@ -2,7 +2,6 @@ hostname: DC1-BL1A is_deployed: true router_bgp: as: '65104' - router_id: 192.168.255.14 bgp_defaults: - distance bgp 20 200 200 bgp: @@ -131,7 +130,6 @@ router_bgp: - address_family: evpn route_targets: - '65104:15' - router_id: 192.168.255.14 redistribute: connected: enabled: true @@ -154,7 +152,6 @@ router_bgp: - address_family: vpn-ipv4 route_targets: - 65000:123 - router_id: 192.168.255.14 redistribute: connected: enabled: true @@ -228,7 +225,6 @@ router_bgp: - address_family: evpn route_targets: - '65104:20' - router_id: 192.168.255.14 redistribute: connected: enabled: true @@ -243,7 +239,6 @@ router_bgp: - address_family: evpn route_targets: - '65104:21' - router_id: 192.168.255.14 redistribute: connected: enabled: true @@ -258,7 +253,6 @@ router_bgp: - address_family: evpn route_targets: - '65104:31' - router_id: 192.168.255.14 redistribute: connected: enabled: true @@ -273,7 +267,6 @@ router_bgp: - address_family: evpn route_targets: - '65104:42' - router_id: 192.168.255.14 vlan_aware_bundles: - name: Tenant_A_WAN_Zone rd: 192.168.254.14:14 @@ -452,6 +445,9 @@ ntp: null snmp_server: contact: example@example.com location: EOS_DESIGNS_UNIT_TESTS DC1-BL1A +router_general: + router_id: + ipv4: 192.168.255.14 ethernet_interfaces: - name: Ethernet1 peer: DC1-SPINE1 @@ -724,7 +720,6 @@ router_ospf: - id: 14 vrf: Tenant_A_WAN_Zone passive_interface_default: true - router_id: 192.168.255.14 no_passive_interfaces: - Ethernet7 - Vlan150 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1B.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1B.yml index 9e85a6ee2f4..230c18c3c3a 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1B.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-BL1B.yml @@ -692,10 +692,10 @@ router_ospf: - id: 14 vrf: Tenant_A_WAN_Zone passive_interface_default: true - router_id: 192.168.255.15 no_passive_interfaces: - Vlan150 max_lsa: 15000 + router_id: 192.168.255.15 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF1A.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF1A.yml index c5c3f276075..cf0d92e6593 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF1A.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF1A.yml @@ -569,9 +569,9 @@ router_ospf: - id: 9 vrf: Tenant_A_OP_Zone passive_interface_default: true - router_id: 192.168.42.42 no_passive_interfaces: - Vlan113 + router_id: 192.168.42.42 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF2A.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF2A.yml index ba424019f4e..6f99f37bbb6 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF2A.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF2A.yml @@ -1226,10 +1226,10 @@ router_ospf: - id: 16 vrf: Tenant_A_OSPF passive_interface_default: true - router_id: 192.168.255.10 no_passive_interfaces: - Ethernet22 - Ethernet23 + router_id: 192.168.255.10 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF2B.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF2B.yml index 943e4430946..65b7b10449c 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF2B.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-LEAF2B.yml @@ -1166,9 +1166,9 @@ router_ospf: - id: 16 vrf: Tenant_A_OSPF passive_interface_default: true - router_id: 192.168.255.11 no_passive_interfaces: - Ethernet24 + router_id: 192.168.255.11 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-SPINE4.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-SPINE4.yml index e53c627383e..ed38a0af854 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-SPINE4.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/DC1-SPINE4.yml @@ -2,7 +2,6 @@ hostname: DC1-SPINE4 is_deployed: true router_bgp: as: '65001' - router_id: 192.168.255.4 bgp_defaults: - distance bgp 20 200 200 bgp: @@ -264,6 +263,9 @@ ntp: snmp_server: contact: example@example.com location: EOS_DESIGNS_UNIT_TESTS DC1-SPINE4 +router_general: + router_id: + ipv4: 192.168.255.4 ethernet_interfaces: - name: Ethernet1/1 peer: DC1-LEAF1A diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/SVI_PROFILE_NODE_1.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/SVI_PROFILE_NODE_1.yml index 25306ea8169..8218972db3c 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/SVI_PROFILE_NODE_1.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/SVI_PROFILE_NODE_1.yml @@ -472,12 +472,12 @@ router_ospf: - id: 1 vrf: svi_profile_tests_vrf passive_interface_default: true - router_id: 192.168.255.1 no_passive_interfaces: - Vlan510 - Vlan511 - Vlan512 max_lsa: 15000 + router_id: 192.168.255.1 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/SVI_PROFILE_NODE_2.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/SVI_PROFILE_NODE_2.yml index 3f10f469faf..989c074cf8e 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/SVI_PROFILE_NODE_2.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/SVI_PROFILE_NODE_2.yml @@ -344,12 +344,12 @@ router_ospf: - id: 1 vrf: svi_profile_tests_vrf passive_interface_default: true - router_id: 192.168.255.1 no_passive_interfaces: - Vlan510 - Vlan511 - Vlan512 max_lsa: 15000 + router_id: 192.168.255.1 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/core-1-isis-sr-ldp.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/core-1-isis-sr-ldp.yml index 45c404ec101..b800c8cc309 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/core-1-isis-sr-ldp.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/core-1-isis-sr-ldp.yml @@ -27,6 +27,10 @@ management_api_http: enable_vrfs: - name: MGMT enable_https: true +router_general: + router_id: + ipv4: 10.0.0.1 + ipv6: 2000:1234:ffff:ffff::1 loopback_interfaces: - name: Loopback0 description: ROUTER_ID @@ -45,7 +49,6 @@ router_isis: instance: CORE log_adjacency_changes: true net: 49.0001.0100.0000.0001.00 - router_id: 10.0.0.1 is_type: level-2 address_family_ipv4: enabled: true @@ -71,7 +74,6 @@ mpls: ip: true ldp: interface_disabled_default: true - router_id: 10.0.0.1 shutdown: false transport_address_interface: Loopback0 ethernet_interfaces: diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/core-2-ospf-ldp.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/core-2-ospf-ldp.yml index 74b528f7788..2d5a037c490 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/core-2-ospf-ldp.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/core-2-ospf-ldp.yml @@ -27,6 +27,10 @@ management_api_http: enable_vrfs: - name: MGMT enable_https: true +router_general: + router_id: + ipv4: 10.0.0.2 + ipv6: 2000:1234:ffff:ffff::2 loopback_interfaces: - name: Loopback0 description: ROUTER_ID @@ -41,7 +45,6 @@ router_ospf: process_ids: - id: 101 passive_interface_default: true - router_id: 10.0.0.2 max_lsa: 12000 no_passive_interfaces: - Ethernet1 @@ -59,7 +62,6 @@ mpls: ip: true ldp: interface_disabled_default: true - router_id: 10.0.0.2 shutdown: false transport_address_interface: Loopback0 ethernet_interfaces: diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/evpn_services_l2_only_false.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/evpn_services_l2_only_false.yml index 2055b251e79..87d46dd841c 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/evpn_services_l2_only_false.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/intended/structured_configs/evpn_services_l2_only_false.yml @@ -995,9 +995,9 @@ router_ospf: process_ids: - id: 123 passive_interface_default: true - router_id: 192.168.255.109 no_passive_interfaces: - Vlan1234 + router_id: 192.168.255.109 redistribute: bgp: enabled: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-BL1A.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-BL1A.yml index 8c881a25603..b7610e875cd 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-BL1A.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-BL1A.yml @@ -5,6 +5,8 @@ my_special_dci_ethernet_interfaces: custom_structured_configuration_list_merge: append +use_router_general_for_router_id: true + # Test appending to list of ip name-servers. override_ip_name_servers: - ip_address: 1.1.1.1 diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-SPINE4.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-SPINE4.yml index dfa57b3c8ee..55abfafafab 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-SPINE4.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/DC1-SPINE4.yml @@ -2,6 +2,8 @@ # If the device is set to "is_deployed: false" at the host_vars level, then do not shutdown interfaces towards undeployed peers. shutdown_interfaces_towards_undeployed_peers: false +use_router_general_for_router_id: true + # If the device is set to "is_deployed: false" at the host_vars level, then do not shutdown bgp towards undeployed peers. shutdown_bgp_towards_undeployed_peers: false diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/core-1-isis-sr-ldp.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/core-1-isis-sr-ldp.yml index 32ddf295a1c..aeb92fa75ba 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/core-1-isis-sr-ldp.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/core-1-isis-sr-ldp.yml @@ -1,2 +1,4 @@ --- underlay_routing_protocol: isis-sr-ldp +# Use router id from router general configuration +use_router_general_for_router_id: true diff --git a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/core-2-ospf-ldp.yml b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/core-2-ospf-ldp.yml index 688b68e8c00..059afc08cac 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/core-2-ospf-ldp.yml +++ b/ansible_collections/arista/avd/molecule/eos_designs_unit_tests/inventory/host_vars/core-2-ospf-ldp.yml @@ -1,2 +1,3 @@ --- underlay_routing_protocol: ospf-ldp +use_router_general_for_router_id: true diff --git a/ansible_collections/arista/avd/roles/eos_designs/docs/tables/use-router-general-for-router-id.md b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/use-router-general-for-router-id.md new file mode 100644 index 00000000000..e22e6af2cf8 --- /dev/null +++ b/ansible_collections/arista/avd/roles/eos_designs/docs/tables/use-router-general-for-router-id.md @@ -0,0 +1,17 @@ + +=== "Table" + + | Variable | Type | Required | Default | Value Restrictions | Description | + | -------- | ---- | -------- | ------- | ------------------ | ----------- | + | [use_router_general_for_router_id](## "use_router_general_for_router_id") | Boolean | | `False` | | Use `router general` to set router ID for all routing protocols and VRFs. | + +=== "YAML" + + ```yaml + # Use `router general` to set router ID for all routing protocols and VRFs. + use_router_general_for_router_id: + ``` diff --git a/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml b/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml index a971be0d724..e26b62c6996 100644 --- a/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml +++ b/python-avd/pyavd/_eos_designs/schema/eos_designs.schema.yml @@ -4535,6 +4535,11 @@ keys: description: 'Generate AVD configurations directly from a given CloudVision topology. See `cv_topology` for details.' + use_router_general_for_router_id: + type: bool + description: Use `router general` to set router ID for all routing protocols and + VRFs. + default: false vtep_loopback_description: documentation_options: table: overlay-settings diff --git a/python-avd/pyavd/_eos_designs/schema/schema_fragments/use_router_general_for_router_id.schema.yml b/python-avd/pyavd/_eos_designs/schema/schema_fragments/use_router_general_for_router_id.schema.yml new file mode 100644 index 00000000000..e1d110de147 --- /dev/null +++ b/python-avd/pyavd/_eos_designs/schema/schema_fragments/use_router_general_for_router_id.schema.yml @@ -0,0 +1,12 @@ +# Copyright (c) 2023-2024 Arista Networks, Inc. +# Use of this source code is governed by the Apache License 2.0 +# that can be found in the LICENSE file. +# yaml-language-server: $schema=../../../_schema/avd_meta_schema.json +# Line above is used by RedHat's YAML Schema vscode extension +# Use Ctrl + Space to get suggestions for every field. Autocomplete will pop up after typing 2 letters. +type: dict +keys: + use_router_general_for_router_id: + type: bool + description: Use `router general` to set router ID for all routing protocols and VRFs. + default: false diff --git a/python-avd/pyavd/_eos_designs/shared_utils/misc.py b/python-avd/pyavd/_eos_designs/shared_utils/misc.py index 981d11abfb3..3cb758d12f3 100644 --- a/python-avd/pyavd/_eos_designs/shared_utils/misc.py +++ b/python-avd/pyavd/_eos_designs/shared_utils/misc.py @@ -427,3 +427,7 @@ def _get_ipv4_acl_field_with_substitution(field_value: str, replacements: dict[s @cached_property def ipv4_prefix_list_catalog(self: SharedUtils) -> list: return get(self.hostvars, "ipv4_prefix_list_catalog", default=[]) + + @cached_property + def use_router_general_for_router_id(self: SharedUtils) -> bool: + return bool(get(self.hostvars, "use_router_general_for_router_id")) diff --git a/python-avd/pyavd/_eos_designs/structured_config/base/__init__.py b/python-avd/pyavd/_eos_designs/structured_config/base/__init__.py index d4fa15848eb..e55a255ffb7 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/base/__init__.py +++ b/python-avd/pyavd/_eos_designs/structured_config/base/__init__.py @@ -11,10 +11,11 @@ from pyavd.j2filters import natural_sort from .ntp import NtpMixin +from .router_general import RouterGeneralMixin from .snmp_server import SnmpServerMixin -class AvdStructuredConfigBase(AvdFacts, NtpMixin, SnmpServerMixin): +class AvdStructuredConfigBase(AvdFacts, NtpMixin, SnmpServerMixin, RouterGeneralMixin): """ The AvdStructuredConfig Class is imported by "get_structured_config" to render parts of the structured config. @@ -66,7 +67,7 @@ def router_bgp(self) -> dict | None: router_bgp = { "as": self.shared_utils.bgp_as, - "router_id": self.shared_utils.router_id, + "router_id": self.shared_utils.router_id if not self.shared_utils.use_router_general_for_router_id else None, "distance": get(self._hostvars, "bgp_distance"), "bgp_defaults": get(self.shared_utils.switch_data_combined, "bgp_defaults"), "bgp": { @@ -80,6 +81,7 @@ def router_bgp(self) -> dict | None: }, "redistribute": self._router_bgp_redistribute_routes, } + if get(self._hostvars, "bgp_update_wait_for_convergence", default=False) is True and platform_bgp_update_wait_for_convergence: router_bgp.setdefault("updates", {})["wait_for_convergence"] = True diff --git a/python-avd/pyavd/_eos_designs/structured_config/base/router_general.py b/python-avd/pyavd/_eos_designs/structured_config/base/router_general.py new file mode 100644 index 00000000000..3cb923bfa25 --- /dev/null +++ b/python-avd/pyavd/_eos_designs/structured_config/base/router_general.py @@ -0,0 +1,36 @@ +# Copyright (c) 2023-2024 Arista Networks, Inc. +# Use of this source code is governed by the Apache License 2.0 +# that can be found in the LICENSE file. +from __future__ import annotations + +from functools import cached_property +from typing import TYPE_CHECKING + +from pyavd._utils import strip_empties_from_dict + +from .utils import UtilsMixin + +if TYPE_CHECKING: + from . import AvdStructuredConfigBase + + +class RouterGeneralMixin(UtilsMixin): + """ + Mixin Class used to generate structured config for one key. + + Class should only be used as Mixin to a AvdStructuredConfig class. + """ + + @cached_property + def router_general(self: AvdStructuredConfigBase) -> dict | None: + if self.shared_utils.use_router_general_for_router_id: + return strip_empties_from_dict( + { + "router_id": { + "ipv4": self.shared_utils.router_id, + "ipv6": self.shared_utils.ipv6_router_id, + } + } + ) + + return None diff --git a/python-avd/pyavd/_eos_designs/structured_config/network_services/router_bgp.py b/python-avd/pyavd/_eos_designs/structured_config/network_services/router_bgp.py index 830e4e9bff1..94c204ef1e7 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/network_services/router_bgp.py +++ b/python-avd/pyavd/_eos_designs/structured_config/network_services/router_bgp.py @@ -168,7 +168,9 @@ def _router_bgp_vrfs(self: AvdStructuredConfigNetworkServices) -> dict: bgp_vrf_redistribute_connected = get(vrf, "redistribute_connected", default=True) if vrf_name != "default": # Non-default VRF - bgp_vrf["router_id"] = self.shared_utils.router_id + if not self.shared_utils.use_router_general_for_router_id: + bgp_vrf["router_id"] = self.shared_utils.router_id + if bgp_vrf_redistribute_connected is True: bgp_vrf["redistribute"] = {"connected": {"enabled": True}} # Redistribution of static routes for VRF default are handled elsewhere diff --git a/python-avd/pyavd/_eos_designs/structured_config/network_services/router_ospf.py b/python-avd/pyavd/_eos_designs/structured_config/network_services/router_ospf.py index 6faead71e37..729129e6291 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/network_services/router_ospf.py +++ b/python-avd/pyavd/_eos_designs/structured_config/network_services/router_ospf.py @@ -65,12 +65,16 @@ def router_ospf(self: AvdStructuredConfigNetworkServices) -> dict | None: "id": process_id, "vrf": vrf["name"] if vrf["name"] != "default" else None, "passive_interface_default": True, - "router_id": default(get(vrf, "ospf.router_id"), self.shared_utils.router_id), "no_passive_interfaces": ospf_interfaces, "bfd_enable": get(vrf, "ospf.bfd"), "max_lsa": get(vrf, "ospf.max_lsa"), } + if ospf_router_id := get(vrf, "ospf.router_id"): + process["router_id"] = ospf_router_id + elif not self.shared_utils.use_router_general_for_router_id: + process["router_id"] = self.shared_utils.router_id + process_redistribute = {} if get(vrf, "ospf.redistribute_bgp.enabled", default=True) is True: diff --git a/python-avd/pyavd/_eos_designs/structured_config/underlay/mpls.py b/python-avd/pyavd/_eos_designs/structured_config/underlay/mpls.py index 2f90eb76fa3..57c80c835c8 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/underlay/mpls.py +++ b/python-avd/pyavd/_eos_designs/structured_config/underlay/mpls.py @@ -6,6 +6,8 @@ from functools import cached_property from typing import TYPE_CHECKING +from pyavd._utils import strip_empties_from_dict + from .utils import UtilsMixin if TYPE_CHECKING: @@ -26,14 +28,16 @@ def mpls(self: AvdStructuredConfigUnderlay) -> dict | None: return None if self.shared_utils.underlay_ldp is True: - return { - "ip": True, - "ldp": { - "interface_disabled_default": True, - "router_id": self.shared_utils.router_id, - "shutdown": False, - "transport_address_interface": "Loopback0", - }, - } + return strip_empties_from_dict( + { + "ip": True, + "ldp": { + "interface_disabled_default": True, + "router_id": self.shared_utils.router_id if not self.shared_utils.use_router_general_for_router_id else None, + "shutdown": False, + "transport_address_interface": "Loopback0", + }, + } + ) return {"ip": True} diff --git a/python-avd/pyavd/_eos_designs/structured_config/underlay/router_isis.py b/python-avd/pyavd/_eos_designs/structured_config/underlay/router_isis.py index 4822979e142..ad1753acd2d 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/underlay/router_isis.py +++ b/python-avd/pyavd/_eos_designs/structured_config/underlay/router_isis.py @@ -7,7 +7,7 @@ from typing import TYPE_CHECKING from pyavd._errors import AristaAvdInvalidInputsError -from pyavd._utils import get +from pyavd._utils import get, strip_empties_from_dict from .utils import UtilsMixin @@ -32,7 +32,7 @@ def router_isis(self: AvdStructuredConfigUnderlay) -> dict | None: "instance": self.shared_utils.isis_instance_name, "log_adjacency_changes": True, "net": self._isis_net, - "router_id": self.shared_utils.router_id, + "router_id": self.shared_utils.router_id if not self.shared_utils.use_router_general_for_router_id else None, "is_type": self._is_type, "address_family_ipv4": {"enabled": True, "maximum_paths": get(self._hostvars, "isis_maximum_paths", default=4)}, } @@ -72,7 +72,7 @@ def router_isis(self: AvdStructuredConfigUnderlay) -> dict | None: router_isis["address_family_ipv6"]["fast_reroute_ti_lfa"] = {"mode": "node-protection"} router_isis["segment_routing_mpls"] = {"router_id": self.shared_utils.router_id, "enabled": True} - return router_isis + return strip_empties_from_dict(router_isis) @cached_property def _isis_net(self: AvdStructuredConfigUnderlay) -> str | None: diff --git a/python-avd/pyavd/_eos_designs/structured_config/underlay/router_ospf.py b/python-avd/pyavd/_eos_designs/structured_config/underlay/router_ospf.py index 04633c2d83e..96262a333d1 100644 --- a/python-avd/pyavd/_eos_designs/structured_config/underlay/router_ospf.py +++ b/python-avd/pyavd/_eos_designs/structured_config/underlay/router_ospf.py @@ -40,7 +40,7 @@ def router_ospf(self: AvdStructuredConfigUnderlay) -> dict | None: process = { "id": process_id, "passive_interface_default": True, - "router_id": self.shared_utils.router_id, + "router_id": self.shared_utils.router_id if not self.shared_utils.use_router_general_for_router_id else None, "max_lsa": get(self._hostvars, "underlay_ospf_max_lsa", default=12000), "no_passive_interfaces": no_passive_interfaces, "bfd_enable": get(self._hostvars, "underlay_ospf_bfd_enable", default=False), From 461a3b71aa5dfea42dceee42e8d5462e8193b99d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 06:59:52 +0100 Subject: [PATCH 2/5] Bump(requirements): Bump ruff from 0.5.6 to 0.7.3 in /ansible_collections/arista/avd (#4714) --- ansible_collections/arista/avd/requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible_collections/arista/avd/requirements-dev.txt b/ansible_collections/arista/avd/requirements-dev.txt index 97d983386d3..bf5bd0d21bd 100644 --- a/ansible_collections/arista/avd/requirements-dev.txt +++ b/ansible_collections/arista/avd/requirements-dev.txt @@ -22,7 +22,7 @@ pylint>=3.2.6 pre-commit>=3.2.0 pre-commit-hooks>=3.3.0 referencing>=0.35.0 -ruff==0.5.6 +ruff==0.7.3 tox treelib>=1.5.5 twine From 35f368826ebfa1360391cc78f71acd284b83fd15 Mon Sep 17 00:00:00 2001 From: Vibhu-gslab <109593615+Vibhu-gslab@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:07:32 +0530 Subject: [PATCH 3/5] Feat(eos_cli_config_gen): Add support for ipv4/ipv6 access group ingress default in system.control_plane (#4710) --- .../documentation/devices/host1.md | 64 +++++++++++++ .../documentation/devices/system.md | 94 ------------------- .../intended/configs/host1.cfg | 17 ++++ .../intended/configs/system.cfg | 20 ---- .../host_vars/{ => host1}/system.yml | 2 + .../eos_cli_config_gen/inventory/hosts.yml | 1 - .../eos_cli_config_gen/docs/tables/system.md | 8 ++ .../j2templates/documentation/system.j2 | 10 +- .../j2templates/eos/system.j2 | 6 ++ .../schema/eos_cli_config_gen.schema.yml | 6 ++ .../schema/schema_fragments/system.schema.yml | 6 ++ 11 files changed, 118 insertions(+), 116 deletions(-) delete mode 100644 ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/system.md delete mode 100644 ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/system.cfg rename ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/{ => host1}/system.yml (82%) diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md index 4e8ebb2ff1d..b956814906e 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md @@ -8,6 +8,7 @@ - [IP Domain-list](#ip-domain-list) - [Clock Settings](#clock-settings) - [NTP](#ntp) + - [System Control-Plane](#system-control-plane) - [Management SSH](#management-ssh) - [Management Tech-Support](#management-tech-support) - [CVX](#cvx) @@ -150,6 +151,9 @@ - [VRF Instances](#vrf-instances) - [VRF Instances Summary](#vrf-instances-summary) - [VRF Instances Device Configuration](#vrf-instances-device-configuration) +- [System L1](#system-l1) + - [Unsupported Interface Configurations](#unsupported-interface-configurations) + - [System L1 Device Configuration](#system-l1-device-configuration) - [Application Traffic Recognition](#application-traffic-recognition) - [Applications](#applications) - [Application Profiles](#application-profiles) @@ -328,6 +332,48 @@ ntp server 20.20.20.1 key ntp server ie.pool.ntp.org iburst key ``` +### System Control-Plane + +#### TCP MSS Ceiling + +| Protocol | Segment Size | +| -------- | -------------| +| IPv4 | 1344 | +| IPv6 | 1366 | + +#### Control-Plane Access-Groups + +| Protocol | VRF | Access-list | +| -------- | --- | ------------| +| IPv4 Ingress default | All | ingress_ipv4_acl | +| IPv4 | default | acl4_1 | +| IPv4 | red | acl4_2 | +| IPv4 | red_1 | acl4_2 | +| IPv4 | default | acl4_3 | +| IPv6 Ingress default | All | ingress_ipv6_acl | +| IPv6 | default | acl6_1 | +| IPv6 | blue | acl6_2 | +| IPv6 | blue_1 | acl6_2 | +| IPv6 | default | acl6_3 | + +#### System Control-Plane Device Configuration + +```eos +! +system control-plane + tcp mss ceiling ipv4 1344 ipv6 1366 + ip access-group ingress default ingress_ipv4_acl + ip access-group acl4_1 in + ip access-group acl4_3 vrf default in + ip access-group acl4_2 vrf red in + ip access-group acl4_2 vrf red_1 in + ipv6 access-group ingress default ingress_ipv6_acl + ipv6 access-group acl6_1 in + ipv6 access-group acl6_3 vrf default in + ipv6 access-group acl6_2 vrf blue in + ipv6 access-group acl6_2 vrf blue_1 in +``` + ### Management SSH #### Authentication Settings @@ -6098,6 +6144,24 @@ vrf instance TENANT_A_PROJECT01 vrf instance TENANT_A_PROJECT02 ``` +## System L1 + +### Unsupported Interface Configurations + +| Unsupported Configuration | action | +| ---------------- | -------| +| Speed | warn | +| Error correction | error | + +### System L1 Device Configuration + +```eos +! +system l1 + unsupported speed action warn + unsupported error-correction action error +``` + ## Application Traffic Recognition ### Applications diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/system.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/system.md deleted file mode 100644 index b09a9142548..00000000000 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/system.md +++ /dev/null @@ -1,94 +0,0 @@ -# system - -## Table of Contents - -- [Management](#management) - - [Management Interfaces](#management-interfaces) - - [System Control-Plane](#system-control-plane) -- [System L1](#system-l1) - - [Unsupported Interface Configurations](#unsupported-interface-configurations) - - [System L1 Device Configuration](#system-l1-device-configuration) - -## Management - -### Management Interfaces - -#### Management Interfaces Summary - -##### IPv4 - -| Management Interface | Description | Type | VRF | IP Address | Gateway | -| -------------------- | ----------- | ---- | --- | ---------- | ------- | -| Management1 | OOB_MANAGEMENT | oob | MGMT | 10.73.255.122/24 | 10.73.255.2 | - -##### IPv6 - -| Management Interface | Description | Type | VRF | IPv6 Address | IPv6 Gateway | -| -------------------- | ----------- | ---- | --- | ------------ | ------------ | -| Management1 | OOB_MANAGEMENT | oob | MGMT | - | - | - -#### Management Interfaces Device Configuration - -```eos -! -interface Management1 - description OOB_MANAGEMENT - vrf MGMT - ip address 10.73.255.122/24 -``` - -### System Control-Plane - -#### TCP MSS Ceiling - -| Protocol | Segment Size | -| -------- | -------------| -| IPv4 | 1344 | -| IPv6 | 1366 | - -#### Control-Plane Access-Groups - -| Protocol | VRF | Access-list | -| -------- | --- | ------------| -| IPv4 | default | acl4_1 | -| IPv4 | red | acl4_2 | -| IPv4 | red_1 | acl4_2 | -| IPv4 | default | acl4_3 | -| IPv6 | default | acl6_1 | -| IPv6 | blue | acl6_2 | -| IPv6 | blue_1 | acl6_2 | -| IPv6 | default | acl6_3 | - -#### System Control-Plane Device Configuration - -```eos -! -system control-plane - tcp mss ceiling ipv4 1344 ipv6 1366 - ip access-group acl4_1 in - ip access-group acl4_3 vrf default in - ip access-group acl4_2 vrf red in - ip access-group acl4_2 vrf red_1 in - ipv6 access-group acl6_1 in - ipv6 access-group acl6_3 vrf default in - ipv6 access-group acl6_2 vrf blue in - ipv6 access-group acl6_2 vrf blue_1 in -``` - -## System L1 - -### Unsupported Interface Configurations - -| Unsupported Configuration | action | -| ---------------- | -------| -| Speed | warn | -| Error correction | error | - -### System L1 Device Configuration - -```eos -! -system l1 - unsupported speed action warn - unsupported error-correction action error -``` diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg index 1e1915189a4..2c5ed9c0634 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg @@ -500,6 +500,10 @@ no sflow hardware acceleration module Linecard3 ! service unsupported-transceiver test dsafDSFfvadskjh3424 ! +system l1 + unsupported speed action warn + unsupported error-correction action error +! tap aggregation mode exclusive profile tap-aggregation-extended encapsulation dot1br strip @@ -3065,6 +3069,19 @@ mac access-list TEST4 permit any 02:00:00:12:34:56 00:00:00:00:00:00 deny any 02:00:00:ab:cd:ef 00:00:00:00:00:00 ! +system control-plane + tcp mss ceiling ipv4 1344 ipv6 1366 + ip access-group ingress default ingress_ipv4_acl + ip access-group acl4_1 in + ip access-group acl4_3 vrf default in + ip access-group acl4_2 vrf red in + ip access-group acl4_2 vrf red_1 in + ipv6 access-group ingress default ingress_ipv6_acl + ipv6 access-group acl6_1 in + ipv6 access-group acl6_3 vrf default in + ipv6 access-group acl6_2 vrf blue in + ipv6 access-group acl6_2 vrf blue_1 in +! mac address-table notification host-flap logging mac address-table notification host-flap detection window 10 mac address-table notification host-flap detection moves 2 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/system.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/system.cfg deleted file mode 100644 index d246010a90b..00000000000 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/system.cfg +++ /dev/null @@ -1,20 +0,0 @@ -! -system l1 - unsupported speed action warn - unsupported error-correction action error -! -interface Management1 - description OOB_MANAGEMENT - vrf MGMT - ip address 10.73.255.122/24 -! -system control-plane - tcp mss ceiling ipv4 1344 ipv6 1366 - ip access-group acl4_1 in - ip access-group acl4_3 vrf default in - ip access-group acl4_2 vrf red in - ip access-group acl4_2 vrf red_1 in - ipv6 access-group acl6_1 in - ipv6 access-group acl6_3 vrf default in - ipv6 access-group acl6_2 vrf blue in - ipv6 access-group acl6_2 vrf blue_1 in diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/system.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/system.yml similarity index 82% rename from ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/system.yml rename to ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/system.yml index 4158907f7cd..5b8816533fa 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/system.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/system.yml @@ -3,6 +3,7 @@ system: tcp_mss: ipv4: 1344 ipv6: 1366 + ipv4_access_group_ingress_default: ingress_ipv4_acl ipv4_access_groups: - acl_name: "acl4_1" - acl_name: "acl4_2" @@ -11,6 +12,7 @@ system: vrf: red_1 - acl_name: "acl4_3" vrf: default + ipv6_access_group_ingress_default: ingress_ipv6_acl ipv6_access_groups: - acl_name: "acl6_1" - acl_name: "acl6_2" diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/hosts.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/hosts.yml index e6a586e9cdb..543677f8b5d 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/hosts.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/hosts.yml @@ -85,7 +85,6 @@ test_hosts: spanning-tree-rapid-pvst: sync-e: tcam-profile: - system: terminattr-cloud: terminattr-extra-flags: terminattr-multi-cluster-certs: diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/system.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/system.md index 050f3ab4e68..a9d23e78899 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/system.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/system.md @@ -12,9 +12,11 @@ | [    tcp_mss](## "system.control_plane.tcp_mss") | Dictionary | | | | | | [      ipv4](## "system.control_plane.tcp_mss.ipv4") | Integer | | | | Segment size. | | [      ipv6](## "system.control_plane.tcp_mss.ipv6") | Integer | | | | Segment size. | + | [    ipv4_access_group_ingress_default](## "system.control_plane.ipv4_access_group_ingress_default") | String | | | | ACL name to be used as the default CP ACL for all VRFs. | | [    ipv4_access_groups](## "system.control_plane.ipv4_access_groups") | List, items: Dictionary | | | | | | [      - acl_name](## "system.control_plane.ipv4_access_groups.[].acl_name") | String | Required | | | | | [        vrf](## "system.control_plane.ipv4_access_groups.[].vrf") | String | | | | | + | [    ipv6_access_group_ingress_default](## "system.control_plane.ipv6_access_group_ingress_default") | String | | | | ACL name to be used as the default CP ACL for all VRFs. | | [    ipv6_access_groups](## "system.control_plane.ipv6_access_groups") | List, items: Dictionary | | | | | | [      - acl_name](## "system.control_plane.ipv6_access_groups.[].acl_name") | String | Required | | | | | [        vrf](## "system.control_plane.ipv6_access_groups.[].vrf") | String | | | | | @@ -34,9 +36,15 @@ # Segment size. ipv6: + + # ACL name to be used as the default CP ACL for all VRFs. + ipv4_access_group_ingress_default: ipv4_access_groups: - acl_name: vrf: + + # ACL name to be used as the default CP ACL for all VRFs. + ipv6_access_group_ingress_default: ipv6_access_groups: - acl_name: vrf: diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation/system.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation/system.j2 index 7a685f9db8f..c61b554922f 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation/system.j2 +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation/system.j2 @@ -20,16 +20,24 @@ | IPv6 | {{ system.control_plane.tcp_mss.ipv6 }} | {% endif %} {% endif %} -{% if system.control_plane.ipv4_access_groups is arista.avd.defined or system.control_plane.ipv6_access_groups is arista.avd.defined %} +{% if system.control_plane.ipv4_access_groups is arista.avd.defined or system.control_plane.ipv6_access_groups is arista.avd.defined or system.control_plane.ipv4_access_group_ingress_default is arista.avd.defined or system.control_plane.ipv6_access_group_ingress_default is arista.avd.defined %} #### Control-Plane Access-Groups | Protocol | VRF | Access-list | | -------- | --- | ------------| +{# IPv4 Access-groups Ingress Default #} +{% if system.control_plane.ipv4_access_group_ingress_default is arista.avd.defined %} +| IPv4 Ingress default | All | {{ system.control_plane.ipv4_access_group_ingress_default }} | +{% endif %} {# IPv4 Access-groups #} {% for acl_set in system.control_plane.ipv4_access_groups | arista.avd.natural_sort %} | IPv4 | {{ acl_set.vrf | arista.avd.default('default') }} | {{ acl_set.acl_name }} | {% endfor %} +{# IPv6 Access-groups Ingress Default #} +{% if system.control_plane.ipv6_access_group_ingress_default is arista.avd.defined %} +| IPv6 Ingress default | All | {{ system.control_plane.ipv6_access_group_ingress_default }} | +{% endif %} {# IPv6 Access-groups #} {% for acl_set in system.control_plane.ipv6_access_groups | arista.avd.natural_sort %} | IPv6 | {{ acl_set.vrf | arista.avd.default('default') }} | {{ acl_set.acl_name }} | diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/system.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/system.j2 index 913ebf3c154..652fb1236f0 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/system.j2 +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/system.j2 @@ -19,6 +19,9 @@ system control-plane {{ cp_mss_cli }} {% endif %} {# control_plane access_groups ipv4 #} +{% if system.control_plane.ipv4_access_group_ingress_default is arista.avd.defined %} + ip access-group ingress default {{ system.control_plane.ipv4_access_group_ingress_default }} +{% endif %} {% if system.control_plane.ipv4_access_groups is arista.avd.defined %} {% set with_vrf_non_default = system.control_plane.ipv4_access_groups | selectattr('vrf', 'arista.avd.defined') | rejectattr('vrf', 'equalto', 'default') | arista.avd.natural_sort | arista.avd.natural_sort('vrf') %} {% set without_vrf = system.control_plane.ipv4_access_groups | rejectattr('vrf', 'arista.avd.defined') | arista.avd.natural_sort %} @@ -34,6 +37,9 @@ system control-plane {{ cp_ipv4_access_grp }} {% endfor %} {# control_plane access_groups ipv6 #} +{% if system.control_plane.ipv6_access_group_ingress_default is arista.avd.defined %} + ipv6 access-group ingress default {{ system.control_plane.ipv6_access_group_ingress_default }} +{% endif %} {% if system.control_plane.ipv6_access_groups is arista.avd.defined %} {% set with_vrf_non_default = system.control_plane.ipv6_access_groups | selectattr('vrf', 'arista.avd.defined') | rejectattr('vrf', 'equalto', 'default') | arista.avd.natural_sort | arista.avd.natural_sort('vrf') %} {% set without_vrf = system.control_plane.ipv6_access_groups | rejectattr('vrf', 'arista.avd.defined') | arista.avd.natural_sort %} diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml index 3d096271e83..f13012ec9a2 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml @@ -20436,6 +20436,9 @@ keys: ipv6: type: int description: Segment size. + ipv4_access_group_ingress_default: + type: str + description: ACL name to be used as the default CP ACL for all VRFs. ipv4_access_groups: type: list unique_keys: @@ -20450,6 +20453,9 @@ keys: type: str convert_types: - int + ipv6_access_group_ingress_default: + type: str + description: ACL name to be used as the default CP ACL for all VRFs. ipv6_access_groups: type: list unique_keys: diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/system.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/system.schema.yml index c844c587a50..ff92974b1d1 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/system.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/system.schema.yml @@ -22,6 +22,9 @@ keys: ipv6: type: int description: Segment size. + ipv4_access_group_ingress_default: + type: str + description: ACL name to be used as the default CP ACL for all VRFs. ipv4_access_groups: type: list unique_keys: @@ -36,6 +39,9 @@ keys: type: str convert_types: - int + ipv6_access_group_ingress_default: + type: str + description: ACL name to be used as the default CP ACL for all VRFs. ipv6_access_groups: type: list unique_keys: From 6fad7e2afbc777c3a3aeb410d0847f18847bafb0 Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Wed, 13 Nov 2024 11:48:35 +0100 Subject: [PATCH 4/5] CI: Ensure we run from a built package instead of source (#4719) --- .github/requirements-ci.txt | 6 +----- .github/workflows/new-cvp-integration.yml | 7 +++++++ .github/workflows/pull-request-management.yml | 5 +++-- .../arista/avd/docs/contribution/development-tooling.md | 4 ++-- ansible_collections/arista/avd/plugins/__init__.py | 3 ++- containers/dev/.devcontainer/entrypoint.sh | 7 ++++--- python-avd/pyavd/constants.py | 3 ++- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/requirements-ci.txt b/.github/requirements-ci.txt index 847d93385a1..9f5ac3b2eae 100644 --- a/.github/requirements-ci.txt +++ b/.github/requirements-ci.txt @@ -1,7 +1,3 @@ # Installing PyAVD from source. # The package path below is relative to the repo root and will only work if the pip install is executed from there. -./python-avd -# The -r path is relative to this file. --r ../ansible_collections/arista/avd/requirements.txt -# Needed for molecule -jsonschema-rs>=0.24 +./python-avd[ansible-collection] diff --git a/.github/workflows/new-cvp-integration.yml b/.github/workflows/new-cvp-integration.yml index 733f90afc47..d8a18eab32e 100644 --- a/.github/workflows/new-cvp-integration.yml +++ b/.github/workflows/new-cvp-integration.yml @@ -6,6 +6,13 @@ on: workflow_dispatch concurrency: group: ${{ github.workflow }}-${{ github.head_ref }} + +env: + # Set -vvv is ACTIONS_STEP_DEBUG is set + # Apparently it is set in secrets when running with debug + ANSIBLE_VERBOSITY: ${{ secrets.ACTIONS_STEP_DEBUG && 3 || 0 }} + AVD_NEVER_RUN_FROM_SOURCE: 1 + jobs: # ----------------------------------------------- # # CV INTEGRATION MOLECULE TEST FOR CV_WORKFLOW # diff --git a/.github/workflows/pull-request-management.yml b/.github/workflows/pull-request-management.yml index 7738c5a8468..ca0cba4f09a 100644 --- a/.github/workflows/pull-request-management.yml +++ b/.github/workflows/pull-request-management.yml @@ -11,6 +11,7 @@ env: # Set -vvv is ACTIONS_STEP_DEBUG is set # Apparently it is set in secrets when running with debug ANSIBLE_VERBOSITY: ${{ secrets.ACTIONS_STEP_DEBUG && 3 || 0 }} + AVD_NEVER_RUN_FROM_SOURCE: 1 jobs: file-changes: @@ -111,7 +112,7 @@ jobs: python-version: ${{ matrix.python_version }} - name: 'Install Python requirements' run: | - pip install -r ansible_collections/arista/avd/requirements-dev.txt -r ansible_collections/arista/avd/requirements.txt --upgrade + pip install -r .github/requirements-ci.txt -r ansible_collections/arista/avd/requirements-dev.txt --upgrade # ----------------------------------- # # EOS CLI CONFIG GEN MOLECULE @@ -432,7 +433,7 @@ jobs: 3.13 - name: 'Install Python & Ansible requirements' run: | - pip install -r ansible_collections/arista/avd/requirements-dev.txt -r ansible_collections/arista/avd/requirements.txt --upgrade + pip install -r .github/requirements-ci.txt -r ansible_collections/arista/avd/requirements-dev.txt --upgrade ansible-galaxy collection install -r ansible_collections/arista/avd/collections.yml - name: 'Run ansible-test integration test cases' run: | diff --git a/ansible_collections/arista/avd/docs/contribution/development-tooling.md b/ansible_collections/arista/avd/docs/contribution/development-tooling.md index 7c0d7d0d641..59389bca301 100644 --- a/ansible_collections/arista/avd/docs/contribution/development-tooling.md +++ b/ansible_collections/arista/avd/docs/contribution/development-tooling.md @@ -56,7 +56,7 @@ Developing with your local Python environment requires you to configure and inst Recommended steps with Python virtual environment: 1. Create and activate a Python virtual environment. -2. Install Python requirements located in the AVD repository: [requirements-dev.txt](https://github.com/aristanetworks/avd/blob/devel/ansible_collections/arista/avd/requirements-dev.txt) and [requirements.txt](https://github.com/aristanetworks/avd/blob/devel/ansible_collections/arista/avd/requirements.txt). +2. Install Python requirements located in the AVD repository: [requirements-dev.txt](https://github.com/aristanetworks/avd/blob/devel/ansible_collections/arista/avd/requirements-dev.txt). !!! note Ensure the virtual environment is located outside of the AVD project directory. @@ -72,7 +72,7 @@ source avd-venv/bin/activate # The installation _must_ be performed from the root of the cloned avd repository. cd avd # Requirements files are located in `ansible_collections/arista/avd` of the avd repository. -pip3 install -r ansible_collections/arista/avd/requirements-dev.txt -r ansible_collections/arista/avd/requirements.txt --upgrade +pip3 install -r ansible_collections/arista/avd/requirements-dev.txt --upgrade ``` !!! note diff --git a/ansible_collections/arista/avd/plugins/__init__.py b/ansible_collections/arista/avd/plugins/__init__.py index 1a93e0335b6..473eccb2bd4 100644 --- a/ansible_collections/arista/avd/plugins/__init__.py +++ b/ansible_collections/arista/avd/plugins/__init__.py @@ -4,11 +4,12 @@ from __future__ import annotations from contextlib import suppress +from os import environ from pathlib import Path PYTHON_AVD_PATH = Path(__file__).parents[4] / "python-avd" RUNNING_FROM_SOURCE_PATH = PYTHON_AVD_PATH / "pyavd/running_from_src.txt" -RUNNING_FROM_SOURCE = RUNNING_FROM_SOURCE_PATH.exists() +RUNNING_FROM_SOURCE = RUNNING_FROM_SOURCE_PATH.exists() and not environ.get("AVD_NEVER_RUN_FROM_SOURCE") if RUNNING_FROM_SOURCE: import sys diff --git a/containers/dev/.devcontainer/entrypoint.sh b/containers/dev/.devcontainer/entrypoint.sh index 5bae915c88e..66dafa7c6a5 100644 --- a/containers/dev/.devcontainer/entrypoint.sh +++ b/containers/dev/.devcontainer/entrypoint.sh @@ -14,9 +14,10 @@ if [ -z "$(command -v ansible)" ]; then pip install "pyavd[ansible] @ ${PYAVD_INSTALL_LOCATION}" ansible-galaxy collection install --force ${AVD_INSTALL_PATH} # otherwise install requirements and collection from container workspace - elif [ -f ${CONTAINER_WSF_AVD_PATH}/requirements.txt ] && [ -f ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt ] ; then - # use editable install for requirements - pip install -r ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt -r ${CONTAINER_WSF_AVD_PATH}/requirements.txt + elif [ -f ${CONTAINER_WORKSPACE}/python-avd/pyproject.toml ] && [ -f ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt ] ; then + # Install pyavd from source and dev requirements from file + pip install ${CONTAINER_WORKSPACE}/python-avd[ansible-collection] -r ${CONTAINER_WSF_AVD_PATH}/requirements-dev.txt + # Install arista.avd collection from source ansible-galaxy collection install --force ${CONTAINER_WSF_AVD_PATH} fi diff --git a/python-avd/pyavd/constants.py b/python-avd/pyavd/constants.py index dbd65ccea82..19ad221be1f 100644 --- a/python-avd/pyavd/constants.py +++ b/python-avd/pyavd/constants.py @@ -1,9 +1,10 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. +from os import environ from pathlib import Path -RUNNING_FROM_SRC = Path(__file__).parent.joinpath("running_from_src.txt").exists() +RUNNING_FROM_SRC = Path(__file__).parent.joinpath("running_from_src.txt").exists() and not environ.get("AVD_NEVER_RUN_FROM_SOURCE") EOS_CLI_CONFIG_GEN_SCHEMA_ID = "eos_cli_config_gen" EOS_DESIGNS_SCHEMA_ID = "eos_designs" EOS_CLI_CONFIG_GEN_JINJA2_CONFIG_TEMPLATE = "eos-intended-config.j2" From 241b40080e7358ceb87f230ab978bdd8bf3d58ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:49:14 +0100 Subject: [PATCH 5/5] CI: pre-commit autoupdate (#4711) --- .pre-commit-config.yaml | 2 +- .../eos_validate_state/python_modules/tests/avdtestrouting.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc8ec3828f9..f7fefdf6a9c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -75,7 +75,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.7.2 + rev: v0.7.3 hooks: # Run the linter. - id: ruff diff --git a/ansible_collections/arista/avd/roles/eos_validate_state/python_modules/tests/avdtestrouting.py b/ansible_collections/arista/avd/roles/eos_validate_state/python_modules/tests/avdtestrouting.py index a1ec8e9e94e..46d45f36b14 100644 --- a/ansible_collections/arista/avd/roles/eos_validate_state/python_modules/tests/avdtestrouting.py +++ b/ansible_collections/arista/avd/roles/eos_validate_state/python_modules/tests/avdtestrouting.py @@ -9,7 +9,7 @@ from ansible_collections.arista.avd.plugins.plugin_utils.eos_validate_state_utils.avdtestbase import AvdTestBase from ansible_collections.arista.avd.plugins.plugin_utils.utils import default, get -from ..bgp_constants import BGP_ADDRESS_FAMILIES # noqa: TID252 Will be fixed when moving to pyavd +from ..bgp_constants import BGP_ADDRESS_FAMILIES # noqa: TID252 will be fixed when moving to pyavd LOGGER = logging.getLogger(__name__)