Skip to content
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
5 changes: 5 additions & 0 deletions module_utils/network_lsr/argument_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2771,6 +2771,11 @@ def _parse_route_tables_mapping_from_file(cls, filename, mapping):
def get_route_tables_mapping(cls):
if not hasattr(cls, "_cached_rt_tables"):
mapping = {}
# look in static built-in route tables file first
cls._parse_route_tables_mapping_from_file(
"/usr/share/iproute2/rt_tables", mapping
)
# then look in the user-defined route tables file
cls._parse_route_tables_mapping_from_file(
"/etc/iproute2/rt_tables", mapping
)
Expand Down
26 changes: 26 additions & 0 deletions tests/playbooks/tests_route_table.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
metric: 50
table: 30200
src: 198.51.100.3
- network: 198.51.101.128
prefix: 26
gateway: 198.51.101.1
metric: 2
table: main

- name: Get the routes from the route table 30200
command: ip route show table 30200
Expand All @@ -62,6 +67,12 @@
ignore_errors: true
changed_when: false

- name: Get the routes from the route table main
command: ip route show table main
register: route_table_main
ignore_errors: true
changed_when: false

- name: Assert that the route table 30200 contains the specified route
assert:
that:
Expand All @@ -81,6 +92,14 @@
msg: "the route table 30400 does not exist or does not contain the
specified route"

- name: Assert that the route table main contains the specified route
assert:
that:
- route_table_main.stdout is search("198.51.101.128/26 via
198.51.101.1 dev ethtest0 proto static metric 2")
msg: "the route table main does not exist or does not contain the
specified route"

- name: Create a dedicated test file in `/etc/iproute2/rt_tables.d/` and
add a new routing table
lineinfile:
Expand Down Expand Up @@ -121,6 +140,11 @@
metric: 50
table: custom
src: 198.51.100.3
- network: 198.51.101.128
prefix: 26
gateway: 198.51.101.1
metric: 2
table: custom

- name: Get the routes from the named route table 'custom'
command: ip route show table custom
Expand All @@ -139,6 +163,8 @@
- route_table_custom.stdout is search("192.0.2.64/26 via
198.51.100.8 dev ethtest0 proto static src 198.51.100.3
metric 50")
- route_table_custom.stdout is search("198.51.101.128/26 via
198.51.101.1 dev ethtest0 proto static metric 2")
msg: "the named route table 'custom' does not exist or does not contain
the specified route"

Expand Down
Loading