diff --git a/changelogs/fragments/static_route_encap_intf.yaml b/changelogs/fragments/static_route_encap_intf.yaml new file mode 100644 index 000000000..bd2009856 --- /dev/null +++ b/changelogs/fragments/static_route_encap_intf.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Fixes idempotency for static routes with encap interfaces diff --git a/plugins/module_utils/network/iosxr/facts/static_routes/static_routes.py b/plugins/module_utils/network/iosxr/facts/static_routes/static_routes.py index e6e37482e..d83aa9ee7 100644 --- a/plugins/module_utils/network/iosxr/facts/static_routes/static_routes.py +++ b/plugins/module_utils/network/iosxr/facts/static_routes/static_routes.py @@ -154,6 +154,7 @@ def parse_faddr(self, item): def parse_intf(self, item): inf_search_strs = [ + r" ((\w+)((?:\d)/(?:\d)/(?:\d)/(?:\d+))\.(?:\d+))", r" ((\w+)((?:\d)/(?:\d)/(?:\d)/(?:\d+)))", r" (([a-zA-Z]+)(?:\d+))", ] diff --git a/tests/integration/targets/iosxr_static_routes/tests/cli/merged.yaml b/tests/integration/targets/iosxr_static_routes/tests/cli/merged.yaml index 1ab0df6ed..79549aa81 100644 --- a/tests/integration/targets/iosxr_static_routes/tests/cli/merged.yaml +++ b/tests/integration/targets/iosxr_static_routes/tests/cli/merged.yaml @@ -29,6 +29,11 @@ - forward_router_address: 192.0.2.11 admin_distance: 100 + - dest: 192.0.2.48/28 + next_hops: + - forward_outer_address: 192.0.2.10 + interface: TenGigE0/0/0/23.2500 + - dest: 192.168.17.0/24 next_hops: - interface: Loopback0 diff --git a/tests/unit/modules/network/iosxr/fixtures/iosxr_static_routes_config.cfg b/tests/unit/modules/network/iosxr/fixtures/iosxr_static_routes_config.cfg index 309eb7662..e6be046e3 100644 --- a/tests/unit/modules/network/iosxr/fixtures/iosxr_static_routes_config.cfg +++ b/tests/unit/modules/network/iosxr/fixtures/iosxr_static_routes_config.cfg @@ -4,6 +4,7 @@ router static 192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120 192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1 192.0.2.32/28 192.0.2.11 100 + 192.0.2.48/28 TenGigE0/0/0/23.2500 192.0.2.10 ! address-family ipv6 unicast 2001:db8:1000::/36 FastEthernet0/0/0/7 description DC diff --git a/tests/unit/modules/network/iosxr/test_iosxr_static_routes.py b/tests/unit/modules/network/iosxr/test_iosxr_static_routes.py index cb0aa70f7..3e74706c5 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_static_routes.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_static_routes.py @@ -398,6 +398,35 @@ def test_iosxr_static_routes_replaced_idempotent(self): ) self.execute_module(changed=False, commands=[]) + def test_iosxr_static_routes_replaced_idempotent_encap_intf(self): + set_module_args( + dict( + config=[ + dict( + address_families=[ + dict( + afi="ipv4", + safi="unicast", + routes=[ + dict( + dest="192.0.2.48/28", + next_hops=[ + dict( + interface="TenGigE0/0/0/23.2500", + forward_router_address="192.0.2.10", + ), + ], + ), + ], + ), + ], + ), + ], + state="replaced", + ), + ) + self.execute_module(changed=False, commands=[]) + def test_iosxr_static_routes_overridden(self): set_module_args( dict(