diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
commit | 7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch) | |
tree | efb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/cisco/iosxr/plugins | |
parent | Releasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff) | |
download | ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip |
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/cisco/iosxr/plugins')
85 files changed, 12550 insertions, 6181 deletions
diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/__init__.py b/ansible_collections/cisco/iosxr/plugins/cache/__init__.py index e69de29bb..e69de29bb 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/__init__.py +++ b/ansible_collections/cisco/iosxr/plugins/cache/__init__.py diff --git a/ansible_collections/cisco/iosxr/plugins/cliconf/iosxr.py b/ansible_collections/cisco/iosxr/plugins/cliconf/iosxr.py index 706bff6e5..6b569ae2a 100644 --- a/ansible_collections/cisco/iosxr/plugins/cliconf/iosxr.py +++ b/ansible_collections/cisco/iosxr/plugins/cliconf/iosxr.py @@ -248,6 +248,17 @@ class Cliconf(CliconfBase): device_info["network_os_model"] = match.group(1) break + if "network_os_model" not in device_info: + data = self.get_command_output("show inventory") + match = re.search(r"DESCR: \"[Cc]isco (\S+ \S+)", data, re.M) + if match: + device_info["network_os_model"] = match.group(1) + + data = self.get_command_output("show inventory") + match = re.search(r"SN: (\S+)\n\nNAME:", data, re.M) + if match: + device_info["network_os_serialnum"] = match.group(1) + hostname = self.get_command_output("show running-config hostname") match = re.search(r"hostname\s(\S+)$", hostname, re.M) if match: @@ -274,7 +285,7 @@ class Cliconf(CliconfBase): if admin and "admin-" in prompt: self.send_command("exit") - def get_config(self, source="running", format="text", flags=None): + def get_config(self, source="running", flags=None, format="text"): if source not in ["running"]: raise ValueError("fetching configuration from %s is not supported" % source) @@ -290,10 +301,11 @@ class Cliconf(CliconfBase): self, candidate=None, commit=True, - admin=False, - exclusive=False, replace=None, + diff=False, comment=None, + admin=False, + exclusive=False, label=None, ): operations = self.get_device_operations() diff --git a/ansible_collections/cisco/iosxr/plugins/doc_fragments/iosxr.py b/ansible_collections/cisco/iosxr/plugins/doc_fragments/iosxr.py index 5049db819..ab9a5b155 100644 --- a/ansible_collections/cisco/iosxr/plugins/doc_fragments/iosxr.py +++ b/ansible_collections/cisco/iosxr/plugins/doc_fragments/iosxr.py @@ -9,7 +9,6 @@ __metaclass__ = type class ModuleDocFragment(object): - # Standard files documentation fragment DOCUMENTATION = r"""options: {} notes: diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/__init__.py b/ansible_collections/cisco/iosxr/plugins/lookup/__init__.py index e69de29bb..e69de29bb 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/__init__.py +++ b/ansible_collections/cisco/iosxr/plugins/lookup/__init__.py diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/__init__.py b/ansible_collections/cisco/iosxr/plugins/module_utils/common/__init__.py index e69de29bb..e69de29bb 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/__init__.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/common/__init__.py diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_address_family/bgp_address_family.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_address_family/bgp_address_family.py index 7413c1ad9..10d4e1666 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_address_family/bgp_address_family.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_address_family/bgp_address_family.py @@ -149,6 +149,9 @@ class Bgp_address_familyArgs(object): # pylint: disable=R0903 }, "dampening": { "type": "dict", + "mutually_exclusive": [ + ["set", "value", "route_policy"], + ], "options": { "set": {"type": "bool"}, "value": {"type": "int"}, diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_global/bgp_global.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_global/bgp_global.py index 051e26996..3009b9f32 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_global/bgp_global.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_global/bgp_global.py @@ -270,6 +270,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "fast_detect": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable", "strict_mode"], + ], "options": { "set": {"type": "bool"}, "disable": {"type": "bool"}, @@ -292,6 +295,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "send": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable"], + ], "options": { "set": {"type": "bool"}, "disable": {"type": "bool"}, @@ -299,6 +305,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "receive": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable"], + ], "options": { "set": {"type": "bool"}, "disable": {"type": "bool"}, @@ -317,6 +326,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "all": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -332,6 +344,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "description": {"type": "str"}, "dmz_link_bandwidth": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": {"type": "bool"}, "set": {"type": "bool"}, @@ -340,6 +355,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "dscp": {"type": "str"}, "ebgp_multihop": { "type": "dict", + "mutually_exclusive": [ + ["value", "mpls"], + ], "options": { "value": {"type": "int"}, "mpls": {"type": "bool"}, @@ -347,6 +365,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "ebgp_recv_extcommunity_dmz": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": {"type": "bool"}, "set": {"type": "bool"}, @@ -354,6 +375,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "ebgp_send_extcommunity_dmz": { "type": "dict", + "mutually_exclusive": [ + ["set", "cumulatie", "inheritance_disable"], + ], "options": { "inheritance_disable": {"type": "bool"}, "cumulatie": {"type": "bool"}, @@ -362,6 +386,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "egress_engineering": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": {"type": "bool"}, "set": {"type": "bool"}, @@ -377,6 +404,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "set": {"type": "bool"}, "activate": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -386,6 +416,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "as_prepends": { "type": "dict", + "mutually_exclusive": [ + ["value", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -395,6 +428,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "local_preference": { "type": "dict", + "mutually_exclusive": [ + ["value", "inheritance_disable"], + ], "options": { "value": {"type": "int"}, "inheritance_disable": { @@ -413,6 +449,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "ignore_connected_check": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": {"type": "bool"}, "set": {"type": "bool"}, @@ -421,6 +460,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "keychain": { "type": "dict", "no_log": False, + "mutually_exclusive": [ + ["name", "inheritance_disable"], + ], "options": { "name": {"type": "str"}, "inheritance_disable": {"type": "bool"}, @@ -431,6 +473,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "address": { "type": "dict", + "mutually_exclusive": [ + ["ipv4_address", "inheritance_disable"], + ], "options": { "ipv4_address": {"type": "str"}, "inheritance_disable": { @@ -442,8 +487,24 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "local_as": { "type": "dict", + "mutually_exclusive": [ + ["value", "inheritance_disable"], + ], "options": { "value": {"type": "int"}, + "no_prepend": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "replace_as": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "dual_as": {"type": "bool"}, + }, + }, + }, + }, "inheritance_disable": {"type": "bool"}, }, }, @@ -455,6 +516,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "in": { "type": "dict", + "mutually_exclusive": [ + ["value", "disable", "inheritance_disable"], + ], "options": { "value": {"type": "int"}, "disable": {"type": "bool"}, @@ -465,6 +529,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "out": { "type": "dict", + "mutually_exclusive": [ + ["value", "disable", "inheritance_disable"], + ], "options": { "value": {"type": "int"}, "disable": {"type": "bool"}, @@ -486,6 +553,19 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, }, }, + "password": { + "type": "dict", + "no_log": False, + "mutually_exclusive": [ + ["encrypted", "inheritance_disable"], + ], + "options": { + "encrypted": {"type": "str", "no_log": True}, + "inheritance_disable": { + "type": "bool", + }, + }, + }, "receive_buffer_size": {"type": "int"}, "remote_as": {"type": "int"}, "send_buffer_size": {"type": "int"}, @@ -495,6 +575,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "shutdown": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": {"type": "bool"}, "set": {"type": "bool"}, @@ -505,6 +588,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "mss": { "type": "dict", + "mutually_exclusive": [ + ["value", "inheritance_disable"], + ], "options": { "value": {"type": "int"}, "inheritance_disable": { @@ -523,6 +609,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "ttl_security": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": {"type": "bool"}, "set": {"type": "bool"}, @@ -568,10 +657,24 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, }, "update_source": {"type": "str"}, + "use": { + "type": "dict", + "options": { + "neighbor_group": { + "type": "str", + }, + "session_group": { + "type": "str", + }, + }, + }, }, }, "nsr": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable"], + ], "options": { "set": {"type": "bool"}, "disable": {"type": "bool"}, @@ -862,6 +965,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "fast_detect": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable", "strict_mode"], + ], "options": { "set": {"type": "bool"}, "disable": {"type": "bool"}, @@ -886,6 +992,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "send": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable"], + ], "options": { "set": { "type": "bool", @@ -897,6 +1006,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "receive": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable"], + ], "options": { "set": { "type": "bool", @@ -921,6 +1033,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "all": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -938,6 +1053,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "description": {"type": "str"}, "dmz_link_bandwidth": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -955,6 +1073,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "ebgp_recv_extcommunity_dmz": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -964,6 +1085,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "ebgp_send_extcommunity_dmz": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -974,6 +1098,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "egress_engineering": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -991,6 +1118,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "set": {"type": "bool"}, "activate": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -1000,6 +1130,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "as_prepends": { "type": "dict", + "mutually_exclusive": [ + ["value", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -1009,6 +1142,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "local_preference": { "type": "dict", + "mutually_exclusive": [ + ["value", "inheritance_disable"], + ], "options": { "value": {"type": "int"}, "inheritance_disable": { @@ -1027,6 +1163,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "ignore_connected_check": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -1036,6 +1175,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "keychain": { "type": "dict", + "mutually_exclusive": [ + ["name", "inheritance_disable"], + ], "no_log": False, "options": { "name": {"type": "str"}, @@ -1049,6 +1191,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "address": { "type": "dict", + "mutually_exclusive": [ + ["ipv4_address", "inheritance_disable"], + ], "options": { "ipv4_address": { "type": "str", @@ -1062,8 +1207,24 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "local_as": { "type": "dict", + "mutually_exclusive": [ + ["value", "inheritance_disable"], + ], "options": { "value": {"type": "int"}, + "no_prepend": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "replace_as": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "dual_as": {"type": "bool"}, + }, + }, + }, + }, "inheritance_disable": { "type": "bool", }, @@ -1077,6 +1238,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "in": { "type": "dict", + "mutually_exclusive": [ + ["value", "disable", "inheritance_disable"], + ], "options": { "value": { "type": "int", @@ -1091,6 +1255,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "out": { "type": "dict", + "mutually_exclusive": [ + ["value", "disable", "inheritance_disable"], + ], "options": { "value": { "type": "int", @@ -1118,6 +1285,19 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, }, }, + "password": { + "type": "dict", + "mutually_exclusive": [ + ["encrypted", "inheritance_disable"], + ], + "no_log": False, + "options": { + "encrypted": {"type": "str", "no_log": True}, + "inheritance_disable": { + "type": "bool", + }, + }, + }, "receive_buffer_size": {"type": "int"}, "remote_as": {"type": "int"}, "send_buffer_size": {"type": "int"}, @@ -1131,6 +1311,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "shutdown": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -1143,6 +1326,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "options": { "mss": { "type": "dict", + "mutually_exclusive": [ + ["value", "inheritance_disable"], + ], "options": { "value": {"type": "int"}, "inheritance_disable": { @@ -1161,6 +1347,9 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, "ttl_security": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "inheritance_disable": { "type": "bool", @@ -1208,6 +1397,17 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 }, }, "update_source": {"type": "str"}, + "use": { + "type": "dict", + "options": { + "neighbor_group": { + "type": "str", + }, + "session_group": { + "type": "str", + }, + }, + }, }, }, "rd": { @@ -1239,6 +1439,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "deleted", "merged", "replaced", + "overridden", "gathered", "rendered", "parsed", diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py index a720860b7..68e1bbeae 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -80,6 +80,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "send_cost_community_disable": {"type": "bool"}, "send_med": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable"], + ], "options": { "set": {"type": "bool"}, "disable": {"type": "bool"}, @@ -89,10 +92,16 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "allowas_in": { "type": "dict", + "mutually_exclusive": [ + ["set", "value"], + ], "options": {"value": {"type": "int"}, "set": {"type": "bool"}}, }, "as_override": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -105,6 +114,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "default_originate": { "type": "dict", + "mutually_exclusive": [ + ["set", "route_policy", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "route_policy": {"type": "str"}, @@ -137,6 +149,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "multipath": {"type": "bool"}, "next_hop_self": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -179,6 +194,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "route_reflector_client": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -186,6 +204,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "send_community_ebgp": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -193,6 +214,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "send_community_gshut_ebgp": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -200,6 +224,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "send_extended_community_ebgp": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -207,6 +234,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "send_multicast_attributes": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable"], + ], "options": { "set": {"type": "bool"}, "disable": {"type": "bool"}, @@ -217,6 +247,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "options": { "inbound": { "type": "dict", + "mutually_exclusive": [ + ["set", "always", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "always": {"type": "bool"}, @@ -271,6 +304,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "send_cost_community_disable": {"type": "bool"}, "send_med": { "type": "dict", + "mutually_exclusive": [ + ["set", "disable"], + ], "options": { "set": {"type": "bool"}, "disable": {"type": "bool"}, @@ -280,6 +316,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "allowas_in": { "type": "dict", + "mutually_exclusive": [ + ["value", "set"], + ], "options": { "value": {"type": "int"}, "set": {"type": "bool"}, @@ -288,6 +327,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "as_override": { "type": "dict", "aliases": ["as_overrride"], + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -299,6 +341,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "default_originate": { "type": "dict", + "mutually_exclusive": [ + ["set", "route_policy", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "route_policy": {"type": "str"}, @@ -331,6 +376,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "multipath": {"type": "bool"}, "next_hop_self": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -364,6 +412,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "route_reflector_client": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -371,6 +422,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "send_community_ebgp": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -378,6 +432,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "send_community_gshut_ebgp": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -385,6 +442,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, "send_extended_community_ebgp": { "type": "dict", + "mutually_exclusive": [ + ["set", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "inheritance_disable": {"type": "bool"}, @@ -395,6 +455,9 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 "options": { "inbound": { "type": "dict", + "mutually_exclusive": [ + ["set", "always", "inheritance_disable"], + ], "options": { "set": {"type": "bool"}, "always": {"type": "bool"}, diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/__init__.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_templates/__init__.py index e69de29bb..e69de29bb 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/__init__.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_templates/__init__.py diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_templates/bgp_templates.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_templates/bgp_templates.py new file mode 100644 index 000000000..793f26282 --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/bgp_templates/bgp_templates.py @@ -0,0 +1,612 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the +# ansible.content_builder. +# +# Manually editing this file is not advised. +# +# To update the argspec make the desired changes +# in the documentation in the module file and re-run +# ansible.content_builder commenting out +# the path to external 'docstring' in build.yaml. +# +############################################## + +""" +The arg spec for the iosxr_bgp_templates module +""" + + +class Bgp_templatesArgs(object): # pylint: disable=R0903 + """The arg spec for the iosxr_bgp_templates module""" + + argument_spec = { + "config": { + "type": "dict", + "options": { + "as_number": {"type": "str"}, + "neighbor": { + "type": "list", + "elements": "dict", + "options": { + "name": {"type": "str"}, + "address_family": { + "type": "list", + "elements": "dict", + "options": { + "afi": { + "type": "str", + "choices": ["ipv4", "ipv6"], + }, + "safi": { + "type": "str", + "choices": [ + "flowspec", + "mdt", + "multicast", + "mvpn", + "rt-filter", + "tunnel", + "unicast", + "labeled-unicast", + "sr-policy", + ], + }, + "signalling": { + "type": "dict", + "options": { + "bgp_disable": {"type": "bool"}, + "ldp_disable": {"type": "bool"}, + }, + }, + "advertise": { + "type": "dict", + "options": { + "local_labeled_route": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "disable": {"type": "bool"}, + }, + }, + "permanent_network": {"type": "bool"}, + }, + }, + "aigp": { + "type": "dict", + "options": { + "disable": {"type": "bool"}, + "set": {"type": "bool"}, + "send_cost_community_disable": { + "type": "bool", + }, + "send_med": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "disable": {"type": "bool"}, + }, + }, + }, + }, + "allowas_in": { + "type": "dict", + "options": { + "value": {"type": "int"}, + "set": {"type": "bool"}, + }, + }, + "as_override": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "bestpath_origin_as_allow_invalid": { + "type": "bool", + }, + "capability_orf_prefix": { + "type": "str", + "choices": ["both", "send", "none", "receive"], + }, + "default_originate": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "route_policy": {"type": "str"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "encapsulation_type_srv6": {"type": "bool"}, + "long_lived_graceful_restart": { + "type": "dict", + "options": { + "capable": {"type": "bool"}, + "stale_time": { + "type": "dict", + "options": { + "send": {"type": "int"}, + "accept": {"type": "int"}, + }, + }, + }, + }, + "maximum_prefix": { + "type": "dict", + "options": { + "max_limit": {"type": "int"}, + "threshold_value": {"type": "int"}, + "restart": {"type": "int"}, + "warning_only": {"type": "bool"}, + "discard_extra_paths": {"type": "bool"}, + }, + }, + "multipath": {"type": "bool"}, + "next_hop_self": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "next_hop_unchanged": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "inheritance_disable": {"type": "bool"}, + "multipath": {"type": "bool"}, + }, + }, + "optimal_route_reflection_group_name": { + "type": "str", + }, + "orf_route_policy": {"type": "str"}, + "origin_as": { + "type": "dict", + "options": { + "validation": { + "type": "dict", + "options": { + "disable": {"type": "bool"}, + }, + }, + }, + }, + "remove_private_AS": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "inbound": {"type": "bool"}, + "entire_aspath": {"type": "bool"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "route_policy": { + "type": "dict", + "options": { + "inbound": {"type": "str"}, + "outbound": {"type": "str"}, + }, + }, + "route_reflector_client": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "send_community_ebgp": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "send_community_gshut_ebgp": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "send_extended_community_ebgp": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "send_multicast_attributes": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "disable": {"type": "bool"}, + }, + }, + "soft_reconfiguration": { + "type": "dict", + "options": { + "inbound": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "always": {"type": "bool"}, + "inheritance_disable": { + "type": "bool", + }, + }, + }, + }, + }, + "weight": {"type": "int"}, + "update": { + "type": "dict", + "options": { + "out_originator_loopcheck_disable": { + "type": "bool", + }, + "out_originator_loopcheck_set": { + "type": "bool", + }, + }, + }, + "use": {"type": "str"}, + }, + }, + "advertisement_interval": {"type": "int"}, + "bfd": { + "type": "dict", + "options": { + "fast_detect": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "disable": {"type": "bool"}, + "strict_mode": {"type": "bool"}, + }, + }, + "minimum_interval": {"type": "int"}, + "multiplier": {"type": "int"}, + }, + }, + "bmp_activate": { + "type": "dict", + "options": {"server": {"type": "int"}}, + }, + "capability": { + "type": "dict", + "options": { + "additional_paths": { + "type": "dict", + "options": { + "send": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "disable": {"type": "bool"}, + }, + }, + "receive": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "disable": {"type": "bool"}, + }, + }, + }, + }, + "suppress": { + "type": "dict", + "options": { + "four_byte_AS": { + "type": "dict", + "options": {"set": {"type": "bool"}}, + }, + "all": { + "type": "dict", + "options": { + "inheritance_disable": { + "type": "bool", + }, + "set": {"type": "bool"}, + }, + }, + }, + }, + }, + }, + "cluster_id": {"type": "str"}, + "description": {"type": "str"}, + "dmz_link_bandwidth": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "set": {"type": "bool"}, + }, + }, + "dscp": {"type": "str"}, + "ebgp_multihop": { + "type": "dict", + "options": { + "value": {"type": "int"}, + "mpls": {"type": "bool"}, + }, + }, + "ebgp_recv_extcommunity_dmz": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "set": {"type": "bool"}, + }, + }, + "ebgp_send_extcommunity_dmz": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "cumulatie": {"type": "bool"}, + "set": {"type": "bool"}, + }, + }, + "egress_engineering": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "set": {"type": "bool"}, + }, + }, + "enforce_first_as": { + "type": "dict", + "options": {"disable": {"type": "bool"}}, + }, + "graceful_maintenance": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "activate": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "set": {"type": "bool"}, + }, + }, + "as_prepends": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "value": {"type": "int"}, + }, + }, + "local_preference": { + "type": "dict", + "options": { + "value": {"type": "int"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + }, + }, + "graceful_restart": { + "type": "dict", + "options": { + "restart_time": {"type": "int"}, + "stalepath_time": {"type": "int"}, + }, + }, + "ignore_connected_check": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "set": {"type": "bool"}, + }, + }, + "idle_watch_time": {"type": "int"}, + "internal_vpn_client": {"type": "bool"}, + "keychain": { + "type": "dict", + "no_log": False, + "options": { + "name": {"type": "str", "no_log": True}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "local": { + "type": "dict", + "options": { + "address": { + "type": "dict", + "options": { + "ipv4_address": {"type": "str"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + }, + }, + "local_as": { + "type": "dict", + "options": { + "value": {"type": "int"}, + "no_prepend": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "replace_as": { + "type": "dict", + "options": { + "set": {"type": "bool"}, + "dual_as": {"type": "bool"}, + }, + }, + }, + }, + "inheritance_disable": {"type": "bool"}, + }, + }, + "local_address_subnet": {"type": "str"}, + "log": { + "type": "dict", + "options": { + "log_message": { + "type": "dict", + "options": { + "in": { + "type": "dict", + "options": { + "value": {"type": "int"}, + "disable": {"type": "bool"}, + "inheritance_disable": { + "type": "bool", + }, + }, + }, + "out": { + "type": "dict", + "options": { + "value": {"type": "int"}, + "disable": {"type": "bool"}, + "inheritance_disable": { + "type": "bool", + }, + }, + }, + }, + }, + }, + }, + "maximum_peers": {"type": "int"}, + "password": { + "type": "dict", + "no_log": False, + "options": { + "encrypted": {"type": "str", "no_log": True}, + "inheritance_disable": {"type": "bool"}, + }, + }, + "peer_set": {"type": "int"}, + "precedence": { + "type": "str", + "choices": [ + "critical", + "flash", + "flash-override", + "immediate", + "internet", + "network", + "priority", + "routine", + ], + }, + "receive_buffer_size": {"type": "int"}, + "remote_as": {"type": "int"}, + "remote_as_list": {"type": "str"}, + "send_buffer_size": {"type": "int"}, + "session_open_mode": { + "type": "str", + "choices": ["active-only", "both", "passive-only"], + }, + "shutdown": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "set": {"type": "bool"}, + }, + }, + "tcp": { + "type": "dict", + "options": { + "mss": { + "type": "dict", + "options": { + "value": {"type": "int"}, + "inheritance_disable": {"type": "bool"}, + }, + }, + }, + }, + "timers": { + "type": "dict", + "options": { + "keepalive_time": {"type": "int"}, + "holdtime": {"type": "int"}, + "min_holdtime": {"type": "int"}, + }, + }, + "ttl_security": { + "type": "dict", + "options": { + "inheritance_disable": {"type": "bool"}, + "set": {"type": "bool"}, + }, + }, + "update": { + "type": "dict", + "options": { + "in": { + "type": "dict", + "options": { + "filtering": { + "type": "dict", + "options": { + "attribute_filter": { + "type": "dict", + "options": { + "group": {"type": "str"}, + }, + }, + "logging": { + "type": "dict", + "options": { + "disable": {"type": "bool"}, + }, + }, + "update_message": { + "type": "dict", + "options": { + "buffers": {"type": "int"}, + }, + }, + }, + }, + }, + }, + }, + }, + "update_source": {"type": "str"}, + "use": { + "type": "dict", + "options": { + "neighbor_group": {"type": "str"}, + "session_group": {"type": "str"}, + }, + }, + }, + }, + }, + }, + "running_config": {"type": "str"}, + "state": { + "type": "str", + "choices": [ + "deleted", + "merged", + "overridden", + "replaced", + "gathered", + "rendered", + "parsed", + ], + "default": "merged", + }, + } # pylint: disable=C0301 diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/l2_interfaces/l2_interfaces.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/l2_interfaces/l2_interfaces.py index e58ddebbb..dff2f7680 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/l2_interfaces/l2_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/l2_interfaces/l2_interfaces.py @@ -69,6 +69,7 @@ class L2_InterfacesArgs(object): "type": "list", }, "q_vlan": {"type": "list", "elements": "int"}, + "qvlan": {"type": "list", "elements": "str"}, "propagate": {"type": "bool"}, "encapsulation": { "type": "dict", diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/lacp/lacp.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/lacp/lacp.py index 2bdda1778..3fcaf8cb0 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/lacp/lacp.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/lacp/lacp.py @@ -58,6 +58,7 @@ class LacpArgs(object): # pylint: disable=R0903 "choices": [ "merged", "replaced", + "overridden", "deleted", "parsed", "rendered", diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/lldp_global/lldp_global.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/lldp_global/lldp_global.py index 6c6c39479..117065223 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/lldp_global/lldp_global.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/argspec/lldp_global/lldp_global.py @@ -62,6 +62,7 @@ class Lldp_globalArgs(object): # pylint: disable=R0903 "choices": [ "merged", "replaced", + "overridden", "deleted", "parsed", "rendered", diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py index 9f9b1ea61..0e0ea7d00 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/acls/acls.py @@ -502,7 +502,8 @@ class Acls(ConfigBase): ) ^ set(flatten_dict(want_ace.get("protocol_options", {}))) if delta or protocol_opt_delta: - want_ace = self._dict_merge(have_ace, want_ace) + if self.state not in ["replaced"]: + want_ace = self._dict_merge(have_ace, want_ace) return self._compute_commands(want_ace) def _prepare_for_diff(self, ace): diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py index 69b752be9..4cb4083c6 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py @@ -116,6 +116,7 @@ class Bgp_global(ResourceModule): """ if self.state not in ["parsed", "gathered"]: self.generate_commands() + # import epdb;epdb.serve() self.run_commands() return self.result @@ -123,7 +124,7 @@ class Bgp_global(ResourceModule): """Generate configuration commands to send based on want, have and desired state. """ - if self.state in ["merged", "replaced"]: + if self.state in ["merged", "replaced", "overridden"]: w_asn = self.want.get("as_number") h_asn = self.have.get("as_number") @@ -242,6 +243,8 @@ class Bgp_global(ResourceModule): for the Bgp_global neighbor resource. """ neighbor_parsers = [ + "use.neighbor_group", + "use.session_group", "advertisement_interval", "bfd_fast_detect_disable", "bfd_fast_detect_strict_mode", @@ -275,6 +278,8 @@ class Bgp_global(ResourceModule): "local", "local_address", "origin_as", + "password_inheritance_disable", + "password_encrypted", "remote_as", "receive_buffer_size", "send_buffer_size", diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_templates/__init__.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_templates/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_templates/__init__.py diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_templates/bgp_templates.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_templates/bgp_templates.py new file mode 100644 index 000000000..c62687dfa --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/bgp_templates/bgp_templates.py @@ -0,0 +1,295 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The iosxr_bgp_templates config file. +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to its desired end-state is +created. +""" + +from copy import deepcopy + +from ansible.module_utils.six import iteritems +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( + ResourceModule, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, +) + +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.facts.facts import Facts +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.rm_templates.bgp_templates import ( + Bgp_templatesTemplate, +) + + +class Bgp_templates(ResourceModule): + """ + The iosxr_bgp_templates config class + """ + + def __init__(self, module): + super(Bgp_templates, self).__init__( + empty_fact_val={}, + facts_module=Facts(module), + module=module, + resource="bgp_templates", + tmplt=Bgp_templatesTemplate(), + ) + self.parsers = [ + "router", + "advertise.local_labeled_route.disable", + "advertise.local_labeled_route.set", + "advertise.permanent_network", + "aigp.set", + "aigp.disable", + "aigp.send_med", + "aigp.send_cost_community_disable", + "allowas_in", + "as_override", + "bestpath_origin_as_allow_invalid", + "capability_orf_prefix", + "default_originate.set", + "default_originate.route_policy", + "default_originate.inheritance_disable", + "long_lived_graceful_restart_capable", + "long_lived_graceful_restart_stale_time", + "maximum_prefix", + "multipath", + "next_hop_self", + "next_hop_unchanged.set", + "next_hop_unchanged.inheritance_disable", + "next_hop_unchanged.multipath", + "optimal_route_reflection_group_name", + "origin_as", + "remove_private_AS", + "remove_private_AS.set", + "route_reflector_client", + "send_community_ebgp", + "send_community_gshut_ebgp", + "send_extended_community_ebgp", + "send_multicast_attributes", + "soft_reconfiguration", + "weight", + "route_policy.inbound", + "route_policy.outbound", + "signalling", + "update.out_originator_loopcheck_disable", + "update.out_originator_loopcheck_set", + "use", + ] + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + if self.state not in ["parsed", "gathered"]: + self.generate_commands() + self.run_commands() + + return self.result + + def generate_commands(self): + """Generate configuration commands to send based on + want, have and desired state. + """ + w_asn = self.want.pop("as_number", "") + h_asn = self.have.pop("as_number", "") + + asn = w_asn or h_asn + wantd = self._bgp_list_to_dict(deepcopy(self.want)) + haved = self._bgp_list_to_dict(deepcopy(self.have)) + # if state is merged, merge want onto have and then compare + if self.state == "merged": + wantd = dict_merge(haved, wantd) + + # if state is deleted, empty out wantd and set haved to wantd + if self.state == "deleted": + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} + wantd = {} + + if self.state in ["overridden", "deleted"]: + cmds = [] + for k, have in iteritems(haved.get("neighbor", {})): + if k not in wantd.get("neighbor", {}): + cmds.append("no neighbor-group {0}".format(have["name"])) + self.commands.extend(cmds) + + self._compare(asn, want=wantd, have=haved) + + def sort_commands(self, index): + old_cmd = self.commands[index:] + self.commands = self.commands[0:index] + self.commands.extend( + [each for each in old_cmd if "no" in each] + + [each for each in old_cmd if "no" not in each], + ) + + def _compare(self, asn, want, have): + """Leverages the base class `compare()` method and + populates the list of commands to be run by comparing + the `want` and `have` data with the `parsers` defined + for the Bgp_global network resource. + """ + self._compare_ngs(want=want, have=have) + if self.commands and "router bgp" not in self.commands[0]: + self.commands.insert(0, "router bgp {0}".format(asn)) + + def _compare_ngs(self, want, have): + """Leverages the base class `compare()` method and + populates the list of commands to be run by comparing + the `want` and `have` data with the `parsers` defined + for the Bgp_global neighbor resource. + """ + neighbor_parsers = [ + "use.neighbor_group", + "use.session_group", + "advertisement_interval", + "bfd_fast_detect_disable", + "bfd_fast_detect_strict_mode", + "bfd_fast_detect_set", + "bfd_nbr_minimum_interval", + "bfd_nbr_multiplier", + "bmp_activate", + "dmz_link_bandwidth", + "dmz_link_bandwidth_inheritance_disable", + "neighbor_description", + "neighbor_cluster_id", + "dscp", + "ebgp_multihop_value", + "ebgp_multihop_mpls", + "ebgp_recv_extcommunity_dmz", + "ebgp_recv_extcommunity_dmz_set", + "ebgp_send_extcommunity_dmz", + "ebgp_send_extcommunity_dmz_set", + "ebgp_send_extcommunity_dmz_cumulatie", + "egress_engineering", + "egress_engineering_set", + "idle_watch_time", + "internal_vpn_client", + "ignore_connected_check", + "ignore_connected_check_set", + "neighbor_enforce_first_as_disable", + "neighbor_graceful_restart_restart_time", + "neighbor_graceful_restart_stalepath_time", + "keychain", + "keychain_name", + "local_as_inheritance_disable", + "local_as", + "local", + "local_address", + "origin_as", + "password_inheritance_disable", + "password_encrypted", + "peer_set", + "precedence", + "remote_as", + "remote_as_list", + "receive_buffer_size", + "send_buffer_size", + "session_open_mode", + "neighbor_shutdown", + "neighbor_shutdown_inheritance_disable", + "neighbor_tcp_mss", + "neighbor_tcp_mss_inheritance_disable", + "neighbor_timers_keepalive", + "update_source", + "neighbor_ttl_security_inheritance_disable", + "neighbor_ttl_security", + "neighbor_graceful_maintenance_set", + "neighbor_graceful_maintenance_activate", + "neighbor_graceful_maintenance_activate_inheritance_disable", + "neighbor_graceful_maintenance_as_prepends", + "neighbor_graceful_maintenance_local_preference_disable", + "neighbor_graceful_maintenance_local_preference", + "neighbor_graceful_maintenance_as_prepends_value", + "neighbor_capability_additional_paths_send", + "neighbor_capability_additional_paths_send_disable", + "neighbor_capability_additional_paths_rcv_disable", + "neighbor_capability_additional_paths_rcv", + "neighbor_capability_suppress_four_byte_AS", + "neighbor_capability_suppress_all", + "neighbor_capability_suppress_all_inheritance_disable", + "neighbor_log_message_in_value", + "neighbor_log_message_in_disable", + "neighbor_log_message_in_inheritance_disable", + "neighbor_log_message_out_value", + "neighbor_log_message_out_disable", + "neighbor_log_message_out_inheritance_disable", + "neighbor_update_in_filtering_attribute_filter_group", + "neighbor_update_in_filtering_logging_disable", + "neighbor_update_in_filtering_message_buffers", + ] + + want_nbr = want.get("neighbor", {}) + have_nbr = have.get("neighbor", {}) + for name, entry in iteritems(want_nbr): + have = have_nbr.pop(name, {}) + begin = len(self.commands) + self.compare(parsers=neighbor_parsers, want=entry, have=have) + if self.state in ["replaced", "overridden"]: + self.sort_commands(begin) + self._compare_af(want=entry, have=have) + name = entry.get("name", "") + if len(self.commands) != begin: + self.commands.insert( + begin, + self._tmplt.render( + {"name": name}, + "neighbor_group", + False, + ), + ) + + def _compare_af(self, want, have): + """Custom handling of afs option + :params want: the want BGP dictionary + :params have: the have BGP dictionary + """ + wafs = want.get("address_family", {}) + hafs = have.get("address_family", {}) + for name, entry in iteritems(wafs): + begin = len(self.commands) + af_have = hafs.pop(name, {}) + self.compare(parsers=self.parsers, want=entry, have=af_have) + if self.state in ["replaced", "overridden"]: + self.sort_commands(begin) + if len(self.commands) != begin or (not af_have and entry): + self.commands.insert( + begin, + self._tmplt.render( + {"afi": entry.get("afi"), "safi": entry.get("safi")}, + "address_family", + False, + ), + ) + + for name, entry in iteritems(hafs): + self.addcmd( + {"afi": entry.get("afi"), "safi": entry.get("safi")}, + "address_family", + True, + ) + + def _bgp_list_to_dict(self, data): + if "neighbor" in data: + for nbr in data["neighbor"]: + if "address_family" in nbr: + nbr["address_family"] = { + (x["afi"], x.get("safi")): x for x in nbr["address_family"] + } + data["neighbor"] = {x["name"]: x for x in data["neighbor"]} + return data diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/interfaces/interfaces.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/interfaces/interfaces.py index 2a0c18852..d13206109 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/interfaces/interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/interfaces/interfaces.py @@ -181,21 +181,33 @@ class Interfaces(ConfigBase): to the desired configuration """ commands = [] + not_in_have = set() + in_have = set() for each in have: for interface in want: - if each["name"] == interface["name"] or interface["name"] in each["name"]: + interface["name"] = normalize_interface(interface["name"]) + if each["name"] == interface["name"]: + in_have.add(interface["name"]) break + if interface["name"] != each["name"]: + not_in_have.add(interface["name"]) else: # We didn't find a matching desired state, which means we can # pretend we received an empty desired state. interface = dict(name=each["name"]) - commands.extend(self._clear_config(interface, each)) + kwargs = {"want": interface, "have": each} + commands.extend(self._clear_config(**kwargs)) continue have_dict = filter_dict_having_none_value(interface, each) - want = dict() - commands.extend(self._clear_config(want, have_dict)) + commands.extend(self._clear_config(dict(), have_dict)) commands.extend(self._set_config(interface, each)) + # Add the want interface that's not already configured in have interface + for each in not_in_have - in_have: + for every in want: + interface = "interface {0}".format(every["name"]) + if each and interface not in commands: + commands.extend(self._set_config(every, {})) # Remove the duplicate interface call commands = remove_duplicate_interface(commands) @@ -305,6 +317,17 @@ class Interfaces(ConfigBase): and want.get("duplex") != have.get("duplex") ): remove_command_from_config_list(interface, "duplex", commands) + + if interface_type.lower() in [ + "gigabitethernet", + "fourhundredgige", + "fiftygige", + "fortygige", + "hundredgige", + "twohundredgige", + "tengige", + "twentyfivegige", + ]: if have.get("mtu") and want.get("mtu") != have.get("mtu"): remove_command_from_config_list(interface, "mtu", commands) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/l2_interfaces/l2_interfaces.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/l2_interfaces/l2_interfaces.py index c571d3fa0..da44bb709 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/l2_interfaces/l2_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/l2_interfaces/l2_interfaces.py @@ -262,12 +262,20 @@ class L2_Interfaces(ConfigBase): return commands + def _handle_deprecated(self, config): + if config.get("q_vlan"): + config["qvlan"] = config.get("q_vlan") + del config["q_vlan"] + return config + def _set_config(self, want, have, module): # Set the interface config based on the want and have config commands = [] interface = "interface " + want["name"] l2_protocol_bool = False # Get the diff b/w want and have + want = self._handle_deprecated(want) + have = self._handle_deprecated(have) diff = dict_diff(have, want) if diff: # For merging with already configured l2protocol @@ -286,7 +294,7 @@ class L2_Interfaces(ConfigBase): wants_native = diff.get("native_vlan") l2transport = diff.get("l2transport") - q_vlan = diff.get("q_vlan") + qvlan = diff.get("qvlan") encapsulation = diff.get("encapsulation") propagate = diff.get("propagate") if l2_protocol_bool is False: @@ -308,18 +316,16 @@ class L2_Interfaces(ConfigBase): ) add_command_to_config_list(interface, cmd, commands) - if q_vlan and "." in interface: - q_vlans = " ".join(map(str, want.get("q_vlan"))) - if q_vlans != have.get("q_vlan"): + if qvlan and "." in interface: + q_vlans = " ".join(map(str, want.get("qvlan"))) + if q_vlans != have.get("qvlan"): cmd = "dot1q vlan {0}".format(q_vlans) add_command_to_config_list(interface, cmd, commands) else: if l2transport or l2protocol: for each in l2protocol: each = dict(each) - if isinstance(each, dict) and "cpsv" in list( - each.keys(), - ): + if isinstance(each, dict) and each.get("cpsv"): cmd = "l2transport l2protocol {0} {1}".format( "cpsv", each.get("cpsv"), @@ -361,6 +367,8 @@ class L2_Interfaces(ConfigBase): def _clear_config(self, want, have): # Delete the interface config based on the want and have config commands = [] + want = self._handle_deprecated(want) + have = self._handle_deprecated(have) if want.get("name"): interface = "interface " + want["name"] @@ -375,7 +383,7 @@ class L2_Interfaces(ConfigBase): commands, ) - if have.get("q_vlan"): + if have.get("qvlan"): remove_command_from_config_list( interface, "encapsulation dot1q", diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/l3_interfaces/l3_interfaces.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/l3_interfaces/l3_interfaces.py index 98b7c5965..9b55e2f91 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/l3_interfaces/l3_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/l3_interfaces/l3_interfaces.py @@ -11,6 +11,8 @@ created from __future__ import absolute_import, division, print_function +import copy + __metaclass__ = type @@ -119,7 +121,7 @@ class L3_Interfaces(ConfigBase): to the desired configuration """ want = self._module.params["config"] - have = existing_l3_interfaces_facts + have = copy.deepcopy(existing_l3_interfaces_facts) resp = self.set_state(want, have) return to_list(resp) @@ -308,8 +310,12 @@ class L3_Interfaces(ConfigBase): if want.get("ipv4"): for each in want.get("ipv4"): if each.get("address") != "dhcp": - ip_addr_want = validate_n_expand_ipv4(module, each) - each["address"] = ip_addr_want + each["address"] = validate_n_expand_ipv4(module, each) + + if have.get("ipv4"): + for each in have.get("ipv4"): + if each.get("address") != "dhcp": + each["address"] = validate_n_expand_ipv4(module, each) # Get the diff b/w want and have want_dict = dict_to_set(want) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/lacp/lacp.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/lacp/lacp.py index 8a6744e54..ee0a7768d 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/lacp/lacp.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/lacp/lacp.py @@ -137,6 +137,7 @@ class Lacp(ConfigBase): :returns: the commands necessary to migrate the current configuration to the desired configuration """ + commands = [] if self.state in ("merged", "replaced", "rendered") and not want: self._module.fail_json( msg="value of config parameter must not be empty for state {0}".format( @@ -148,7 +149,7 @@ class Lacp(ConfigBase): commands = self._state_deleted(want, have) elif self.state in ("merged", "rendered"): commands = self._state_merged(want, have) - elif self.state == "replaced": + elif self.state in ["replaced", "overridden"]: commands = self._state_replaced(want, have) return commands diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/lldp_global/lldp_global.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/lldp_global/lldp_global.py index e4fda3c7c..a5c872f6f 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/lldp_global/lldp_global.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/lldp_global/lldp_global.py @@ -80,7 +80,6 @@ class Lldp_global(ConfigBase): commands.extend(self.set_config(existing_lldp_global_facts)) if commands and self.state in self.ACTION_STATES: - if not self._module.check_mode: self._connection.edit_config(commands) result["changed"] = True @@ -136,6 +135,7 @@ class Lldp_global(ConfigBase): :returns: the commands necessary to migrate the current configuration to the desired configuration """ + commands = [] state = self._module.params["state"] if state in ("merged", "replaced", "rendered") and not want: self._module.fail_json( @@ -148,7 +148,7 @@ class Lldp_global(ConfigBase): commands = self._state_deleted(want, have) elif state in ("merged", "rendered"): commands = self._state_merged(want, have) - elif state == "replaced": + elif state in ["replaced", "overridden"]: commands = self._state_replaced(want, have) return commands diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/logging_global/logging_global.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/logging_global/logging_global.py index ff790e548..d3d5223be 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/logging_global/logging_global.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/logging_global/logging_global.py @@ -178,7 +178,6 @@ class Logging_global(ResourceModule): self.addcmd(hentry, x, negate=True) def list_to_dict(self, config): - data = deepcopy(config) if "tls_servers" in data: data["tls_servers"] = {x["name"]: x for x in data["tls_servers"]} diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py index 05ce42472..16e0bc3e9 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py @@ -10,7 +10,6 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from copy import deepcopy from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( @@ -107,22 +106,11 @@ class Ospfv3(ResourceModule): haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} wantd = {} - # delete processes first so we do run into "more than one" errors - if self.state == "deleted": - haved_del = deepcopy(haved) - want_process = {} - for k, t_want in iteritems(haved_del): - want_process["process_id"] = t_want.get("process_id") - if not (len(t_want) == 2 and not t_want.get("areas")): - self._compare(want=want_process, have=haved_del.get(k, {})) - if self.state == "overridden": - haved_del = deepcopy(haved) - want = {} - for k, t_want in iteritems(haved_del): + # if state is overridden, first remove processes that are in have but not in want + if self.state in ["overridden", "deleted"]: + for k, have in iteritems(haved): if k not in wantd: - want["process_id"] = t_want.get("process_id") - if not (len(t_want) == 2 and not t_want.get("areas")): - self._compare(want=want, have=haved_del.get(k, {})) + self.addcmd(have, "pid", True) for k, want in iteritems(wantd): self._compare(want=want, have=haved.pop(k, {})) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/ping/ping.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/ping/ping.py index ce2a5229c..587fbde98 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/ping/ping.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/ping/ping.py @@ -84,7 +84,7 @@ class Ping: Returns the percent of packet loss, received packets, transmitted packets, and RTT data. """ - if type(ping_results) == list: + if isinstance(ping_results, list): ping_results = ping_results[0] ping_data = PingTemplate(lines=ping_results.splitlines()) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/snmp_server/snmp_server.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/snmp_server/snmp_server.py index 9ee3e1a12..b69f2abd7 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/snmp_server/snmp_server.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/snmp_server/snmp_server.py @@ -281,7 +281,6 @@ class Snmp_server(ResourceModule): "users", "targets", ]: - wantx = want.get(x, {}) havex = have.get(x, {}) if "." in x: @@ -350,7 +349,6 @@ class Snmp_server(ResourceModule): return host_dict def list_to_dict(self, config): - data = deepcopy(config) if data.get("vrfs"): diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/static_routes/static_routes.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/static_routes/static_routes.py index b558f01af..ce8694389 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/static_routes/static_routes.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/config/static_routes/static_routes.py @@ -439,6 +439,57 @@ class Static_routes(ConfigBase): return commands + def _static_route_popper(self, want_afi, have_afi): + """ """ + commands = [] + + update_commands = [] + if not want_afi.get("routes", []): + commands.append( + "no address-family {0} {1}".format( + have_afi["afi"], + have_afi["safi"], + ), + ) + else: + for have_route in have_afi.get("routes", []): + want_route = ( + search_obj_in_list( + have_route["dest"], + want_afi.get("routes", []), + key="dest", + ) + or {} + ) + + rotated_want_next_hops = self.rotate_next_hops( + want_route.get("next_hops", {}), + ) + rotated_have_next_hops = self.rotate_next_hops( + have_route.get("next_hops", {}), + ) + + for key in rotated_want_next_hops.keys(): + if key in rotated_have_next_hops: + cmd = "no {0}".format(want_route["dest"]) + for item in key: + if "." in item or ":" in item or "/" in item: + cmd += " {0}".format(item) + else: + cmd += " vrf {0}".format(item) + update_commands.append(cmd) + if update_commands: + update_commands.insert( + 0, + "address-family {0} {1}".format( + have_afi["afi"], + have_afi["safi"], + ), + ) + commands.extend(update_commands) + + return commands + def _state_deleted(self, want, have): """The command generator when state is deleted @@ -460,12 +511,8 @@ class Static_routes(ConfigBase): or {} ) if have_afi: - commands.append( - "no address-family {0} {1}".format( - have_afi["afi"], - have_afi["safi"], - ), - ) + commands.extend(self._static_route_popper(want_afi, have_afi)) + if "vrf" in want and commands: commands.insert(0, "vrf {0}".format(want["vrf"])) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/bgp_templates/__init__.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/bgp_templates/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/bgp_templates/__init__.py diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/bgp_templates/bgp_templates.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/bgp_templates/bgp_templates.py new file mode 100644 index 000000000..98889ae59 --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/bgp_templates/bgp_templates.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The iosxr bgp_templates fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.bgp_templates.bgp_templates import ( + Bgp_templatesArgs, +) +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.rm_templates.bgp_templates import ( + Bgp_templatesTemplate, +) +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.utils.utils import ( + flatten_config, +) + + +class Bgp_templatesFacts(object): + """The iosxr bgp_templates facts class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Bgp_templatesArgs.argument_spec + + def get_config(self, connection): + return connection.get("show running-config router bgp") + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for Bgp_templates network resource + + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + + :rtype: dictionary + :returns: facts + """ + facts = {} + objs = [] + + if not data: + data = self.get_config(connection) + data = flatten_config(data, "neighbor-group") + # parse native config using the Bgp_templates template + bgp_templates_parser = Bgp_templatesTemplate(lines=data.splitlines(), module=self._module) + objs = bgp_templates_parser.parse() + if objs: + objs["neighbor"] = self._post_parse(objs).get( + "neighbor", + [], + ) + ansible_facts["ansible_network_resources"].pop("bgp_templates", None) + + params = utils.remove_empties( + bgp_templates_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), + ) + + facts["bgp_templates"] = params.get("config", {}) + ansible_facts["ansible_network_resources"].update(facts) + + return ansible_facts + + def _post_parse(self, data): + """Converts the intermediate data structure + to valid format as per argspec. + :param obj: dict + """ + if "neighbor" in data: + data["neighbor"] = sorted( + list(data["neighbor"].values()), + key=lambda k, s="name": k[s], + ) + for nbrg in data["neighbor"]: + if nbrg.get("address_family"): + nbrg["address_family"] = list(nbrg["address_family"].values()) + return data diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/facts.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/facts.py index 4d7e7b100..5cafa587d 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/facts.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/facts.py @@ -34,6 +34,9 @@ from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.facts.bg from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.facts.bgp_neighbor_address_family.bgp_neighbor_address_family import ( Bgp_neighbor_address_familyFacts, ) +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.facts.bgp_templates.bgp_templates import ( + Bgp_templatesFacts, +) from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.facts.hostname.hostname import ( HostnameFacts, ) @@ -122,6 +125,7 @@ FACT_RESOURCE_SUBSETS = dict( ntp_global=Ntp_globalFacts, snmp_server=Snmp_serverFacts, hostname=HostnameFacts, + bgp_templates=Bgp_templatesFacts, ) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/interfaces/interfaces.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/interfaces/interfaces.py index e89dbca2e..5efcd6084 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/interfaces/interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/interfaces/interfaces.py @@ -92,24 +92,24 @@ class InterfacesFacts(object): config = deepcopy(spec) match = re.search(r"^(\S+)", conf) - - intf = match.group(1) - if match.group(1).lower() == "preconfigure": - match = re.search(r"^(\S+) (.*)", conf) - if match: - intf = match.group(2) - - if get_interface_type(intf) == "unknown": - return {} - # populate the facts from the configuration - config["name"] = intf - config["description"] = utils.parse_conf_arg(conf, "description") - if utils.parse_conf_arg(conf, "speed"): - config["speed"] = int(utils.parse_conf_arg(conf, "speed")) - if utils.parse_conf_arg(conf, "mtu"): - config["mtu"] = int(utils.parse_conf_arg(conf, "mtu")) - config["duplex"] = utils.parse_conf_arg(conf, "duplex") - enabled = utils.parse_conf_cmd_arg(conf, "shutdown", False) - config["enabled"] = enabled if enabled is not None else True - - return utils.remove_empties(config) + if match: + intf = match.group(1) + if match.group(1).lower() == "preconfigure": + match = re.search(r"^(\S+) (.*)", conf) + if match: + intf = match.group(2) + + if get_interface_type(intf) == "unknown": + return {} + # populate the facts from the configuration + config["name"] = intf + config["description"] = utils.parse_conf_arg(conf, "description") + if utils.parse_conf_arg(conf, "speed"): + config["speed"] = int(utils.parse_conf_arg(conf, "speed")) + if utils.parse_conf_arg(conf, "mtu"): + config["mtu"] = int(utils.parse_conf_arg(conf, "mtu")) + config["duplex"] = utils.parse_conf_arg(conf, "duplex") + enabled = utils.parse_conf_cmd_arg(conf, "shutdown", False) + config["enabled"] = enabled if enabled is not None else True + + return utils.remove_empties(config) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/l2_interfaces/l2_interfaces.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/l2_interfaces/l2_interfaces.py index cdb1d72cf..f562e20f8 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/l2_interfaces/l2_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/l2_interfaces/l2_interfaces.py @@ -93,18 +93,17 @@ class L2_InterfacesFacts(object): """ config = deepcopy(spec) match = re.search(r"^(\S+)", conf) + if match: + intf = match.group(1) - intf = match.group(1) + if intf.lower() == "preconfigure": + match = re.search(r"^(\S+) (.*)", conf) + if match: + intf = match.group(2) - if match.group(1).lower() == "preconfigure": - match = re.search(r"^(\S+) (.*)", conf) - if match: - intf = match.group(2) + if get_interface_type(intf) == "unknown": + return {} - if get_interface_type(intf) == "unknown": - return {} - - if intf.lower().startswith("gi"): config["name"] = intf # populate the facts from the configuration @@ -128,11 +127,11 @@ class L2_InterfacesFacts(object): encapsulation.group(2).split("second-dot1q ")[1], ) else: - config["q_vlan"] = [] + config["qvlan"] = [] if dot1q: - config["q_vlan"].append(int(dot1q.split(" ")[0])) + config["qvlan"].append(dot1q.split(" ")[0]) if len(dot1q.split(" ")) > 1: - config["q_vlan"].append(int(dot1q.split(" ")[2])) + config["qvlan"].append(dot1q.split(" ")[2]) if utils.parse_conf_cmd_arg(conf, "l2transport", True): config["l2transport"] = True diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/l3_interfaces/l3_interfaces.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/l3_interfaces/l3_interfaces.py index bf5ce5f85..b4dba858e 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/l3_interfaces/l3_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/l3_interfaces/l3_interfaces.py @@ -27,6 +27,7 @@ from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec. ) from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.utils.utils import ( get_interface_type, + netmask_to_cidr, ) @@ -93,39 +94,45 @@ class L3_InterfacesFacts(object): """ config = deepcopy(spec) match = re.search(r"^(\S+)", conf) - - intf = match.group(1) - if match.group(1).lower() == "preconfigure": - match = re.search(r"^(\S+) (.*)", conf) - if match: - intf = match.group(2) - - if get_interface_type(intf) == "unknown": - return {} - - # populate the facts from the configuration - config["name"] = intf - - # Get the configured IPV4 details - ipv4 = [] - ipv4_all = re.findall(r"ipv4 address (\S+.*)", conf) - for each in ipv4_all: - each_ipv4 = dict() - if "secondary" in each: - each_ipv4["address"] = each.split(" secondary")[0] - each_ipv4["secondary"] = True - else: - each_ipv4["address"] = each - ipv4.append(each_ipv4) - config["ipv4"] = ipv4 - - # Get the configured IPV6 details - ipv6 = [] - ipv6_all = re.findall(r"ipv6 address (\S+)", conf) - for each in ipv6_all: - each_ipv6 = dict() - each_ipv6["address"] = each - ipv6.append(each_ipv6) - config["ipv6"] = ipv6 - - return utils.remove_empties(config) + if match: + intf = match.group(1) + if match.group(1).lower() == "preconfigure": + match = re.search(r"^(\S+) (.*)", conf) + if match: + intf = match.group(2) + + if get_interface_type(intf) == "unknown": + return {} + + # populate the facts from the configuration + config["name"] = intf + + # Get the configured IPV4 details + ipv4 = [] + ipv4_all = re.findall(r"ipv4 address (\S+.*)", conf) + for each in ipv4_all: + each_ipv4 = dict() + if "secondary" in each: + each_ipv4["address"] = self.format_ipv4(each.split(" secondary")[0]) + each_ipv4["secondary"] = True + elif "secondary" not in each and "dhcp" not in each: + each_ipv4["address"] = self.format_ipv4(each) + elif "dhcp" in each: + each_ipv4["address"] = "dhcp" + ipv4.append(each_ipv4) + config["ipv4"] = ipv4 + + # Get the configured IPV6 details + ipv6 = [] + ipv6_all = re.findall(r"ipv6 address (\S+)", conf) + for each in ipv6_all: + each_ipv6 = dict() + each_ipv6["address"] = each + ipv6.append(each_ipv6) + config["ipv6"] = ipv6 + return utils.remove_empties(config) + + def format_ipv4(self, address): + if address.split(" ")[1]: + cidr_val = netmask_to_cidr(address.split(" ")[1]) + return address.split(" ")[0] + "/" + cidr_val diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/legacy/base.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/legacy/base.py index 9e346d36c..cc657f42a 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/legacy/base.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/legacy/base.py @@ -30,7 +30,6 @@ from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.iosxr im class FactsBase(object): - COMMANDS = frozenset() def __init__(self, module): @@ -58,8 +57,7 @@ class Default(FactsBase): device_info = resp["device_info"] platform_facts["system"] = device_info["network_os"] - - for item in ("model", "image", "version", "platform", "hostname"): + for item in ("serialnum", "model", "image", "version", "platform", "hostname"): val = device_info.get("network_os_%s" % item) if val: platform_facts[item] = val @@ -71,13 +69,14 @@ class Default(FactsBase): class Hardware(FactsBase): - - COMMANDS = ["dir /all", "show memory summary"] + COMMANDS = ["dir /all", "show memory summary", "show processes cpu | include CPU utilization"] def populate(self): super(Hardware, self).populate() + data = self.responses[0] self.facts["filesystems"] = self.parse_filesystems(data) + self.facts["cpu_utilization"] = self.parse_cpu_utilization(self.responses[2]) data = self.responses[1] match = re.search(r"Physical Memory: (\d+)M total \((\d+)", data) @@ -88,9 +87,29 @@ class Hardware(FactsBase): def parse_filesystems(self, data): return re.findall(r"^Directory of (\S+)", data, re.M) + def parse_cpu_utilization(self, data): + facts = {} + cpu_utilization_regex = re.compile( + r""" + ^CPU\sutilization\sfor\sone\sminute:(\s(?P<one_min>[0-9]+)?%)?; + \sfive\sminutes:\s(?P<five_mins>[0-9]+)?%; + \sfifteen\sminutes:\s(?P<fifteen_mins>[0-9]+)?% + """, + re.VERBOSE, + ) -class Config(FactsBase): + for line in data.split("\n"): + cpu_utilization_match = cpu_utilization_regex.match(line) + if cpu_utilization_match: + facts["one_minute"] = int(cpu_utilization_match.group("one_min")) + facts["five_minutes"] = int(cpu_utilization_match.group("five_mins")) + facts["fifteen_minutes"] = int(cpu_utilization_match.group("fifteen_mins")) + + return facts + + +class Config(FactsBase): COMMANDS = ["show running-config"] def populate(self): @@ -99,7 +118,6 @@ class Config(FactsBase): class Interfaces(FactsBase): - COMMANDS = [ "show interfaces", "show ipv6 interface", diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/ospfv2/ospfv2.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/ospfv2/ospfv2.py index 240ecb4d5..b5c2693f1 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/ospfv2/ospfv2.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/ospfv2/ospfv2.py @@ -19,7 +19,7 @@ import re from copy import deepcopy from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/ospfv3/ospfv3.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/ospfv3/ospfv3.py index 49302ce9b..d34f15fbd 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/ospfv3/ospfv3.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/facts/ospfv3/ospfv3.py @@ -13,7 +13,7 @@ import re from copy import deepcopy from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network_template import ( +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( NetworkTemplate, ) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py index ea15fdfcd..c7498aa19 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py @@ -36,7 +36,6 @@ import re from difflib import Differ from ansible.module_utils._text import to_bytes, to_text -from ansible.module_utils.basic import env_fallback from ansible.module_utils.connection import Connection, ConnectionError from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.netconf import ( NetconfConnection, @@ -146,7 +145,6 @@ def build_xml_subtree(container_ele, xmap, param=None, opcode=None): if ( opcode in ("delete", "merge") and meta.get("operation", "unknown") == "edit" ) or meta.get("operation", None) is None: - if meta.get("tag", False) is True: if parent.tag == container_ele.tag: if meta.get("ns", False) is True: @@ -430,7 +428,6 @@ def load_config( nc_get_filter=None, label=None, ): - conn = get_connection(module) diff = None diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/address_family.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/address_family.py deleted file mode 100644 index 0d5393407..000000000 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/address_family.py +++ /dev/null @@ -1,133 +0,0 @@ -# -# (c) 2019, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type -import re - -from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list - -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.providers import ( - CliProvider, -) - - -class AddressFamily(CliProvider): - def render(self, config=None): - commands = list() - safe_list = list() - - router_context = "router bgp %s" % self.get_value("config.bgp_as") - context_config = None - - for item in self.get_value("config.address_family"): - context = "address-family %s %s" % (item["afi"], item["safi"]) - context_commands = list() - - if config: - context_path = [router_context, context] - context_config = self.get_config_context( - config, - context_path, - indent=1, - ) - - for key, value in iteritems(item): - if value is not None: - meth = getattr(self, "_render_%s" % key, None) - if meth: - resp = meth(item, context_config) - if resp: - context_commands.extend(to_list(resp)) - - if context_commands: - commands.append(context) - commands.extend(context_commands) - commands.append("exit") - - safe_list.append(context) - - if config: - resp = self._negate_config(config, safe_list) - commands.extend(resp) - - return commands - - def _negate_config(self, config, safe_list=None): - commands = list() - matches = re.findall(r"(address-family .+)$", config, re.M) - for item in set(matches).difference(safe_list): - commands.append("no %s" % item) - return commands - - def _render_networks(self, item, config=None): - commands = list() - safe_list = list() - - for entry in item["networks"]: - network = entry["prefix"] - if entry["masklen"]: - network = "%s/%s" % (entry["prefix"], entry["masklen"]) - safe_list.append(network) - - cmd = "network %s" % network - - if entry["route_map"]: - cmd += " route-policy %s" % entry["route_map"] - - if not config or cmd not in config: - commands.append(cmd) - - if config and self.params["operation"] == "replace": - matches = re.findall(r"network (\S+)", config, re.M) - for entry in set(matches).difference(safe_list): - commands.append("no network %s" % entry) - - return commands - - def _render_redistribute(self, item, config=None): - commands = list() - safe_list = list() - - for entry in item["redistribute"]: - option = entry["protocol"] - - cmd = "redistribute %s" % entry["protocol"] - - if entry["id"] and entry["protocol"] in ( - "ospf", - "eigrp", - "isis", - "ospfv3", - ): - cmd += " %s" % entry["id"] - option += " %s" % entry["id"] - - if entry["metric"]: - cmd += " metric %s" % entry["metric"] - - if entry["route_map"]: - cmd += " route-policy %s" % entry["route_map"] - - if not config or cmd not in config: - commands.append(cmd) - - safe_list.append(option) - - if self.params["operation"] == "replace": - if config: - matches = re.findall( - r"redistribute (\S+)(?:\s*)(\d*)", - config, - re.M, - ) - for i in range(0, len(matches)): - matches[i] = " ".join(matches[i]).strip() - for entry in set(matches).difference(safe_list): - commands.append("no redistribute %s" % entry) - - return commands diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/neighbors.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/neighbors.py deleted file mode 100644 index 29e4a1d2e..000000000 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/neighbors.py +++ /dev/null @@ -1,136 +0,0 @@ -# -# (c) 2019, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type -import re -import socket - -from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list - -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.providers import ( - CliProvider, -) - - -class Neighbors(CliProvider): - def render(self, config=None): - commands = list() - safe_list = list() - - router_context = "router bgp %s" % self.get_value("config.bgp_as") - context_config = None - - for item in self.get_value("config.neighbors"): - context_commands = list() - - neighbor = item["neighbor"] - - try: - socket.inet_aton(neighbor) - context = "neighbor %s" % neighbor - except socket.error: - context = "neighbor-group %s" % neighbor - - if config: - context_path = [router_context, context] - context_config = self.get_config_context( - config, - context_path, - indent=1, - ) - - for key, value in iteritems(item): - if value is not None: - meth = getattr(self, "_render_%s" % key, None) - if meth: - resp = meth(item, context_config) - if resp: - context_commands.extend(to_list(resp)) - - if context_commands: - commands.append(context) - commands.extend(context_commands) - commands.append("exit") - - safe_list.append(context) - - if config and safe_list: - commands.extend(self._negate_config(config, safe_list)) - - return commands - - def _negate_config(self, config, safe_list=None): - commands = list() - matches = re.findall(r"(neighbor \S+)", config, re.M) - for item in set(matches).difference(safe_list): - commands.append("no %s" % item) - return commands - - def _render_remote_as(self, item, config=None): - cmd = "remote-as %s" % item["remote_as"] - if not config or cmd not in config: - return cmd - - def _render_description(self, item, config=None): - cmd = "description %s" % item["description"] - if not config or cmd not in config: - return cmd - - def _render_enabled(self, item, config=None): - cmd = "shutdown" - if item["enabled"] is True: - cmd = "no %s" % cmd - if not config or cmd not in config: - return cmd - - def _render_update_source(self, item, config=None): - cmd = "update-source %s" % item["update_source"].replace(" ", "") - if not config or cmd not in config: - return cmd - - def _render_password(self, item, config=None): - cmd = "password %s" % item["password"] - if not config or cmd not in config: - return cmd - - def _render_ebgp_multihop(self, item, config=None): - cmd = "ebgp-multihop %s" % item["ebgp_multihop"] - if not config or cmd not in config: - return cmd - - def _render_tcp_mss(self, item, config=None): - cmd = "tcp mss %s" % item["tcp_mss"] - if not config or cmd not in config: - return cmd - - def _render_advertisement_interval(self, item, config=None): - cmd = "advertisement-interval %s" % item["advertisement_interval"] - if not config or cmd not in config: - return cmd - - def _render_neighbor_group(self, item, config=None): - cmd = "use neighbor-group %s" % item["neighbor_group"] - if not config or cmd not in config: - return cmd - - def _render_timers(self, item, config): - """generate bgp timer related configuration""" - keepalive = item["timers"]["keepalive"] - holdtime = item["timers"]["holdtime"] - min_neighbor_holdtime = item["timers"]["min_neighbor_holdtime"] - - if keepalive and holdtime: - cmd = "timers %s %s" % (keepalive, holdtime) - if min_neighbor_holdtime: - cmd += " %s" % min_neighbor_holdtime - if not config or cmd not in config: - return cmd - else: - raise ValueError( - "required both options for timers: keepalive and holdtime", - ) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/process.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/process.py deleted file mode 100644 index bd2c08ae1..000000000 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/cli/config/bgp/process.py +++ /dev/null @@ -1,121 +0,0 @@ -# -# (c) 2019, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type -import re - -from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list - -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.cli.config.bgp.address_family import ( - AddressFamily, -) -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.cli.config.bgp.neighbors import ( - Neighbors, -) -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.providers import ( - CliProvider, - register_provider, -) - - -REDISTRIBUTE_PROTOCOLS = [ - "ospf", - "ospfv3", - "eigrp", - "isis", - "static", - "connected", - "lisp", - "mobile", - "rip", - "subscriber", -] - - -@register_provider("iosxr", "iosxr_bgp") -class Provider(CliProvider): - def render(self, config=None): - commands = list() - - existing_as = None - if config: - match = re.search(r"router bgp (\d+)", config, re.M) - if match: - existing_as = match.group(1) - - operation = self.params["operation"] - - context = None - - if self.params["config"]: - context = "router bgp %s" % self.get_value("config.bgp_as") - - if operation == "delete": - if existing_as: - commands.append("no router bgp %s" % existing_as) - elif context: - commands.append("no %s" % context) - - else: - if operation == "replace": - if existing_as and int(existing_as) != self.get_value( - "config.bgp_as", - ): - # The negate command has to be committed before new BGP AS is used. - self.connection.edit_config( - "no router bgp %s" % existing_as, - ) - config = None - - elif operation == "override": - if existing_as: - # The negate command has to be committed before new BGP AS is used. - self.connection.edit_config( - "no router bgp %s" % existing_as, - ) - config = None - - context_commands = list() - - for key, value in iteritems(self.get_value("config")): - if value is not None: - meth = getattr(self, "_render_%s" % key, None) - if meth: - resp = meth(config) - if resp: - context_commands.extend(to_list(resp)) - - if context and context_commands: - commands.append(context) - commands.extend(context_commands) - commands.append("exit") - - return commands - - def _render_router_id(self, config=None): - cmd = "bgp router-id %s" % self.get_value("config.router_id") - if not config or cmd not in config: - return cmd - - def _render_log_neighbor_changes(self, config=None): - cmd = "bgp log neighbor changes" - log_neighbor_changes = self.get_value("config.log_neighbor_changes") - if log_neighbor_changes is True: - if not config or cmd not in config: - return "%s detail" % cmd - elif log_neighbor_changes is False: - if config and cmd in config: - return "%s disable" % cmd - - def _render_neighbors(self, config): - """generate bgp neighbor configuration""" - return Neighbors(self.params).render(config) - - def _render_address_family(self, config): - """generate address-family configuration""" - return AddressFamily(self.params).render(config) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/module.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/module.py deleted file mode 100644 index afb9b9e7e..000000000 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/module.py +++ /dev/null @@ -1,71 +0,0 @@ -# -# (c) 2019, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type -from ansible.module_utils._text import to_text -from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.connection import Connection - -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers import providers - - -class NetworkModule(AnsibleModule): - - fail_on_missing_provider = True - - def __init__(self, connection=None, *args, **kwargs): - super(NetworkModule, self).__init__(*args, **kwargs) - - if connection is None: - connection = Connection(self._socket_path) - - self.connection = connection - - @property - def provider(self): - if not hasattr(self, "_provider"): - capabilities = self.from_json(self.connection.get_capabilities()) - - network_os = capabilities["device_info"]["network_os"] - network_api = capabilities["network_api"] - - if network_api == "cliconf": - connection_type = "network_cli" - - cls = providers.get( - network_os, - self._name.split(".")[-1], - connection_type, - ) - - if not cls: - msg = "unable to find suitable provider for network os %s" % network_os - if self.fail_on_missing_provider: - self.fail_json(msg=msg) - else: - self.warn(msg) - - obj = cls(self.params, self.connection, self.check_mode) - - setattr(self, "_provider", obj) - - return getattr(self, "_provider") - - def get_facts(self, subset=None): - try: - self.provider.get_facts(subset) - except Exception as exc: - self.fail_json(msg=to_text(exc)) - - def edit_config(self, config_filter=None): - current_config = self.connection.get_config(flags=config_filter) - try: - commands = self.provider.edit_config(current_config) - changed = bool(commands) - return {"commands": commands, "changed": changed} - except Exception as exc: - self.fail_json(msg=to_text(exc)) diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/providers.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/providers.py deleted file mode 100644 index 94220ffaf..000000000 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/providers/providers.py +++ /dev/null @@ -1,127 +0,0 @@ -# -# (c) 2019, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type -import json - -from threading import RLock - -from ansible.module_utils.six import itervalues -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import ( - NetworkConfig, -) -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list - - -_registered_providers = {} -_provider_lock = RLock() - - -def register_provider(network_os, module_name): - def wrapper(cls): - _provider_lock.acquire() - try: - if network_os not in _registered_providers: - _registered_providers[network_os] = {} - for ct in cls.supported_connections: - if ct not in _registered_providers[network_os]: - _registered_providers[network_os][ct] = {} - for item in to_list(module_name): - for entry in itervalues(_registered_providers[network_os]): - entry[item] = cls - finally: - _provider_lock.release() - return cls - - return wrapper - - -def get(network_os, module_name, connection_type): - network_os_providers = _registered_providers.get(network_os) - if network_os_providers is None: - raise ValueError("unable to find a suitable provider for this module") - if connection_type not in network_os_providers: - raise ValueError("provider does not support this connection type") - elif module_name not in network_os_providers[connection_type]: - raise ValueError("could not find a suitable provider for this module") - return network_os_providers[connection_type][module_name] - - -class ProviderBase(object): - - supported_connections = () - - def __init__(self, params, connection=None, check_mode=False): - self.params = params - self.connection = connection - self.check_mode = check_mode - - @property - def capabilities(self): - if not hasattr(self, "_capabilities"): - resp = self.from_json(self.connection.get_capabilities()) - setattr(self, "_capabilities", resp) - return getattr(self, "_capabilities") - - def get_value(self, path): - params = self.params.copy() - for key in path.split("."): - params = params[key] - return params - - def get_facts(self, subset=None): - raise NotImplementedError(self.__class__.__name__) - - def edit_config(self): - raise NotImplementedError(self.__class__.__name__) - - -class CliProvider(ProviderBase): - - supported_connections = ("network_cli",) - - @property - def capabilities(self): - if not hasattr(self, "_capabilities"): - resp = self.from_json(self.connection.get_capabilities()) - setattr(self, "_capabilities", resp) - return getattr(self, "_capabilities") - - def get_config_context(self, config, path, indent=1): - if config is not None: - netcfg = NetworkConfig(indent=indent, contents=config) - try: - config = netcfg.get_block_config(to_list(path)) - except ValueError: - config = None - return config - - def render(self, config=None): - raise NotImplementedError(self.__class__.__name__) - - def cli(self, command): - try: - if not hasattr(self, "_command_output"): - setattr(self, "_command_output", {}) - return self._command_output[command] - except KeyError: - out = self.connection.get(command) - try: - out = json.loads(out) - except ValueError: - pass - self._command_output[command] = out - return out - - def get_facts(self, subset=None): - return self.populate() - - def edit_config(self, config=None): - commands = self.render(config) - if commands and self.check_mode is False: - self.connection.edit_config(commands) - return commands diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_address_family.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_address_family.py index a1d9bfda8..f5ced0b0b 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_address_family.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_address_family.py @@ -74,7 +74,6 @@ def _tmpl_bgp_dampening(config_data): def _tmpl_maximum_paths_ibgp(config_data): - ibgp_conf = config_data.get("maximum_paths", {}).get("ibgp", {}) if ibgp_conf: command = "maximum-paths ibgp" @@ -97,7 +96,6 @@ def _tmpl_maximum_paths_ibgp(config_data): def _tmpl_maximum_paths_ebgp(config_data): - ebgp_conf = config_data.get("maximum_paths", {}).get("ebgp", {}) if ebgp_conf: command = "maximum-paths ebgp" @@ -111,7 +109,6 @@ def _tmpl_maximum_paths_ebgp(config_data): def _tmpl_maximum_paths_eibgp(config_data): - eibgp_conf = config_data.get("maximum_paths", {}).get("eibgp", {}) if eibgp_conf: command = "maximum-paths ebgp" @@ -137,7 +134,6 @@ def _tmpl_nexthop(config_data): nexthop_conf = config_data.get("nexthop", {}) commands = [] if nexthop_conf: - if "resolution_prefix_length_minimum" in nexthop_conf: command = "nexthop resolution prefix-length minimum " + str( nexthop_conf["resolution_prefix_length_minimum"], diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_global.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_global.py index f584d13f5..c1a5962c7 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_global.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_global.py @@ -32,6 +32,21 @@ def _tmplt_confederation_peers(config_data): return cmds +def _templ_local_as(config_data): + conf = config_data.get("local_as", {}) + if conf.get("value"): + command = "local-as " + str(conf.get("value", {})) + if "no_prepend" in conf: + if "replace_as" in conf.get("no_prepend", {}): + if "dual_as" in conf.get("no_prepend", {}).get("replace_as", {}): + command += " no-prepend replace-as dual-as" + elif "set" in conf.get("no_prepend", {}).get("replace_as", {}): + command += " no-prepend replace-as" + elif "set" in conf.get("no_prepend", {}): + command += " no-prepend" + return command + + class Bgp_globalTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): super(Bgp_globalTemplate, self).__init__( @@ -2052,10 +2067,12 @@ class Bgp_globalTemplate(NetworkTemplate): r""" \s+(?P<nbr_address>neighbor\s\S+) \s(?P<local_as>local-as\s\S+) + (\s(?P<no_prepend>no-prepend))? + (\s(?P<replace_as>replace-as))? + (\s(?P<dual_as>dual-as))? $""", re.VERBOSE, ), - "setval": "local-as {{ local_as.value }}", - "compval": "local_as.value", + "setval": _templ_local_as, "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { @@ -2063,6 +2080,14 @@ class Bgp_globalTemplate(NetworkTemplate): "{{nbr_address.split(" ")[1]}}": { "local_as": { "value": "{{ local_as.split(" ")[1] }}", + "no_prepend": + { + "set": "{{ True if no_prepend is defined and replace_as is undefined and dual_as is undefined else None}}", + "replace_as": { + "set": "{{ True if replace_as is defined and dual_as is undefined}}", + "dual_as": "{{ not not dual_as}}", + }, + }, }, }, }, @@ -2152,6 +2177,55 @@ class Bgp_globalTemplate(NetworkTemplate): }, }, { + "name": "password_inheritance_disable", + "getval": re.compile( + r""" + \s+(?P<nbr_address>neighbor\s\S+) + \s(?P<password>password\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "password inheritance-disable", + "compval": "password.inheritance_disable", + "result": { + "vrfs": { + '{{ "vrf_" + vrf|d() }}': { + "neighbors": { + "{{nbr_address.split(" ")[1]}}": { + "password": { + "inheritance_disable": "{{ True if password is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "password_encrypted", + "getval": re.compile( + r""" + \s+(?P<nbr_address>neighbor\s\S+) + \spassword\sencrypted + \s(?P<password>\S+) + $""", re.VERBOSE, + ), + "setval": "password encrypted {{password.encrypted}}", + "compval": "password.encrypted", + "result": { + "vrfs": { + '{{ "vrf_" + vrf|d() }}': { + "neighbors": { + "{{nbr_address.split(" ")[1]}}": { + "password": { + "encrypted": "{{ password }}", + }, + }, + }, + }, + }, + }, + }, + { "name": "receive_buffer_size", "getval": re.compile( r""" @@ -2360,6 +2434,52 @@ class Bgp_globalTemplate(NetworkTemplate): }, }, { + "name": "use.neighbor_group", + "getval": re.compile( + r""" + \s+(?P<nbr_address>neighbor\s\S+) + \suse\sneighbor-group\s(?P<neighbor_group>\S+) + $""", re.VERBOSE, + ), + "setval": "use neighbor-group {{ use.neighbor_group }}", + "result": { + "vrfs": { + '{{ "vrf_" + vrf|d() }}': { + "neighbors": { + "{{nbr_address.split(" ")[1]}}": { + "use": { + "neighbor_group": "{{ neighbor_group }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "use.session_group", + "getval": re.compile( + r""" + \s+(?P<nbr_address>neighbor\s\S+) + \suse\ssession-group\s(?P<session_group>\S+) + $""", re.VERBOSE, + ), + "setval": "use session-group {{ use.session_group }}", + "result": { + "vrfs": { + '{{ "vrf_" + vrf|d() }}': { + "neighbors": { + "{{nbr_address.split(" ")[1]}}": { + "use": { + "session_group": "{{ session_group }}", + }, + }, + }, + }, + }, + }, + }, + { "name": "update_source", "getval": re.compile( r""" diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_templates.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_templates.py new file mode 100644 index 000000000..f0274944c --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/bgp_templates.py @@ -0,0 +1,2816 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +""" +The Bgp_templates parser templates file. This contains +a list of parser definitions and associated functions that +facilitates both facts gathering and native command generation for +the given network resource. +""" + +import re + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( + NetworkTemplate, +) + + +UNIQUE_NEIB_ADD = "{{ nbr_address }}" + + +def _tmpl_maximum_prefix(config_data): + conf = config_data.get("maximum_prefix", {}) + if conf: + command = "maximum-prefix" + if "max_limit" in conf: + command += " " + str(conf["max_limit"]) + if "threshold_value" in conf: + command += " " + str(conf["threshold_value"]) + if "restart" in conf: + command += " restart " + str(conf["restart"]) + elif "warning_only" in conf: + command += " warning-only" + elif "discard_extra_paths" in conf: + command += " discard-extra-paths" + + return command + + +def _tmpl_soft_reconfiguration(config_data): + conf = config_data.get("soft_reconfiguration", {}) + if conf: + command = "soft-reconfiguration " + if "inbound" in conf: + command += "inbound" + if "set" in conf["inbound"]: + pass + elif "always" in conf["inbound"]: + command += " always" + if "inheritance_disable" in conf["inbound"]: + command += " inheritance-disable" + + return command + + +def _tmpl_remove_private_AS(config_data): + conf = config_data.get("remove_private_AS", {}) + if conf: + command = "remove-private-AS" + if "inbound" in conf: + command += " inbound" + if "entire_aspath" in conf: + command += " entire-aspath" + if "inheritance_disable" in conf: + command += " inheritance-disable" + return command + + +def _templ_local_as(config_data): + conf = config_data.get("local_as", {}) + if conf.get("value"): + command = "local-as " + str(conf.get("value", {})) + if "no_prepend" in conf: + command = "local-as" + if "replace_as" in conf.get("no_prepend", {}): + if "dual_as" in conf.get("no_prepend", {}).get("replace_as", {}): + command += " no-prepend replace-as dual-as" + elif "set" in conf.get("no_prepend", {}).get("replace_as", {}): + command += " no-prepend replace-as" + elif "set" in conf.get("no_prepend", {}): + command += " no-prepend" + return command + + +class Bgp_templatesTemplate(NetworkTemplate): + def __init__(self, lines=None, module=None): + super(Bgp_templatesTemplate, self).__init__( + lines=lines, + tmplt=self, + module=module, + ) + + # fmt: off + PARSERS = [ + { + "name": "router", + "getval": re.compile( + r""" + ^router\s + bgp + \s(?P<as_num>\S+) + $""", + re.VERBOSE, + ), + "setval": "router bgp {{ as_number }}", + "compval": "as_number", + "result": {"as_number": "{{ as_num }}"}, + "shared": True, + }, + { + "name": "address_family", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + (?P<address_family>\s+address-family\s(?P<afi>\S+)\s(?P<safi>\S+)) + $""", re.VERBOSE, + ), + "setval": "address-family {{ afi}} {{safi}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "afi": "{{ afi}}", + "safi": "{{safi}}", + }, + }, + }, + }, + }, + "shared": True, + }, + { + "name": "neighbor_group", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + $""", re.VERBOSE, + ), + "setval": "neighbor-group {{ name}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "name": UNIQUE_NEIB_ADD, + }, + }, + }, + "shared": True, + }, + { + "name": "signalling", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sSignalling(?P<signalling>) + (\sbgp\sdisable(?P<b_disable>))? + (\sldp\sdisable(?P<l_disable>))? + $""", re.VERBOSE, + ), + "setval": "{{ 'signalling bgp disable' if signalling.bgp_disable else 'signalling ldp disable' }} ", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "signalling": { + "bgp_disable": "{{ True if b_disable is defined }}", + "ldp_disable": "{{ True if l_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "advertise.local_labeled_route.set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + (?P<a_Set>\sadvertise\slocal-labeled-route(?P<a_set>)) + $""", re.VERBOSE, + ), + "setval": "advertise local-labeled-route", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "advertise": { + "local_labeled_route": { + "set": "{{ True if a_set is defined}}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "advertise.local_labeled_route.disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sadvertise + (\slocal-labeled-route\sdisable(?P<l_disable>))? + $""", re.VERBOSE, + ), + "setval": "advertise local-labeled-route disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "advertise": { + "local_labeled_route": { + "disable": "{{ True if l_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "advertise.permanent_network", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sadvertise + (\spermanent-network(?P<set>))? + $""", re.VERBOSE, + ), + "setval": "advertise permanent-network", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "advertise": { + "permanent_network": "{{ True if set is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "aigp.set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + (?P<aigp>\saigp) + $""", re.VERBOSE, + ), + "setval": "aigp", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "aigp": { + "set": "{{ True if aigp is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "aigp.disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \saigp(?P<aigp>) + (\sdisable(?P<disable>)) + $""", re.VERBOSE, + ), + "setval": "aigp disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "aigp": { + "disable": "{{ True if disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "aigp.send_med", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \saigp(?P<aigp>) + (\ssend\smed(?P<send_med>))? + (\ssend\smed\sdisable(?P<send_disable>))? + $""", re.VERBOSE, + ), + "setval": "'aigp send med disable' if {{aigp.send_med.disable}} is defined else 'aigp send med'", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "aigp": { + "send_med": { + "set": "{{ True if send_med is defined }}", + "disable": "{{ True if send_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "aigp.send_cost_community_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \saigp(?P<aigp>) + (\ssend\scost-community\sdisable(?P<cc_disable>))? + $""", re.VERBOSE, + ), + "setval": "aigp send cost-community disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "aigp": { + "send_cost_community_disable": "{{True if cc_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "allowas_in", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sallowas-in(?P<allowas_in>)(\s(?P<value>\S+))? + $""", re.VERBOSE, + ), + "setval": "allowas-in {{allowas_in.value if allowas_in.value is defined }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "allowas_in": { + "set": "{{True if allowas_in is defined and value is not defined}}", + "value": "{{value }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "as_override", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sas-override(?P<as_override>) + (\sinheritance-disable(?P<inheritance_disable>))? + $""", re.VERBOSE, + ), + "setval": "as-override{{' inheritance-disable' if as_override.inheritance_disable is defined else ''}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "as_override": { + "set": "{{True if as_override is defined " + "and inheritance_disable is not defined}}", + "inheritance_disable": "{{True if inheritance_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "bestpath_origin_as_allow_invalid", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sbestpath\sorigin-as\sallow\sinvalid(?P<invalid>) + $""", re.VERBOSE, + ), + "setval": "bestpath origin-as allow invalid", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "bestpath_origin_as_allow_invalid": "{{ True if invalid is defined}}", + }, + }, + }, + }, + }, + }, + { + "name": "capability_orf_prefix", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \scapability\sorf\sprefix\s(?P<capability_orf_prefix>\S+) + $""", re.VERBOSE, + ), + "setval": "capability orf prefix {{capability_orf_prefix }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "capability_orf_prefix": "{{capability_orf_prefix}}", + }, + }, + }, + }, + }, + }, + { + "name": "default_originate.set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s+default-originate(?P<default_originate>) + $""", re.VERBOSE, + ), + "setval": "default-originate", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi}}': { + "default_originate": { + "set": "{{True if default_originate is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "default_originate.route_policy", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s+default-originate(?P<default_originate>) + (\sroute-policy\s(?P<route_policy>\S+))? + $""", re.VERBOSE, + ), + "setval": "default-originate route-policy {{default_originate.route_policy}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi}}': { + "default_originate": { + "route_policy": "{{route_policy}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "default_originate.inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s+default-originate\s(?P<disable>inheritance-disable) + $""", re.VERBOSE, + ), + "setval": "default-originate inheritance-disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi}}': { + "default_originate": { + "inheritance_disable": "{{true if disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "encapsulation_type_srv6", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sencapsulation-type\ssrv6(?P<encapsulation_type_srv6>) + $""", re.VERBOSE, + ), + "setval": "encapsulation-type srv6", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "encapsulation_type_srv6": "{{true if encapsulation_type_srv6 is defined}}", + }, + }, + }, + }, + }, + }, + { + "name": "long_lived_graceful_restart_capable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s+long-lived-graceful-restart + \s(?P<capable>capable) + $""", re.VERBOSE, + ), + "setval": "long-lived-graceful-restart capable", + "compval": "long_lived_graceful_restart.capable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "long_lived_graceful_restart": { + "capable": "{{True if capable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "long_lived_graceful_restart_stale_time", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s+long-lived-graceful-restart + \s+stale-time\ssend\s(?P<stale_time_send>\d+)\saccept\s(?P<accept>\d+) + $""", re.VERBOSE, + ), + "setval": "long-lived-graceful-restart stale-time send " + "{{stale_time.send}} accept {{stale_time.accept}}", + "compval": "long_lived_graceful_restart.stale_time", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "long_lived_graceful_restart": { + "stale_time": { + "send": "{{stale_time_send}}", + "accept": "{{accept}}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "maximum_prefix", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s+maximum-prefix + (\s(?P<maximum_prefix>\d+))? + (\s(?P<threshold_value>\d+))? + (\srestart\s(?P<restart>\d+))? + (\swarning-only\s(?P<warning_only>))? + (\sdiscard-extra-paths\s(?P<discard_extra_paths>))? + $""", re.VERBOSE, + ), + "setval": _tmpl_maximum_prefix, + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "maximum_prefix": { + "max_limit": "{{maximum_prefix}}", + "threshold_value": "{{threshold_value}}", + "restart": "{{restart}}", + "warning_only": "{{ True if warning_only is defined}}", + "discard_extra_paths": "{{ True if discard_extra_paths is defined}}", + }, + }, + }, + }, + }, + }, + }, + + { + "name": "multipath", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \smultipath(?P<multipath>) + $""", re.VERBOSE, + ), + "setval": "multipath", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "multipath": "{{True if multipath is defined}}", + }, + }, + }, + }, + }, + }, + { + "name": "next_hop_self", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \snext-hop-self(?P<next_hop_self>) + (\sinheritance-disable(?P<inheritance_disable>))? + $""", re.VERBOSE, + ), + "setval": "next-hop-self{{' inheritance-disable' if next_hop_self.inheritance_disable is defined else ''}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "next_hop_self": { + "set": "{{True if next_hop_self is defined and" + " inheritance_disable is not defined}}", + "inheritance_disable": "{{True if inheritance_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "next_hop_unchanged.set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \snext-hop-unchanged(?P<next_hop_unchanged>) + $""", re.VERBOSE, + ), + "setval": "next-hop-unchanged", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi}}': { + "next_hop_unchanged": { + "set": "{{True if next_hop_self is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "next_hop_unchanged.inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \snext-hop-unchanged(?P<next_hop_unchanged>) + ((?P<inheritance_disable>)\sinheritance-disable)? + $""", re.VERBOSE, + ), + "setval": "next-hop-unchanged inheritance-disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi}}': { + "next_hop_unchanged": { + "inheritance_disable": "{{True if inheritance_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "next_hop_unchanged.multipath", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \snext-hop-unchanged(?P<next_hop_unchanged>) + (?P<multipath>\smultipath)? + $""", re.VERBOSE, + ), + "setval": "next-hop-unchanged multipath", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi}}': { + "next_hop_unchanged": { + "multipath": "{{True if multipath is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "optimal_route_reflection_group_name", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \soptimal-route-reflection\s(?P<group_name>\S+) + $""", re.VERBOSE, + ), + "setval": "optimal-route-reflection {{optimal_route_reflection_group_name}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "optimal_route_reflection_group_name": "{{ group_name}}", + }, + }, + }, + }, + }, + }, + { + "name": "orf_route_policy", + "getval": re.compile( + r""" + \s+(?P<nbr_address>neighbor\s\S+) + \sorf\sroute-policy\s(?P<orf_rr>\S+) + $""", re.VERBOSE, + ), + "setval": "orf route-policy {{orf_route_policy}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "orf_route_policy": "{{orf_rr}}", + }, + }, + }, + }, + }, + }, + { + "name": "origin_as", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sorigin-as\svalidation\sdisable(?P<origin_as>) + $""", re.VERBOSE, + ), + "setval": "origin-as validation disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "origin_as": { + "validation": { + "disable": "{{True if origin_as is defined }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "remove_private_AS.set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sremove-private-AS(?P<remove_private_AS>) + $""", re.VERBOSE, + ), + "setval": "remove-private-AS", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "remove_private_AS": { + "set": "{{True if remove_private_AS is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "remove_private_AS", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sremove-private-AS(?P<remove_private_AS>) + (\sinbound(?P<inbound>))? + (\sentire-aspath(?P<entire_aspath>))? + (\sinheritance-disable(?P<inheritance_disable>))? + $""", re.VERBOSE, + ), + "setval": _tmpl_remove_private_AS, + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "remove_private_AS": { + "inheritance_disable": "{{True if inheritance_disable is defined}}", + "inbound": "{{True if inbound is defined}}", + "entire_aspath": "{{True if entire_aspath is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "route_policy.inbound", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sroute-policy\s(?P<route_policy>\S+) + \sin + $""", re.VERBOSE, + ), + "setval": "route-policy {{route_policy.inbound}} in", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "route_policy": { + "inbound": "{{route_policy}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "route_policy.outbound", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sroute-policy\s(?P<route_policy>\S+) + \sout + $""", re.VERBOSE, + ), + "setval": "route-policy {{route_policy.outbound}} out", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "route_policy": { + "outbound": "{{route_policy}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "route_reflector_client", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sroute-reflector-client(?P<route_reflector_client>) + (\sinheritance-disable(?P<inheritance_disable>))? + $""", re.VERBOSE, + ), + "setval": "route-reflector-client{{' inheritance-disable' " + "if route_reflector_client.inheritance_disable is defined }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "route_reflector_client": { + "set": "{{True if route_reflector_client is defined and " + "inheritance_disable is not defined }}", + "inheritance_disable": "{{True if inheritance_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "send_community_ebgp", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \ssend-community-ebgp(?P<send_community_ebgp>) + (\sinheritance-disable(?P<inheritance_disable>))? + $""", re.VERBOSE, + ), + "setval": "send-community-ebgp{{' inheritance-disable' " + "if send_community_ebgp.inheritance_disable is defined else ''}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "send_community_ebgp": { + "set": "{{True if send_community_ebgp is defined and " + "inheritance_disable is not defined}}", + "inheritance_disable": "{{True if inheritance_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "send_community_gshut_ebgp", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \ssend-community-gshut-ebgp(?P<send_community_gshut_ebg>) + (\sinheritance-disable(?P<inheritance_disable>))? + $""", re.VERBOSE, + ), + "setval": "send-community-gshut-ebgp{{' inheritance-disable' " + "if send_community_gshut_ebgp.inheritance_disable is defined else ''}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "send_community_gshut_ebgp": { + "set": "{{True if send_community_gshut_ebg is defined and " + "inheritance_disable is not defined}}", + "inheritance_disable": "{{True if inheritance_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "send_extended_community_ebgp", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \ssend-extended-community-ebgp(?P<send_extended_community_ebgp>) + (\sinheritance-disable(?P<inheritance_disable>))? + $""", re.VERBOSE, + ), + "setval": "send-extended-community-ebgp{{' inheritance-disable' " + "if send_extended_community_ebgp.inheritance_disable is defined else ''}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "send_extended_community_ebgp": { + "set": "{{True if send_extended_community_ebgp is defined and " + "inheritance_disable is not defined}}", + "inheritance_disable": "{{True if inheritance_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "send_multicast_attributes", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s+(?P<send_multicast_attributes>send-multicast-attributes) + (\sdisable(?P<disable>))? + $""", re.VERBOSE, + ), + "setval": "send-multicast-attributes{{' disable' " + "if send_multicast_attributes.disable is defined else ''}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "send_multicast_attributes": { + "set": "{{True if send_multicast_attributes is " + "defined and disable is not defined}}", + "disable": "{{True if disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "soft_reconfiguration", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \ssoft-reconfiguration + \sinbound(?P<inbound>) + (\salways(?P<always>))? + (\sinheritance-disable(?P<inheritance_disable>))? + $""", re.VERBOSE, + ), + "setval": _tmpl_soft_reconfiguration, + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "soft_reconfiguration": { + "inbound": { + "set": "{{True if inbound is defined and " + "inheritance_disable is not defined and " + "always is not defined}}", + "always": "{{True if always is defined }}", + "inheritance_disable": "{{True if inheritance_disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "weight", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sweight\s(?P<weight>\d+) + $""", re.VERBOSE, + ), + "setval": "weight {{weight}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "weight": "{{weight}}", + }, + }, + }, + }, + }, + }, + { + "name": "use", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \suse\s(?P<af_use>\S+) + $""", re.VERBOSE, + ), + "setval": "weight {{weight}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "use": "{{af_use}}", + }, + }, + }, + }, + }, + }, + { + "name": "update.out_originator_loopcheck_set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \supdate\sout\soriginator-loopcheck(?P<set>) + $""", re.VERBOSE, + ), + "setval": "update out originator-loopcheck", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "update": { + "out_originator_loopcheck_set": "{{True if set is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "update.out_originator_loopcheck_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \supdate\sout\soriginator-loopcheck(?P<set>) + (\sdisable(?P<disable>))? + $""", re.VERBOSE, + ), + "setval": "update out originator-loopcheck disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "address_family": { + '{{"address_family_" + afi + "_" + safi }}': { + "update": { + "out_originator_loopcheck_disable": "{{True if disable is defined}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "advertisement_interval", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<advertise_in>advertisement-interval\s\d+) + $""", re.VERBOSE, + ), + "setval": "advertisement-interval {{ advertisement_interval }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "advertisement_interval": "{{ advertise_in.split(" ")[1] }}", + }, + }, + }, + }, + { + "name": "bfd_fast_detect_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sbfd + \sfast-detect + \s(?P<disable>disable) + $""", re.VERBOSE, + ), + "setval": "bfd fast-detect disable", + "compval": "bfd.fast_detect.disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "bfd": { + "fast_detect": {"disable": "{{ True if disable is defined }}"}, + }, + }, + }, + }, + }, + { + "name": "bfd_fast_detect_set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sbfd + \s(?P<fast_detect>fast-detect) + $""", re.VERBOSE, + ), + "setval": "bfd fast-detect", + "compval": "bfd.fast_detect.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "bfd": { + "fast_detect": {"set": "{{ True if fast_detect is defined }}"}, + }, + }, + }, + }, + }, + { + "name": "bfd_fast_detect_strict_mode", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sbfd + \sfast-detect + \s(?P<strict_mode>strict-mode) + $""", re.VERBOSE, + ), + "setval": "bfd fast-detect strict-mode", + "compval": "bfd.fast_detect.strict_mode", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "bfd": { + "fast_detect": {"strict_mode": "{{ True if strict_mode is defined }}"}, + }, + }, + }, + }, + }, + { + "name": "bfd_nbr_multiplier", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sbfd + \s(?P<multiplier>multiplier\s\S+) + $""", re.VERBOSE, + ), + "setval": "bfd multiplier {{ bfd.multiplier}}", + "compval": "bfd.multiplier", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: + { + "bfd": { + "multiplier": "{{multiplier.split(" ")[1]}}", + }, + }, + }, + }, + }, + { + "name": "bfd_nbr_minimum_interval", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sbfd + \s(?P<min_interval>minimum-interval\s\S+) + $""", re.VERBOSE, + ), + "setval": "bfd minimum-interval {{ bfd.minimum_interval}}", + "compval": "bfd.minimum_interval", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "bfd": { + "minimum_interval": "{{min_interval.split(" ")[1]}}", + }, + }, + }, + }, + }, + { + "name": "bmp_activate", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sbmp-activate + \s(?P<bmp_activate>server\s\d+) + $""", re.VERBOSE, + ), + "setval": "bmp-activate server {{bmp_activate.server}}", + "compval": "bmp_activate.serevr", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "bmp_activate": {"server": "{{ bmp_activate.split(" ")[1] }}"}, + }, + }, + }, + }, + { + "name": "neighbor_cluster_id", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<cluster_id>cluster-id\s\d+) + $""", re.VERBOSE, + ), + "setval": "cluster-id {{ cluster_id }}", + "compval": "cluster_id", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: {"cluster_id": "{{ cluster_id.split(" ")[1] }}"}, + }, + }, + }, + { + "name": "neighbor_description", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sdescription\s(?P<description>.+) + $""", re.VERBOSE, + ), + "setval": "description {{ description }}", + "compval": "description", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: {"description": "{{ description }}"}, + }, + }, + }, + { + "name": "dmz_link_bandwidth", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<dmz_link_bandwidth>dmz-link-bandwidth) + $""", re.VERBOSE, + ), + "setval": "dmz-link-bandwidth", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "dmz_link_bandwidth": { + "set": "{{ True if dmz_link_bandwidth is defined }}", + }, + }, + }, + }, + }, + { + "name": "dmz_link_bandwidth_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sdmz-link-bandwidth + \s(?P<dmz_link_bandwidth>inheritance_disable) + $""", re.VERBOSE, + ), + "setval": "dmz-link-bandwidth inheritance-disable", + "compval": "dmz_link_bandwidth.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "dmz_link_bandwidth": { + "inheritance_disable": "{{ True if dmz_link_bandwidth is defined }}", + }, + }, + }, + }, + }, + { + "name": "dscp", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<dscp>dscp\s\S+) + $""", re.VERBOSE, + ), + "setval": "dscp {{ dscp }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "dscp": "{{ dscp.split(" ")[1] }}", + }, + }, + }, + }, + { + "name": "ebgp_multihop_value", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ebgp_multihop>ebgp-multihop\s\S+) + $""", re.VERBOSE, + ), + "setval": "ebgp-multihop {{ ebgp_multihop.value}}", + "compval": "ebgp_multihop.value", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ebgp_multihop": { + "value": "{{ ebgp_multihop.split(" ")[1] }}", + }, + }, + }, + }, + }, + { + "name": "ebgp_multihop_mpls", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ebgp_multihop>ebgp-multihop\s\S*\smpls) + $""", re.VERBOSE, + ), + "setval": "ebgp-multihop mpls", + "compval": "ebgp_multihop.mpls", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ebgp_multihop": {"mpls": "{{ True if ebgp_multihop is defined }}"}, + }, + }, + }, + }, + { + "name": "ebgp_recv_extcommunity_dmz_set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ebgp_recv_extcommunity_dmz>ebgp-recv-extcommunity-dmz) + $""", re.VERBOSE, + ), + "setval": "ebgp-recv-extcommunity-dmz inheritance-disable", + "compval": "ebgp_recv_extcommunity_dm.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ebgp_recv_extcommunity_dmz": { + "set": "{{ True if ebgp_recv_extcommunity_dmz is defined }}", + }, + }, + }, + }, + }, + { + "name": "ebgp_recv_extcommunity_dmz", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ebgp_recv_extcommunity_dmz>ebgp-recv-extcommunity-dmz\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "ebgp-recv-extcommunity-dmz inheritance-disable ", + "compval": "ebgp_recv_extcommunity_dmz.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ebgp_recv_extcommunity_dmz": { + "inheritance_disable": "{{ True if ebgp_recv_extcommunity_dmz is defined }}", + }, + }, + }, + }, + }, + { + "name": "ebgp_send_extcommunity_dmz", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ebgp_send_extcommunity_dmz>ebgp-send-extcommunity-dmz\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "ebgp-send-extcommunity-dmz inheritance-disable ", + "compval": "ebgp_send_extcommunity_dmz.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ebgp_send_extcommunity_dmz": { + "inheritance_disable": "{{ True if ebgp_send_extcommunity_dmz is defined }}", + }, + }, + }, + }, + }, + { + "name": "ebgp_send_extcommunity_dmz_set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ebgp_send_extcommunity_dmz>ebgp-send-extcommunity-dmz) + $""", re.VERBOSE, + ), + "setval": "ebgp-send-extcommunity-dmz", + "compval": "ebgp_send_extcommunity_dmz.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ebgp_send_extcommunity_dmz": { + "set": "{{ True if ebgp_send_extcommunity_dmz is defined }}", + }, + }, + }, + }, + }, + { + "name": "ebgp_send_extcommunity_dmz_cumulatie", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ebgp_send_extcommunity_dmz>ebgp-send-extcommunity-dmz\scumulatie) + $""", re.VERBOSE, + ), + "setval": "ebgp-send-extcommunity-dmz cumulatie ", + "compval": "ebgp_send_extcommunity_dmz.cumulatie", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ebgp_send_extcommunity_dmz": { + "cumulatie": "{{ True if ebgp_send_extcommunity_dmz is defined }}", + }, + }, + }, + }, + }, + { + "name": "egress_engineering", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<egress_engineering>egress-engineering\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "egress-engineering inheritance-disable ", + "compval": "egress_engineering.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "egress_engineering": { + "inheritance_disable": "{{ True if egress_engineering is defined }}", + }, + }, + }, + }, + + }, + { + "name": "egress_engineering_set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<egress_engineering>egress-engineering) + $""", re.VERBOSE, + ), + "setval": "egress-engineering", + "compval": "egress_engineering.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "egress_engineering": { + "set": "{{ True if egress_engineering is defined }}", + }, + }, + }, + }, + }, + { + "name": "neighbor_enforce_first_as_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<enforce_first_as_disable>enforce-first-as\sdisable) + $""", re.VERBOSE, + ), + "setval": "enforce-first-as disable", + "compval": "enforce_first_as.disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "enforce_first_as": { + "disable": "{{ True if enforce_first_as_disable is defined }}", + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_restart_restart_time", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<graceful_restart_restart_time>graceful-restart\srestart-time\s\d+) + $""", re.VERBOSE, + ), + "setval": "graceful-restart restart-time {{ graceful_restart.restart_time}}", + "compval": "graceful_restart.restart_time", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_restart": { + "restart_time": "{{ graceful_restart_restart_time.split(" ")[2] }}", + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_restart_stalepath_time", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<graceful_restart_stalepath_time>graceful-restart\sstalepath-time\s\d+) + $""", re.VERBOSE, + ), + "setval": "graceful-restart stalepath-time {{ graceful_restart.stalepath_time}}", + "compval": "graceful_restart.stalepath_time", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_restart": { + "stalepath_time": "{{ graceful_restart_stalepath_time.split(" ")[2] }}", + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_maintenance_set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<graceful_maintenance>graceful-maintenance) + $""", re.VERBOSE, + ), + "setval": "graceful-maintenance", + "compval": "graceful_maintenance.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_maintenance": { + "set": "{{ True if graceful_maintenance is defined }}", + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_maintenance_activate", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<graceful_maintenance>graceful-maintenance\sactivate) + $""", re.VERBOSE, + ), + "setval": "graceful-maintenance activate", + "compval": "graceful_maintenance.activate.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_maintenance": { + "activate": {"set": "{{ True if graceful_maintenance is defined }}"}, + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_maintenance_activate_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<graceful_maintenance>activate\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "graceful-maintenance activate inheritance-disable", + "compval": "graceful_maintenance.activate.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_maintenance": { + "activate": { + "inheritance_disable": "{{ True if graceful_maintenance is defined }}", + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_maintenance_as_prepends", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<as_prepends>as-prepends\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "graceful-maintenance as-prepends inheritance-disable", + "compval": "graceful_maintenance.as_prepends.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_maintenance": { + "as_prepends": { + "inheritance_disable": "{{ True if as_prepends is defined }}", + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_maintenance_local_preference_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<local_preference>local-preference\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "graceful-maintenance local-preference inheritance-disable", + "compval": "graceful_maintenance.local_preference.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_maintenance": { + "local_preference": { + "inheritance_disable": "{{ True if local_preference is defined }}", + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_maintenance_local_preference", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<local_preference>local-preference\s\d+) + $""", re.VERBOSE, + ), + "setval": "graceful-maintenance local-preference {{ graceful_maintenance.local_preference.value}}", + "compval": "graceful_maintenance.local_preference.value", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_maintenance": { + "local_preference": { + "value": "{{ local_preference.split(" ")[1]}}", + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_graceful_maintenance_as_prepends_value", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<as_prepends>as-prepends\s\d+) + $""", re.VERBOSE, + ), + "setval": "graceful-maintenance as-prepends {{ graceful_maintenance.as_prepends.value }}", + "compval": "graceful_maintenance.as_prepends.value", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "graceful_maintenance": { + "as_prepends": { + "value": "{{ as_prepends.split(" ")[1]}}", + }, + }, + }, + }, + }, + }, + { + "name": "ignore_connected_check_set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ignore_connected_check>ignore-connected-check) + $""", re.VERBOSE, + ), + "setval": "ignore-connected-check", + "compval": "ignore_connected_check.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ignore_connected_check": { + "set": "{{ True if ignore_connected_check is defined }}", + }, + }, + }, + }, + }, + { + "name": "ignore_connected_check", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ignore_connected_check>ignore-connected-check\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "ignore-connected-check inheritance-disable ", + "compval": "ignore_connected_check.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ignore_connected_check": { + "inheritance_disable": "{{ True if ignore_connected_check is defined }}", + }, + }, + }, + }, + }, + { + "name": "idle_watch_time", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sidle-watch-time(?P<idle_watch_time>\s\S+) + $""", re.VERBOSE, + ), + "setval": "idle-watch-time {{idle_watch_time}} ", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "idle_watch_time": "{{idle_watch_time}}", + }, + }, + }, + }, + { + "name": "internal_vpn_client", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + (?P<internal_vpn_client>\sinternal-vpn-client) + $""", re.VERBOSE, + ), + "setval": "internal-vpn-client", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "internal_vpn_client": "{{true if internal_vpn_client is defined}}", + }, + }, + }, + }, + { + "name": "keychain", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<keychain>keychain\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "keychain inheritance-disable ", + "compval": "keychain.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "keychain": { + "inheritance_disable": "{{ True if keychain is defined }}", + }, + }, + }, + }, + + }, + { + "name": "keychain_name", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<keychain>keychain\s\S+) + $""", re.VERBOSE, + ), + "setval": "keychain {{ keychain.name }}", + "compval": "keychain.name", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "keychain": { + "name": "{{ keychain.split(" ")[1] }}", + }, + }, + }, + }, + }, + { + "name": "local_address", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slocal + \s(?P<local>address\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "local address inheritance-disable", + "compval": "local.address.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "local": { + "address": { + "inheritance_disable": "{{ True if local is defined }}", + }, + }, + }, + }, + }, + }, + { + "name": "local", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slocal + \s(?P<local>address\s\S+) + $""", re.VERBOSE, + ), + "setval": "local address {{ local.address.ipv4_address }}", + "compval": "local.address.ipv4_address", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "local": { + "address": { + "ipv4_address": "{{ local.split(" ")[1] }}", + }, + }, + }, + }, + }, + }, + { + "name": "local_as_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<local_as>local-as\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "local-as inheritance-disable", + "compval": "local_as.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "local_as": { + "inheritance_disable": "{{ True if local_as is defined }}", + }, + }, + }, + }, + }, + { + "name": "local_as", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<local_as>local-as\s\S+) + (\s(?P<no_prepend>no-prepend))? + (\s(?P<replace_as>replace-as))? + (\s(?P<dual_as>dual-as))? + $""", re.VERBOSE, + ), + "setval": _templ_local_as, + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "local_as": { + "value": "{{ local_as.split(" ")[1] }}", + "no_prepend": { + "set": "{{ True if no_prepend is defined and replace_as is undefined and dual_as is undefined else None}}", + "replace_as": { + "set": "{{ True if replace_as is defined and dual_as is undefined}}", + "dual_as": "{{ not not dual_as}}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "local_address_subnet", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slocal-address-subnet(?P<local>\s\S+) + $""", re.VERBOSE, + ), + "setval": "local-address-subnet {{local_address_subnet}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "local_address_subnet": "{{local.split(" ")[1]}}", + }, + }, + }, + }, + { + "name": "neighbor_log_message_in_value", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slog + \smessage + \s(?P<value>in\s\d+) + $""", re.VERBOSE, + ), + "setval": "log message in {{ log.message.in.value}}", + "compval": "log.log_message.in.value", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "log": { + "log_message": { + "in": { + "value": "{{ value.split(" ")[1] }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_log_message_in_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slog + \smessage + \s(?P<disable>in\sdisable) + $""", re.VERBOSE, + ), + "setval": "log message in disable", + "compval": "log.log_message.in.disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "log": { + "log_message": { + "in": { + "disable": "{{ True if disable is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_log_message_in_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slog + \smessage + \s(?P<disable>in\sinheritance-diable) + $""", re.VERBOSE, + ), + "setval": "log message in inheritance-diable", + "compval": "log.log_message.in.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "log": { + "log_message": { + "in": { + "inheritance_disable": "{{ True if disable is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_log_message_out_value", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slog + \smessage + \s(?P<value>out\s\d+) + $""", re.VERBOSE, + ), + "setval": "log message out {{ log.message.out.value}}", + "compval": "log.log_message.out.value", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "log": { + "log_message": { + "out": { + "value": "{{ value.split(" ")[1] }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_log_message_out_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slog + \smessage + \s(?P<disable>out\sdisable) + $""", re.VERBOSE, + ), + "setval": "log message out disable", + "compval": "log.log_message.out.disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "log": { + "log_message": { + "out": { + "disable": "{{ True if disable is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_log_message_out_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \slog + \smessage + \s(?P<disable>out\sinheritance-diable) + $""", re.VERBOSE, + ), + "setval": "log message out inheritance-diable", + "compval": "log.log_message.out.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "log": { + "log_message": { + "out": { + "inheritance_disable": "{{ True if disable is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "maximum_peers", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \smaximum-peers(?P<local>\s\S+) + $""", re.VERBOSE, + ), + "setval": "maximum-peers {maximum_peers}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "maximum_peers": "{{local}}", + }, + }, + }, + + }, + { + "name": "password_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<password>password\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "password inheritance-disable", + "compval": "password.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "password": { + "inheritance_disable": "{{ True if password is defined }}", + }, + }, + }, + }, + }, + { + "name": "password_encrypted", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \spassword\sencrypted + \s(?P<password>\S+) + $""", re.VERBOSE, + ), + "setval": "password encrypted {{password.encrypted}}", + "compval": "password.encrypted", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "password": { + "encrypted": "{{ password }}", + }, + }, + }, + }, + }, + { + "name": "peer_set", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \speer-set(?P<local>\s\S+) + $""", re.VERBOSE, + ), + "setval": "peer-set {peer_set}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "peer_set": "{{local}}", + }, + }, + }, + }, + { + "name": "receive_buffer_size", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<receive_buffer_size>receive-buffer-size\s\d+) + $""", re.VERBOSE, + ), + "setval": "receive-buffer-size {{ receive_buffer_size }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "receive_buffer_size": "{{ receive_buffer_size.split(" ")[1] }}", + }, + }, + }, + }, + { + "name": "send_buffer_size", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<send_buffer_size>send-buffer-size\s\d+) + $""", re.VERBOSE, + ), + "setval": "send-buffer-size {{ send_buffer_size }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "send_buffer_size": "{{ send_buffer_size.split(" ")[1] }}", + }, + }, + }, + }, + { + "name": "precedence", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \sprecedence\s(?P<local>\S+) + $""", re.VERBOSE, + ), + "setval": "precedence {{precedence}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "precedence": "{{local}}", + }, + }, + }, + }, + { + "name": "remote_as", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<remote_as>remote-as\s\S+) + $""", re.VERBOSE, + ), + "setval": "remote-as {{ remote_as }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "remote_as": "{{ remote_as.split(" ")[1] }}", + }, + }, + }, + }, + { + "name": "remote_as_list", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<remote_as>remote-as-list\s\S+) + $""", re.VERBOSE, + ), + "setval": "remote-as-list {{ remote_as_list }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "remote_as_list": "{{ remote_as.split(" ")[1] }}", + }, + }, + }, + }, + { + "name": "session_open_mode", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<session_open_mode>session-open-mode\s(active-only|both|passive-only)) + $""", re.VERBOSE, + ), + "setval": "session-open-mode {{ session_open_mode }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "session_open_mode": "{{ session_open_mode.split(" ")[1] }}", + }, + }, + }, + }, + { + "name": "neighbor_shutdown", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<shutdown>shutdown) + $""", re.VERBOSE, + ), + "setval": "shutdown", + "compval": "shutdown", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "shutdown": { + "set": "{{ True if shutdown is defined }}", + }, + }, + }, + }, + }, + { + "name": "neighbor_shutdown_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<shutdown>shutdown\sinheritance_disable) + $""", re.VERBOSE, + ), + "setval": "shutdown inheritance-disable", + "compval": "shutdown.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "shutdown": {"inheritance_disable": "{{ True if shutdown is defined }}"}, + }, + }, + }, + }, + { + "name": "neighbor_tcp_mss_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<tcp_mss_disable>tcp\smss\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "tcp mss inheritance-disable", + "compval": "tcp.mss.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "tcp": { + "mss": { + "inheritance_disable": "{{ True if tcp_mss_disable is defined }}", + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_tcp_mss", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<tcp_mss>tcp\smss\s\d+) + $""", re.VERBOSE, + ), + "setval": "tcp mss {{ tcp.mss.value }}", + "compval": "tcp.mss.value", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "tcp": { + "mss": { + "value": "{{ tcp_mss.split(" ")[2] }}", + }, + }, + }, + }, + }, + + }, + { + "name": "neighbor_timers_keepalive", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<timers_keepalive_time>timers\s\d+) + \s(?P<timers_holdtime>\d+) + $""", re.VERBOSE, + ), + "setval": "timers {{ timers.keepalive_time}} {{ timers.holdtime }}", + "compval": "timers", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "timers": { + "keepalive_time": "{{ timers_keepalive_time.split(" ")[1] }}", + "holdtime": "{{ timers_holdtime.split(" ")[0] }}", + }, + }, + }, + }, + }, + { + "name": "use.neighbor_group", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \suse\sneighbor-group\s(?P<neighbor_group>\S+) + $""", re.VERBOSE, + ), + "setval": "use neighbor-group {{ use.neighbor_group }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "use": { + "neighbor_group": "{{ neighbor_group }}", + }, + }, + }, + }, + + }, + { + "name": "use.session_group", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \suse\ssession-group\s(?P<session_group>\S+) + $""", re.VERBOSE, + ), + "setval": "use session-group {{ use.session_group }}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "use": { + "session_group": "{{ session_group }}", + }, + }, + }, + }, + }, + { + "name": "update_source", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \supdate-source + \s(?P<update_source>\S+) + $""", re.VERBOSE, + ), + "setval": "update-source {{ update_source}}", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "update_source": "{{ update_source}}", + }, + }, + }, + }, + { + "name": "neighbor_ttl_security_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ttl_security>ttl-security\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "ttl-security inheritance-disable", + "compval": "ttl_security.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ttl_security": { + "inheritance_disable": "{{ True if ttl_security is defined }}", + }, + }, + }, + }, + }, + { + "name": "neighbor_ttl_security", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<ttl_security>ttl-security) + $""", re.VERBOSE, + ), + "setval": "ttl-security", + "compval": "ttl_security.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "ttl_security": { + "set": "{{ True if ttl_security is defined }}", + }, + }, + }, + }, + + }, + { + "name": "neighbor_update_in_filtering_attribute_filter_group", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<attribute_filter_group>attribute-filter\sgroup\s\S+) + $""", re.VERBOSE, + ), + "setval": "update in filtering attribute-filter group {{ update.in.filtering.attribute_filter.group }}", + "compval": "update.in.filtering.attribute_filter.group", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "update": { + "in": { + "filtering": { + "attribute_filter": { + "group": "{{ attribute_filter_group.split(" ")[2] }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_update_in_filtering_logging_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<logging_disable>logging\sdisable) + $""", re.VERBOSE, + ), + "setval": "update in filtering logging disable", + "compval": "update.in.filtering.logging.disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "update": { + "in": { + "filtering": { + "logging": { + "disable": "{{True if logging_disable is defined }}", + }, + }, + }, + }, + }, + }, + }, + + }, + { + "name": "neighbor_update_in_filtering_message_buffers", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \s(?P<message_buffers>message\sbuffers\s\d+) + $""", re.VERBOSE, + ), + "setval": "update in filtering message buffers {{ update.in.filtering.message.buffers}}", + "compval": "update.in.filtering.update_message.buffers", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "update": { + "in": { + "filtering": { + "update_message": { + "buffers": "{{ message_buffers.split(" ")[2] }}", + }, + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_capability_additional_paths_send", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \scapability + \sadditional-paths + \s(?P<additional_paths_send>send) + $""", re.VERBOSE, + ), + "setval": "capability additional-paths send", + "compval": "capability.additional_paths.send.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "capability": { + "additional_paths": { + "send": { + "set": "{{ True if additional_paths_send is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_capability_additional_paths_send_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \scapability + \sadditional-paths + \s(?P<additional_paths_send>send\sdisable) + $""", re.VERBOSE, + ), + "setval": "capability additional-paths send disable", + "compval": "capability.additional_paths.send.disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "capability": { + "additional_paths": { + "send": { + "disable": "{{ True if additional_paths_send is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_capability_additional_paths_rcv", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \scapability + \sadditional-paths + \s(?P<additional_paths_receive>receive) + $""", re.VERBOSE, + ), + "setval": "capability additional-paths receive", + "compval": "capability.additional_paths.receive.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "capability": { + "additional_paths": { + "receive": { + "set": "{{ True if additional_paths_receive is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_capability_additional_paths_rcv_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \scapability + \sadditional-paths + \s(?P<additional_paths_receive_disable>receive\sdisable) + $""", re.VERBOSE, + ), + "setval": "capability additional-paths receive disable", + "compval": "capability.additional_paths.receive.disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "capability": { + "additional_paths": { + "receive": { + "disable": "{{ True if additional_paths_receive_disable is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_capability_suppress_four_byte_AS", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \scapability + \ssuppress + \s(?P<suppress_4_byte_as>4-byte-as) + $""", re.VERBOSE, + ), + "setval": "capability suppress 4-byte-as", + "compval": "capability.suppress.four_byte_AS.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "capability": { + "suppress": { + "four_byte_AS": { + "set": "{{ True if suppress_4_byte_as is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_capability_suppress_all", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \scapability + \ssuppress + \s(?P<all>all) + $""", re.VERBOSE, + ), + "setval": "capability suppress all", + "compval": "capability.suppress.all.set", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "capability": { + "suppress": { + "all": { + "set": "{{ True if all is defined }}", + }, + }, + }, + }, + }, + }, + }, + { + "name": "neighbor_capability_suppress_all_inheritance_disable", + "getval": re.compile( + r""" + \s+neighbor-group\s(?P<nbr_address>\S+) + \scapability + \ssuppress + \s(?P<all>all\sinheritance-disable) + $""", re.VERBOSE, + ), + "setval": "capability suppress all inheritance-disable", + "compval": "capability.suppress.all.inheritance_disable", + "result": { + "neighbor": { + UNIQUE_NEIB_ADD: { + "capability": { + "suppress": { + "all": { + "inheritance_disable": "{{ True if all is defined }}", + }, + }, + }, + }, + }, + }, + + }, + + ] + # fmt: on diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/ospfv2.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/ospfv2.py index e5a54a64f..68937f9bd 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/ospfv2.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/ospfv2.py @@ -19,11 +19,11 @@ def _tmplt_ospf_default_information(config_data): command += " metric {metric}".format(**config_data["default_information_originate"]) if "metric_type" in config_data["default_information_originate"]: command += " metric-type {metric_type}".format( - **config_data["default_information_originate"] + **config_data["default_information_originate"], ) if "route_policy" in config_data["default_information_originate"]: command += " route-policy {route_policy}".format( - **config_data["default_information_originate"] + **config_data["default_information_originate"], ) return command @@ -35,7 +35,7 @@ def _tmplt_ospf_auto_cost(config_data): command += " disable" if "reference_bandwidth" in config_data["auto_cost"]: command += " reference-bandwidth {reference_bandwidth}".format( - **config_data["auto_cost"] + **config_data["auto_cost"], ) return command @@ -416,11 +416,11 @@ def _tmplt_ospf_area_nssa_def_info_origin(config_data): ) if "metric" in def_info_origin: command += " metric {metric}".format( - **config_data["nssa"]["default_information_originate"] + **config_data["nssa"]["default_information_originate"], ) if "metric_type" in def_info_origin: command += " metric-type {metric_type}".format( - **config_data["nssa"]["default_information_originate"] + **config_data["nssa"]["default_information_originate"], ) return command @@ -531,11 +531,11 @@ def _tmplt_timers_graceful_shutdown(config_data): command = "timers graceful-shutdown" if "initial_delay" in config_data["timers"]["graceful-shutdown"]: command += " initial delay {initial_delay}".format( - **config_data["timers"]["graceful-shutdown"] + **config_data["timers"]["graceful-shutdown"], ) if "retain_routes" in config_data["timers"]["graceful-shutdown"]: command += " retain routes {retain_routes}".format( - **config_data["timers"]["graceful-shutdown"] + **config_data["timers"]["graceful-shutdown"], ) return command diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/ospfv3.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/ospfv3.py index 14e3720be..ea8807206 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/ospfv3.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/rm_templates/ospfv3.py @@ -19,11 +19,11 @@ def _tmplt_ospf_default_information(config_data): command += " metric {metric}".format(**config_data["default_information_originate"]) if "metric_type" in config_data["default_information_originate"]: command += " metric-type {metric_type}".format( - **config_data["default_information_originate"] + **config_data["default_information_originate"], ) if "route_policy" in config_data["default_information_originate"]: command += " route-policy {route_policy}".format( - **config_data["default_information_originate"] + **config_data["default_information_originate"], ) return command @@ -35,7 +35,7 @@ def _tmplt_ospf_auto_cost(config_data): command += " disable" if "reference_bandwidth" in config_data["auto_cost"]: command += " reference-bandwidth {reference_bandwidth}".format( - **config_data["auto_cost"] + **config_data["auto_cost"], ) return command @@ -413,11 +413,11 @@ def _tmplt_ospf_area_nssa_def_info_origin(config_data): ) if "metric" in def_info_origin: command += " metric {metric}".format( - **config_data["nssa"]["default_information_originate"] + **config_data["nssa"]["default_information_originate"], ) if "metric_type" in def_info_origin: command += " metric-type {metric_type}".format( - **config_data["nssa"]["default_information_originate"] + **config_data["nssa"]["default_information_originate"], ) return command @@ -528,11 +528,11 @@ def _tmplt_timers_graceful_shutdown(config_data): command = "timers graceful-shutdown" if "initial_delay" in config_data["timers"]["graceful-shutdown"]: command += " initial delay {initial_delay}".format( - **config_data["timers"]["graceful-shutdown"] + **config_data["timers"]["graceful-shutdown"], ) if "retain_routes" in config_data["timers"]["graceful-shutdown"]: command += " retain routes {retain_routes}".format( - **config_data["timers"]["graceful-shutdown"] + **config_data["timers"]["graceful-shutdown"], ) return command diff --git a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/utils/utils.py b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/utils/utils.py index a4467a487..64c66ca4b 100644 --- a/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/utils/utils.py +++ b/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/utils/utils.py @@ -14,12 +14,11 @@ from functools import total_ordering from ansible.module_utils._text import to_text from ansible.module_utils.basic import missing_required_lib +from ansible.module_utils.common.network import is_masklen, to_netmask from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( dict_diff, - is_masklen, search_obj_in_list, - to_netmask, ) @@ -109,7 +108,7 @@ def filter_dict_having_none_value(want, have): have_ip = have.get("ipv4") for each in have_ip: if len(want_ip) > 1 and each.get("secondary"): - have_ip = each.get("address").split(" ")[0] + have_ip = each.get("address").split("/")[0] if have_ip != want_ip[0]: diff_ip = True if each.get("secondary") and diff_ip is True: @@ -286,7 +285,7 @@ def normalize_interface(name): if_type = "GigabitEthernet" elif name.lower().startswith("fa"): if_type = "FastEthernet" - elif name.lower().startswith("fo"): + elif name.lower().startswith("for"): if_type = "FortyGigE" elif name.lower().startswith("te"): if_type = "TenGigE" @@ -298,10 +297,16 @@ def normalize_interface(name): if_type = "Vlan" elif name.lower().startswith("lo"): if_type = "Loopback" - elif name.lower().startswith("be"): + elif name.lower().startswith("bundle-e"): if_type = "Bundle-Ether" - elif name.lower().startswith("bp"): + elif name.lower().startswith("bundle-p"): if_type = "Bundle-POS" + elif name.lower().startswith("fif"): + if_type = "FiftyGigE" + elif name.lower().startswith("fou"): + if_type = "FourHundredGigE" + elif name.lower().startswith("two"): + if_type = "TwoHundredGigE" else: if_type = None @@ -310,7 +315,6 @@ def normalize_interface(name): number = number_list[-1].strip() else: number = _get_number(name) - if if_type: proper_interface = if_type + number else: @@ -326,14 +330,16 @@ def get_interface_type(interface): return "GigabitEthernet" elif interface.upper().startswith("FA"): return "FastEthernet" - elif interface.upper().startswith("FO"): + elif interface.upper().startswith("FORT"): return "FortyGigE" elif interface.upper().startswith("ET"): return "Ethernet" elif interface.upper().startswith("LO"): return "Loopback" - elif interface.upper().startswith("BE"): + elif interface.upper().startswith("BUNDLE-E"): return "Bundle-Ether" + elif interface.upper().startswith("BUNDLE-P"): + return "Bundle-POS" elif interface.upper().startswith("NV"): return "nve" elif interface.upper().startswith("TE"): @@ -344,6 +350,16 @@ def get_interface_type(interface): return "HundredGigE" elif interface.upper().startswith("PRE"): return "preconfigure" + elif interface.upper().startswith("FIF"): + return "FiftyGigE" + elif interface.upper().startswith("FOU"): + return "FourHundredGigE" + elif interface.upper().startswith("TWO"): + return "TwoHundredGigE" + elif interface.upper().startswith("MG"): + return "management" + elif interface.upper().startswith("MA"): + return "management" else: return "unknown" @@ -454,3 +470,8 @@ def _coerce(other): if isinstance(other, (int, float)): other = Version(str(other)) return other + + +def netmask_to_cidr(netmask): + # convert netmask to cidr and returns the cidr notation + return str(sum([bin(int(x)).count("1") for x in netmask.split(".")])) diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acl_interfaces.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acl_interfaces.py index 7dc8df807..80dcc44f4 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acl_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acl_interfaces.py @@ -130,27 +130,26 @@ EXAMPLES = """ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: in - - name: acl_2 - direction: out - - afi: ipv6 - acls: - - name: acl6_1 - direction: in - - name: acl6_2 - direction: out - - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: out + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: in + - name: acl_2 + direction: out + - afi: ipv6 + acls: + - name: acl6_1 + direction: in + - name: acl6_2 + direction: out + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: out state: merged # After state: @@ -199,14 +198,14 @@ EXAMPLES = """ - name: Update acl_interfaces configuration using merged cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_2 - direction: out - - name: acl_1 - direction: in + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_2 + direction: out + - name: acl_1 + direction: in state: merged # After state: @@ -253,15 +252,17 @@ EXAMPLES = """ # ipv4 access-group acl_1 egress # ! -- name: Replace device configurations of listed interface with provided configurations +- name: >- + Replace device configurations of listed interface with provided + configurations cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv6 - acls: - - name: acl6_3 - direction: in + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv6 + acls: + - name: acl6_3 + direction: in state: replaced # After state: @@ -308,16 +309,16 @@ EXAMPLES = """ - name: Overridde all interface ACL configuration with provided configuration cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_2 - direction: in - - afi: ipv6 - acls: - - name: acl6_3 - direction: out + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_2 + direction: in + - afi: ipv6 + acls: + - name: acl6_3 + direction: out state: overridden # After state: @@ -364,7 +365,7 @@ EXAMPLES = """ - name: Delete all ACL attributes of GigabitEthernet0/0/0/1 cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/1 state: deleted # After state: @@ -564,14 +565,14 @@ EXAMPLES = """ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: in - - name: acl_2 - direction: out + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: in + - name: acl_2 + direction: out state: rendered # Task Output (redacted) diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acls.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acls.py index 22a7779cb..620838353 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acls.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_acls.py @@ -701,100 +701,210 @@ EXAMPLES = """ # Before state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 05:07:45.767 UTC -# RP/0/RP0/CPU0:ios# +# RP/0/RP0/CPU0:ios#show access-lists afi-al +# Fri Sep 22 03:57:04.758 UTC +# ipv4 access-list acl_1 +# 10 permit udp 192.168.1.0 0.0.0.255 any - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_acls: config: - - afi: ipv6 - acls: - - name: acl6_1 - aces: - - sequence: 10 - grant: deny - protocol: tcp - source: - prefix: 2001:db8:1234::/48 - port_protocol: - range: - start: ftp - end: telnet - destination: - any: true - protocol_options: - tcp: - syn: true - ttl: - range: - start: 180 - end: 250 - routing: true - authen: true - log: true - - - sequence: 20 - grant: permit - protocol: icmpv6 - source: - any: true - destination: - any: true - protocol_options: - icmpv6: - router_advertisement: true - precedence: network - destopts: true - - - afi: ipv4 - acls: - - name: acl_1 - aces: - - sequence: 16 - remark: TEST_ACL_1_REMARK - - - sequence: 21 - grant: permit - protocol: tcp - source: - host: 192.0.2.10 - port_protocol: - range: - start: pop3 - end: 121 - destination: - address: 198.51.100.0 - wildcard_bits: 0.0.0.15 - protocol_options: - tcp: - rst: true - - - sequence: 23 - grant: deny - protocol: icmp - source: - any: true - destination: - prefix: 198.51.100.0/28 - protocol_options: - icmp: - reassembly_timeout: true - dscp: - lt: af12 - - - name: acl_2 - aces: - - sequence: 10 - remark: TEST_ACL_2_REMARK + - afi: ipv6 + acls: + - name: acl6_1 + aces: + - sequence: 10 + grant: deny + protocol: tcp + source: + prefix: '2001:db8:1234::/48' + port_protocol: + range: + start: ftp + end: telnet + destination: + any: true + protocol_options: + tcp: + syn: true + ttl: + range: + start: 180 + end: 250 + routing: true + authen: true + log: true + - sequence: 20 + grant: permit + protocol: icmpv6 + source: + any: true + destination: + any: true + protocol_options: + icmpv6: + router_advertisement: true + precedence: network + destopts: true + - afi: ipv4 + acls: + - name: acl_1 + aces: + - sequence: 16 + remark: TEST_ACL_1_REMARK + - sequence: 21 + grant: permit + protocol: tcp + source: + host: 192.0.2.10 + port_protocol: + range: + start: pop3 + end: 121 + destination: + address: 198.51.100.0 + wildcard_bits: 0.0.0.15 + protocol_options: + tcp: + rst: true + - sequence: 23 + grant: deny + protocol: icmp + source: + any: true + destination: + prefix: 198.51.100.0/28 + protocol_options: + icmp: + reassembly_timeout: true + dscp: + lt: af12 + - name: acl_2 + aces: + - sequence: 10 + remark: TEST_ACL_2_REMARK state: merged +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: udp +# sequence: 10 +# source: +# address: 192.168.1.0 +# wildcard_bits: 0.0.0.255 +# name: acl_1 +# afi: ipv4 +# +# commands: +# - ipv6 access-list acl6_1 +# - 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 authen routing log +# - 20 permit icmpv6 any any router-advertisement precedence network destopts +# - ipv4 access-list acl_1 +# - 16 remark TEST_ACL_1_REMARK +# - 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst +# - 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 +# - ipv4 access-list acl_2 +# - 10 remark TEST_ACL_2_REMARK +# +# after: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: udp +# sequence: 10 +# source: +# address: 192.168.1.0 +# wildcard_bits: 0.0.0.255 +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 + # After state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 05:22:57.021 UTC +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Fri Sep 22 04:35:19.977 UTC # ipv4 access-list acl_1 +# 10 permit udp 192.168.1.0 0.0.0.255 any # 16 remark TEST_ACL_1_REMARK # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 @@ -809,9 +919,10 @@ EXAMPLES = """ # Before state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 05:22:57.021 UTC +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Fri Sep 22 04:37:33.542 UTC # ipv4 access-list acl_1 +# 10 permit udp 192.168.1.0 0.0.0.255 any # 16 remark TEST_ACL_1_REMARK # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 @@ -824,34 +935,212 @@ EXAMPLES = """ - name: Update existing ACEs cisco.iosxr.iosxr_acls: config: - - afi: ipv4 - acls: - - name: acl_1 - aces: - - sequence: 21 - source: - prefix: 198.51.100.32/28 - port_protocol: - range: - start: pop3 - end: 121 - protocol_options: - tcp: - syn: true - - - sequence: 23 - protocol_options: - icmp: - router_advertisement: true - dscp: - eq: af23 + - afi: ipv4 + acls: + - name: acl_1 + aces: + - sequence: 21 + source: + prefix: 198.51.100.32/28 + port_protocol: + range: + start: pop3 + end: 121 + protocol_options: + tcp: + syn: true + - sequence: 23 + protocol_options: + icmp: + router_advertisement: true + dscp: + eq: af23 + +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: udp +# sequence: 10 +# source: +# address: 192.168.1.0 +# wildcard_bits: 0.0.0.255 +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 +# +# commands: +# - ipv4 access-list acl_1 +# - 21 permit tcp 198.51.100.32 0.0.0.15 range pop3 121 198.51.100.0 0.0.0.15 syn +# - 23 deny icmp any 198.51.100.0 0.0.0.15 router-advertisement dscp eq af23 +# after: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: udp +# sequence: 10 +# source: +# address: 192.168.1.0 +# wildcard_bits: 0.0.0.255 +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# sequence: 21 +# source: +# address: 198.51.100.32 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# wildcard_bits: 0.0.0.15 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# eq: af23 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# router_advertisement: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 # After state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 05:47:18.711 UTC +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Wed Sep 27 09:58:38.345 UTC # ipv4 access-list acl_1 +# 10 permit udp 192.168.1.0 0.0.0.255 any # 16 remark TEST_ACL_1_REMARK # 21 permit tcp 198.51.100.32 0.0.0.15 range pop3 121 198.51.100.0 0.0.0.15 syn # 23 deny icmp any 198.51.100.0 0.0.0.15 router-advertisement dscp eq af23 @@ -866,9 +1155,10 @@ EXAMPLES = """ # Before state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 05:22:57.021 UTC +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Fri Sep 22 05:38:36.205 UTC # ipv4 access-list acl_1 +# 10 permit udp 192.168.1.0 0.0.0.255 any # 16 remark TEST_ACL_1_REMARK # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 @@ -880,39 +1170,230 @@ EXAMPLES = """ - name: Replace device configurations of listed ACL with provided configurations cisco.iosxr.iosxr_acls: - config: - - afi: ipv4 - acls: - - name: acl_2 - aces: - - sequence: 11 - grant: permit - protocol: igmp - source: - host: 198.51.100.130 - destination: - any: true - ttl: - eq: 100 - - - sequence: 12 - grant: deny - source: - any: true - destination: - any: true - protocol: icmp state: replaced + config: + - afi: ipv4 + acls: + - name: acl_2 + aces: + - sequence: 11 + grant: permit + protocol: igmp + source: + host: 198.51.100.130 + destination: + any: true + ttl: + eq: 100 + - sequence: 12 + grant: deny + source: + any: true + destination: + any: true + protocol: icmp + +# Task Output +# ----------- +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: udp +# sequence: 10 +# source: +# address: 192.168.1.0 +# wildcard_bits: 0.0.0.255 +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 +# +# commands: +# - ipv4 access-list acl_2 +# - no 10 +# - 11 permit igmp host 198.51.100.130 any ttl eq 100 +# - 12 deny icmp any any +# +# after: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: udp +# sequence: 10 +# source: +# address: 192.168.1.0 +# wildcard_bits: 0.0.0.255 +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: igmp +# sequence: 11 +# source: +# host: 198.51.100.130 +# ttl: +# eq: 100 +# - destination: +# any: true +# grant: deny +# protocol: icmp +# sequence: 12 +# source: +# any: true +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 # After state: # ------------- - -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 06:19:51.496 UTC +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Fri Sep 22 05:56:21.103 UTC # ipv4 access-list acl_1 +# 10 permit udp 192.168.1.0 0.0.0.255 any # 16 remark TEST_ACL_1_REMARK -# 21 permit tcp 198.51.100.32 0.0.0.15 range pop3 121 198.51.100.0 0.0.0.15 syn -# 23 deny icmp any 198.51.100.0 0.0.0.15 router-advertisement dscp eq af23 +# 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst +# 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 # ipv4 access-list acl_2 # 11 permit igmp host 198.51.100.130 any ttl eq 100 # 12 deny icmp any any @@ -928,6 +1409,7 @@ EXAMPLES = """ # RP/0/RP0/CPU0:ios#sh access-lists afi-all # Thu Feb 20 05:22:57.021 UTC # ipv4 access-list acl_1 +# 10 permit udp 192.168.1.0 0.0.0.255 any # 16 remark TEST_ACL_1_REMARK # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst # 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 @@ -940,29 +1422,141 @@ EXAMPLES = """ - name: Overridde all ACLs configuration with provided configuration cisco.iosxr.iosxr_acls: config: - - afi: ipv4 - acls: - - name: acl_1 - aces: - - sequence: 10 - grant: permit - source: - any: true - destination: - any: true - protocol: tcp - - - name: acl_2 - aces: - - sequence: 20 - grant: permit - source: - any: true - destination: - any: true - protocol: igmp + - afi: ipv4 + acls: + - name: acl_1 + aces: + - sequence: 10 + grant: permit + source: + any: true + destination: + any: true + protocol: tcp + - name: acl_2 + aces: + - sequence: 20 + grant: permit + source: + any: true + destination: + any: true + protocol: igmp state: overridden +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 +# +# commands: +# - no ipv6 access-list acl6_1 +# - ipv4 access-list acl_1 +# - no 16 +# - no 21 +# - no 23 +# - 10 permit tcp any any +# - ipv4 access-list acl_2 +# - no 10 +# - 20 permit igmp any any +# +# after: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: tcp +# sequence: 10 +# source: +# any: true +# name: acl_1 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: igmp +# sequence: 20 +# source: +# any: true +# name: acl_2 +# afi: ipv4 + # After state: # ------------- @@ -978,8 +1572,8 @@ EXAMPLES = """ # Before state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 05:22:57.021 UTC +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Wed Sep 27 09:34:04.831 UTC # ipv4 access-list acl_1 # 16 remark TEST_ACL_1_REMARK # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst @@ -993,11 +1587,135 @@ EXAMPLES = """ - name: Delete a single ACL cisco.iosxr.iosxr_acls: config: - - afi: ipv6 - acls: - - name: acl6_1 + - afi: ipv6 + acls: + - name: acl6_1 state: deleted +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 +# +# commands: +# - no ipv6 access-list acl6_1 +# +# after: +# - acls: +# - aces: +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 + + # After state: # ------------- @@ -1015,8 +1733,8 @@ EXAMPLES = """ # Before state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 05:22:57.021 UTC +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Wed Sep 27 09:34:04.831 UTC # ipv4 access-list acl_1 # 16 remark TEST_ACL_1_REMARK # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst @@ -1030,13 +1748,136 @@ EXAMPLES = """ - name: Delete all ACLs under one AFI cisco.iosxr.iosxr_acls: config: - - afi: ipv4 + - afi: ipv4 state: deleted +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 +# +# commands: +# - no ipv4 access-list acl_1 +# - no ipv4 access-list acl_2 +# +# after: +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 + # After state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all +# RP/0/RP0/CPU0:ios#show access-lists afi-all # Thu Feb 20 05:22:57.021 UTC # ipv6 access-list acl6_1 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log @@ -1047,8 +1888,8 @@ EXAMPLES = """ # Before state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all -# Thu Feb 20 05:22:57.021 UTC +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Wed Sep 27 09:34:04.831 UTC # ipv4 access-list acl_1 # 16 remark TEST_ACL_1_REMARK # 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst @@ -1063,15 +1904,115 @@ EXAMPLES = """ cisco.iosxr.iosxr_acls: state: deleted + +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 +# +# commands: +# - no ipv4 access-list acl_1 +# - no ipv4 access-list acl_2 +# - no ipv6 access-list acl6_1 +# +# after: [] + # After state: # ------------- -# RP/0/RP0/CPU0:ios#sh access-lists afi-all +# RP/0/RP0/CPU0:ios#show access-lists afi-all # Thu Feb 20 05:07:45.767 UTC # RP/0/RP0/CPU0:ios# # Using gathered to gather ACL facts from the device +# RP/0/RP0/CPU0:ios#show access-lists afi-all +# Wed Sep 27 09:34:04.831 UTC +# ipv4 access-list acl_1 +# 16 remark TEST_ACL_1_REMARK +# 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst +# 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 +# ipv4 access-list acl_2 +# 10 remark TEST_ACL_2_REMARK +# ipv6 access-list acl6_1 +# 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log +# 20 permit icmpv6 any any router-advertisement precedence network destopts + - name: Gather ACL interfaces facts using gathered state cisco.iosxr.iosxr_acls: state: gathered @@ -1079,184 +2020,131 @@ EXAMPLES = """ # Task Output (redacted) # ----------------------- # - -# "gathered": [ -# { -# "acls": [ -# { -# "aces": [ -# { -# "remark": "TEST_ACL_1_REMARK", -# "sequence": 16 -# }, -# { -# "destination": { -# "address": "198.51.100.0", -# "wildcard_bits": "0.0.0.15" -# }, -# "grant": "permit", -# "protocol": "tcp", -# "protocol_options": { -# "tcp": { -# "rst": true -# } -# }, -# "sequence": 21, -# "source": { -# "host": "192.0.2.10", -# "port_protocol": { -# "range": { -# "end": "121", -# "start": "pop3" -# } -# } -# } -# }, -# { -# "destination": { -# "address": "198.51.100.0", -# "wildcard_bits": "0.0.0.15" -# }, -# "dscp": { -# "lt": "af12" -# }, -# "grant": "deny", -# "protocol": "icmp", -# "protocol_options": { -# "icmp": { -# "reassembly_timeout": true -# } -# }, -# "sequence": 23, -# "source": { -# "any": true -# } -# } -# ], -# "name": "acl_1" -# }, -# { -# "aces": [ -# { -# "remark": "TEST_ACL_2_REMARK", -# "sequence": 10 -# } -# ], -# "name": "acl_2" -# } -# ], -# "afi": "ipv4" -# }, -# { -# "acls": [ -# { -# "aces": [ -# { -# "authen": true, -# "destination": { -# "any": true -# }, -# "grant": "deny", -# "log": true, -# "protocol": "tcp", -# "protocol_options": { -# "tcp": { -# "syn": true -# } -# }, -# "routing": true, -# "sequence": 10, -# "source": { -# "port_protocol": { -# "range": { -# "end": "telnet", -# "start": "ftp" -# } -# }, -# "prefix": "2001:db8:1234::/48" -# }, -# "ttl": { -# "range": { -# "end": 250, -# "start": 180 -# } -# } -# }, -# { -# "destination": { -# "any": true -# }, -# "destopts": true, -# "grant": "permit", -# "precedence": "network", -# "protocol": "icmpv6", -# "protocol_options": { -# "icmpv6": { -# "router_advertisement": true -# } -# }, -# "sequence": 20, -# "source": { -# "any": true -# } -# } -# ], -# "name": "acl6_1" -# } -# ], -# "afi": "ipv6" -# } -# ] +# gathered: +# - acls: +# - aces: +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 # Using rendered - name: Render platform specific commands (without connecting to the device) cisco.iosxr.iosxr_acls: config: - - afi: ipv4 - acls: - - name: acl_2 - aces: - - sequence: 11 - grant: permit - protocol: igmp - source: - host: 198.51.100.130 - destination: - any: true - ttl: - eq: 100 - - - sequence: 12 - grant: deny - source: - any: true - destination: - any: true - protocol: icmp + - afi: ipv4 + acls: + - name: acl_2 + aces: + - sequence: 11 + grant: permit + protocol: igmp + source: + host: 198.51.100.130 + destination: + any: true + ttl: + eq: 100 + - sequence: 12 + grant: deny + source: + any: true + destination: + any: true + protocol: icmp state: rendered # Task Output (redacted) # ----------------------- -# "rendered": [ -# "ipv4 access-list acl_2", -# "11 permit igmp host 198.51.100.130 any ttl eq 100", -# "12 deny icmp any any" +# rendered: +# - ipv4 access-list acl_2 +# - 11 permit igmp host 198.51.100.130 any ttl eq 100 +# - 12 deny icmp any any # Using parsed # parsed.cfg # ------------ -# # ipv4 access-list acl_1 -# 10 remark TEST_ACL_2_REMARK +# 16 remark TEST_ACL_1_REMARK +# 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst +# 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 # ipv4 access-list acl_2 -# 11 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 authen routing log -# 21 permit icmpv6 any any router-advertisement precedence network packet-length eq 576 destopts +# 10 remark TEST_ACL_2_REMARK # ipv6 access-list acl6_1 # 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 routing authen log -# 20 permit icmpv6 any any router-advertisement precedence network packet-length eq 576 destopts +# 20 permit icmpv6 any any router-advertisement precedence network destopts - name: Parse externally provided ACL config to agnostic model cisco.iosxr.iosxr_acls: @@ -1265,142 +2153,84 @@ EXAMPLES = """ # Task Output (redacted) # ----------------------- -# "parsed": [ -# { -# "acls": [ -# { -# "aces": [ -# { -# "remark": "TEST_ACL_2_REMARK", -# "sequence": 10 -# } -# ], -# "name": "acl_1" -# }, -# { -# "aces": [ -# { -# "authen": true, -# "destination": { -# "any": true -# }, -# "grant": "deny", -# "log": true, -# "protocol": "tcp", -# "protocol_options": { -# "tcp": { -# "syn": true -# } -# }, -# "routing": true, -# "sequence": 11, -# "source": { -# "port_protocol": { -# "range": { -# "end": "telnet", -# "start": "ftp" -# } -# }, -# "prefix": "2001:db8:1234::/48" -# }, -# "ttl": { -# "range": { -# "end": 250, -# "start": 180 -# } -# } -# }, -# { -# "destination": { -# "any": true -# }, -# "destopts": true, -# "grant": "permit", -# "packet_length": { -# "eq": 576 -# }, -# "precedence": "network", -# "protocol": "icmpv6", -# "protocol_options": { -# "icmpv6": { -# "router_advertisement": true -# } -# }, -# "sequence": 21, -# "source": { -# "any": true -# } -# } -# ], -# "name": "acl_2" -# } -# ], -# "afi": "ipv4" -# }, -# { -# "acls": [ -# { -# "aces": [ -# { -# "authen": true, -# "destination": { -# "any": true -# }, -# "grant": "deny", -# "log": true, -# "protocol": "tcp", -# "protocol_options": { -# "tcp": { -# "syn": true -# } -# }, -# "routing": true, -# "sequence": 10, -# "source": { -# "port_protocol": { -# "range": { -# "end": "telnet", -# "start": "ftp" -# } -# }, -# "prefix": "2001:db8:1234::/48" -# }, -# "ttl": { -# "range": { -# "end": 250, -# "start": 180 -# } -# } -# }, -# { -# "destination": { -# "any": true -# }, -# "destopts": true, -# "grant": "permit", -# "packet_length": { -# "eq": 576 -# }, -# "precedence": "network", -# "protocol": "icmpv6", -# "protocol_options": { -# "icmpv6": { -# "router_advertisement": true -# } -# }, -# "sequence": 20, -# "source": { -# "any": true -# } -# } -# ], -# "name": "acl6_1" -# } -# ], -# "afi": "ipv6" -# } -# ] +# parsed: +# - acls: +# - aces: +# - remark: TEST_ACL_1_REMARK +# sequence: 16 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# grant: permit +# protocol: tcp +# protocol_options: +# tcp: +# rst: true +# sequence: 21 +# source: +# host: 192.0.2.10 +# port_protocol: +# range: +# end: '121' +# start: pop3 +# - destination: +# address: 198.51.100.0 +# wildcard_bits: 0.0.0.15 +# dscp: +# lt: af12 +# grant: deny +# protocol: icmp +# protocol_options: +# icmp: +# reassembly_timeout: true +# sequence: 23 +# source: +# any: true +# name: acl_1 +# - aces: +# - remark: TEST_ACL_2_REMARK +# sequence: 10 +# name: acl_2 +# afi: ipv4 +# - acls: +# - aces: +# - authen: true +# destination: +# any: true +# grant: deny +# log: true +# protocol: tcp +# protocol_options: +# tcp: +# syn: true +# routing: true +# sequence: 10 +# source: +# port_protocol: +# range: +# end: telnet +# start: ftp +# prefix: 2001:db8:1234::/48 +# ttl: +# range: +# end: 250 +# start: 180 +# - destination: +# any: true +# destopts: true +# grant: permit +# precedence: network +# protocol: icmpv6 +# protocol_options: +# icmpv6: +# router_advertisement: true +# sequence: 20 +# source: +# any: true +# name: acl6_1 +# afi: ipv6 """ + RETURN = """ before: description: The configuration prior to the model invocation. @@ -1428,6 +2258,28 @@ commands: - 16 remark TEST_ACL_1_REMARK - 21 permit tcp host 192.0.2.10 range pop3 121 198.51.100.0 0.0.0.15 rst - 23 deny icmp any 198.51.100.0 0.0.0.15 reassembly-timeout dscp lt af12 +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - ipv6 access-list acl6_1 + - 10 deny tcp 2001:db8:1234::/48 range ftp telnet any syn ttl range 180 250 authen routing log + - 20 permit icmpv6 any any router-advertisement precedence network destopts +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_banner.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_banner.py index 2d80022b9..909d79511 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_banner.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_banner.py @@ -70,7 +70,7 @@ EXAMPLES = """ - name: Configure banner from file cisco.iosxr.iosxr_banner: banner: motd - text: "{{ lookup('file', './config_partial/raw_banner.cfg') }}" + text: '{{ lookup(''file'', ''./config_partial/raw_banner.cfg'') }}' state: present """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp.py deleted file mode 100644 index 9a42225ab..000000000 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp.py +++ /dev/null @@ -1,365 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -# -# (c) 2019, Ansible by Red Hat, inc -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# - -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - - -DOCUMENTATION = """ -module: iosxr_bgp -author: Nilashish Chakraborty (@NilashishC) -short_description: Module to configure BGP protocol settings. -description: -- This module provides configuration management of global BGP parameters on devices - running Cisco IOS-XR -version_added: 1.0.0 -deprecated: - alternative: iosxr_bgp_global - why: Updated module released with more functionality. - removed_at_date: '2023-01-29' -notes: -- This module works with connection C(network_cli). See L(the IOS-XR Platform Options,../network/user_guide/platform_iosxr.html). -options: - config: - description: - - Specifies the BGP related configuration. - type: dict - suboptions: - bgp_as: - description: - - Specifies the BGP Autonomous System (AS) number to configure on the device. - type: int - required: true - router_id: - description: - - Configures the BGP routing process router-id value. - type: str - log_neighbor_changes: - description: - - Enable/disable logging neighbor up/down and reset reason. - type: bool - neighbors: - description: - - Specifies BGP neighbor related configurations. - type: list - elements: dict - suboptions: - neighbor: - description: - - Neighbor router address. - type: str - required: true - remote_as: - description: - - Remote AS of the BGP neighbor to configure. - type: int - required: true - update_source: - description: - - Source of the routing updates. - type: str - password: - description: - - Password to authenticate the BGP peer connection. - type: str - enabled: - description: - - Administratively shutdown or enable a neighbor. - type: bool - description: - description: - - Neighbor specific description. - type: str - advertisement_interval: - description: - - Specifies the minimum interval (in seconds) between sending BGP routing - updates. - - The range is from 0 to 600. - type: int - tcp_mss: - description: - - Specifies the TCP initial maximum segment size to use. - - The range is from 68 to 10000. - type: int - ebgp_multihop: - description: - - Specifies the maximum hop count for EBGP neighbors not on directly connected - networks. - - The range is from 0 to 255. - type: int - timers: - description: - - Specifies BGP neighbor timer related configurations. - type: dict - suboptions: - keepalive: - description: - - Frequency with which the Cisco IOS-XR software sends keepalive messages - to its peer. - - The range is from 0 to 65535. - type: int - holdtime: - description: - - Interval after not receiving a keepalive message that the software - declares a peer dead. - - The range is from 3 to 65535. - type: int - min_neighbor_holdtime: - description: - - Interval specifying the minimum acceptable hold-time from a BGP - neighbor. - - The minimum acceptable hold-time must be less than, or equal to, - the interval specified in the holdtime argument. - - The range is from 3 to 65535. - type: int - address_family: - description: - - Specifies BGP address family related configurations. - type: list - elements: dict - suboptions: - afi: - description: - - Type of address family to configure. - choices: - - ipv4 - - ipv6 - required: true - type: str - safi: - description: - - Specifies the type of cast for the address family. - choices: - - flowspec - - unicast - - multicast - - labeled-unicast - type: str - default: unicast - redistribute: - description: - - Specifies the redistribute information from another routing protocol. - type: list - elements: dict - suboptions: - protocol: - description: - - Specifies the protocol for configuring redistribute information. - type: str - choices: - - ospf - - ospfv3 - - eigrp - - isis - - static - - connected - - lisp - - mobile - - rip - - subscriber - required: true - id: - description: - - Identifier for the routing protocol for configuring redistribute - information. - - Valid for protocols 'ospf', 'eigrp', 'isis' and 'ospfv3'. - type: str - metric: - description: - - Specifies the metric for redistributed routes. - type: int - route_map: - description: - - Specifies the route map reference. - type: str - networks: - description: - - Specify networks to announce via BGP. - - For operation replace, this option is mutually exclusive with root level - networks option. - type: list - elements: dict - suboptions: - network: - description: - - Network ID to announce via BGP. - required: true - aliases: - - prefix - type: str - masklen: - description: - - Subnet mask length for the network to announce(e.g, 8, 16, 24, etc.). - type: int - required: true - route_map: - description: - - Route map to modify the attributes. - type: str - operation: - description: - - Specifies the operation to be performed on the BGP process configured on the - device. - - In case of merge, the input configuration will be merged with the existing BGP - configuration on the device. - - In case of replace, if there is a diff between the existing configuration and - the input configuration, the existing configuration will be replaced by the - input configuration for every option that has the diff. - - In case of override, all the existing BGP configuration will be removed from - the device and replaced with the input configuration. - - In case of delete the existing BGP configuration will be removed from the device. - default: merge - type: str - choices: - - merge - - replace - - override - - delete -""" - -EXAMPLES = """ -- name: configure global bgp as 65000 - cisco.iosxr.iosxr_bgp: - bgp_as: 65000 - router_id: 1.1.1.1 - neighbors: - - neighbor: 182.168.10.1 - remote_as: 500 - description: PEER_1 - - neighbor: 192.168.20.1 - remote_as: 500 - update_source: GigabitEthernet 0/0/0/0 - address_family: - - name: ipv4 - cast: unicast - networks: - - network: 192.168.2.0/23 - - network: 10.0.0.0/8 - redistribute: - - protocol: ospf - id: 400 - metric: 110 - -- name: remove bgp as 65000 from config - ios_bgp: - bgp_as: 65000 - state: absent -""" - -RETURN = """ -commands: - description: The list of configuration mode commands to send to the device - returned: always - type: list - sample: - - router bgp 65000 - - bgp router-id 1.1.1.1 - - neighbor 182.168.10.1 remote-as 500 - - neighbor 182.168.10.1 description PEER_1 - - neighbor 192.168.20.1 remote-as 500 - - neighbor 192.168.20.1 update-source GigabitEthernet0/0/0/0 - - address-family ipv4 unicast - - redistribute ospf 400 metric 110 - - network 192.168.2.0/23 - - network 10.0.0.0/8 - - exit -""" -from ansible.module_utils._text import to_text - -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.cli.config.bgp.process import ( - REDISTRIBUTE_PROTOCOLS, -) -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.providers.module import ( - NetworkModule, -) - - -def main(): - """main entry point for module execution""" - network_spec = { - "network": dict(aliases=["prefix"], required=True), - "masklen": dict(type="int", required=True), - "route_map": dict(), - } - - redistribute_spec = { - "protocol": dict(choices=REDISTRIBUTE_PROTOCOLS, required=True), - "id": dict(), - "metric": dict(type="int"), - "route_map": dict(), - } - - timer_spec = { - "keepalive": dict(type="int"), - "holdtime": dict(type="int"), - "min_neighbor_holdtime": dict(type="int"), - } - - neighbor_spec = { - "neighbor": dict(required=True), - "remote_as": dict(type="int", required=True), - "update_source": dict(), - "password": dict(no_log=True), - "enabled": dict(type="bool"), - "description": dict(), - "advertisement_interval": dict(type="int"), - "ebgp_multihop": dict(type="int"), - "tcp_mss": dict(type="int"), - "timers": dict(type="dict", options=timer_spec), - } - - address_family_spec = { - "afi": dict(choices=["ipv4", "ipv6"], required=True), - "safi": dict( - choices=["flowspec", "labeled-unicast", "multicast", "unicast"], - default="unicast", - ), - "networks": dict(type="list", elements="dict", options=network_spec), - "redistribute": dict( - type="list", - elements="dict", - options=redistribute_spec, - ), - } - - config_spec = { - "bgp_as": dict(type="int", required=True), - "router_id": dict(), - "log_neighbor_changes": dict(type="bool"), - "neighbors": dict(type="list", elements="dict", options=neighbor_spec), - "address_family": dict( - type="list", - elements="dict", - options=address_family_spec, - ), - } - - argument_spec = { - "config": dict(type="dict", options=config_spec), - "operation": dict( - default="merge", - choices=["merge", "replace", "override", "delete"], - ), - } - - module = NetworkModule( - argument_spec=argument_spec, - supports_check_mode=True, - ) - - try: - result = module.edit_config(config_filter="router bgp") - except Exception as exc: - module.fail_json(msg=to_text(exc)) - - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_address_family.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_address_family.py index 3010a2f7f..b0cf5a8c7 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_address_family.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_address_family.py @@ -492,17 +492,17 @@ EXAMPLES = """ cisco.iosxr.iosxr_bgp_address_family: state: merged config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -597,10 +597,10 @@ EXAMPLES = """ cisco.iosxr.iosxr_bgp_address_family: state: replaced config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 10 # Task output @@ -674,10 +674,10 @@ EXAMPLES = """ cisco.iosxr.iosxr_bgp_address_family: state: overridden config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 10 @@ -768,17 +768,17 @@ EXAMPLES = """ cisco.iosxr.iosxr_bgp_address_family: state: rendered config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -808,21 +808,21 @@ EXAMPLES = """ # # Using gathered # ------------- -- name: Merge the provided configuration with the existing running configuration +- name: Gather existing running configuration cisco.iosxr.iosxr_bgp_address_family: state: gathered config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -860,8 +860,8 @@ EXAMPLES = """ # # Using parsed # -#parsed.cfg -#------------ +# parsed.cfg +# ------------ # router bgp 65536 # bgp router-id 192.0.1.1 # address-family ipv4 unicast diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_global.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_global.py index bddd8789a..fe444a9ea 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_global.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_global.py @@ -559,6 +559,23 @@ options: inheritance_disable: description: Prevent local AS from being inherited from parent. type: bool + no_prepend: + description: Do not prepend local AS to announcements from this neighbor. + type: dict + suboptions: + set: + type: bool + description: Do not prepend local AS to announcements from this neighbor. + replace_as: + type: dict + description: Prepend only local AS to announcements to this neighbor. + suboptions: + set: + type: bool + description: Prepend only local AS to announcements to this neighbor. + dual_as: + type: bool + description: Dual-AS mode. log: description: Logging update messages per neighbor. type: dict @@ -604,6 +621,16 @@ options: disable: description: Disable RPKI origin-AS validation. type: bool + password: + type: dict + description: Set a password. + suboptions: + encrypted: + type: str + description: Specifies an ENCRYPTED password will follow. + inheritance_disable: + description: Prevent password from being inherited from parent. + type: bool receive_buffer_size: description: Set socket and BGP receive buffer size.Example <512-131072>. type: int @@ -697,6 +724,16 @@ options: update_source: description: Source of routing updates.Refer vendor document for valid values. type: str + use: + description: Use a neighbor-group and session-group template. + type: dict + suboptions: + neighbor_group: + description: Inherit configuration from a neighbor-group. + type: str + session_group: + description: Inherit address-family independent config from a session-group + type: str nsr: description: Enable non-stop-routing support for all neighbors. type: dict @@ -893,73 +930,98 @@ options: description: - The state the configuration should be left in. type: str - choices: [deleted, merged, replaced, gathered, rendered, parsed, purged] + choices: [deleted, merged, replaced, gathered, rendered, parsed, purged, overridden] default: merged """ EXAMPLES = """ -##### Using Merged ########################################## ------------------------------------------------------------------ - -# configuration on device Before merge state: - - -#RP/0/0/CPU0:10#show running-config router bgp -#Thu Feb 4 09:38:36.245 UTC -#% No such configuration item(s) -#RP/0/0/CPU0:10# - -# --------------Merge state--------------- -# - name: Merge the following configuration -# cisco.iosxr.iosxr_bgp_global: -# config: -# as_number: 65536 -# default_metric: 5 -# socket: -# receive_buffer_size: 514 -# send_buffer_size: 4098 -# bgp: -# confederation: -# identifier: 4 -# bestpath: -# med: -# confed: True -# cluster_id: 5 -# router_id: 192.0.2.10 -# neighbors: -# - neighbor: 192.0.2.13 -# remote_as: 65538 -# bfd: -# fast_detect: -# strict_mode: True -# multiplier: 6 -# minimum_interval: 20 -# vrfs: -# - vrf: vrf1 -# default_metric: 5 -# ---------------------------------------- +# Using merged # +# Before state +# ------------ +# RP/0/0/CPU0:10#show running-config router bgp +# Thu Feb 4 09:38:36.245 UTC +# % No such configuration item(s) +# RP/0/0/CPU0:10# +- name: Merge the following BGP global configuration + cisco.iosxr.iosxr_bgp_global: + config: + as_number: 65536 + default_metric: 5 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.13 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 +# +# Task Output: +# --------------- +# +# before: {} # commands: -# - "router bgp 65536", -# - "bgp cluster-id 5", -# - "bgp router-id 192.0.2.10", -# - "bgp bestpath med confed", -# - "bgp confederation identifier 4", -# - "default-metric 5", -# - "socket receive-buffer-size 514", -# - "socket send-buffer-size 4098", -# - "neighbor 192.0.2.13", -# - "bfd fast-detect strict-mode", -# - "bfd minimum-interval 20", -# - "bfd multiplier 6", -# - "remote-as 65538", -# - "vrf vrf1", -# - "default-metric 5" - -# Configuration on device After Merge state: -# -------------------------------------------- +# - router bgp 65536 +# - bgp cluster-id 5 +# - bgp router-id 192.0.2.10 +# - bgp bestpath med confed +# - bgp confederation identifier 4 +# - default-metric 5 +# - socket receive-buffer-size 514 +# - socket send-buffer-size 4098 +# - neighbor 192.0.2.13 +# - bfd fast-detect strict-mode +# - bfd minimum-interval 20 +# - bfd multiplier 6 +# - remote-as 65538 +# - vrf vrf1 +# - default-metric 5 +# +# after: +# as_number: '65536' +# bgp: +# bestpath: +# med: +# confed: true +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 +# default_metric: 5 +# neighbors: +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.13 +# remote_as: 65538 +# socket: +# receive_buffer_size: 514 +# send_buffer_size: 4098 +# vrfs: +# - default_metric: 5 +# vrf: vrf1 +# +# After state +# ----------- # RP/0/0/CPU0:10#show running-config router bgp # Thu Feb 4 09:44:32.480 UTC @@ -982,10 +1044,10 @@ EXAMPLES = """ # ! # ! -##### Using replaced ########################################### - -# configuration on device before replaced -# -------------------------------------------- +# Using replaced +# +# Before state +# ------------ # # RP/0/0/CPU0:10#show running-config router bgp # Thu Feb 4 09:44:32.480 UTC @@ -1007,49 +1069,105 @@ EXAMPLES = """ # default-metric 5 # ! # ! -# --------------Replace state--------------- -# - name: Replace the following configuration -# cisco.iosxr.iosxr_bgp_global: -# state: replaced -# config: -# as_number: 65536 -# default_metric: 4 -# socket: -# receive_buffer_size: 514 -# send_buffer_size: 4098 -# bgp: -# confederation: -# identifier: 4 -# bestpath: -# med: -# confed: True -# cluster_id: 5 -# router_id: 192.0.2.10 -# neighbors: -# - neighbor: 192.0.2.14 -# remote_as: 65538 -# bfd: -# fast_detect: -# strict_mode: True -# multiplier: 6 -# minimum_interval: 20 -# vrfs: -# - vrf: vrf1 -# default_metric: 5 -# ------------------------------------------- -# commands: -# - "router bgp 65536", -# - "default-metric 4", -# - "neighbor 192.0.2.14", -# - "bfd fast-detect strict-mode", -# - "bfd minimum-interval 20", -# - "bfd multiplier 6", -# - "remote-as 65538", -# - "no neighbor 192.0.2.13" -# configuration on device After Replaced state: -# ---------------------------------------------- +- name: Replace the following configuration + cisco.iosxr.iosxr_bgp_global: + state: replaced + config: + as_number: 65536 + default_metric: 4 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.14 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 +# +# Task Output: +# ------------- +# +# before: +# as_number: '65536' +# bgp: +# bestpath: +# med: +# confed: true +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 +# default_metric: 5 +# neighbors: +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.13 +# remote_as: 65538 +# socket: +# receive_buffer_size: 514 +# send_buffer_size: 4098 +# vrfs: +# - default_metric: 5 +# vrf: vrf1 +# +# commands: +# - router bgp 65536 +# - default-metric 4 +# - neighbor 192.0.2.14 +# - bfd fast-detect strict-mode +# - bfd minimum-interval 20 +# - bfd multiplier 6 +# - remote-as 65538 +# - no neighbor 192.0.2.13 +# +# after: +# as_number: '65536' +# bgp: +# bestpath: +# med: +# confed: true +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 +# default_metric: 4 +# neighbors: +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.14 +# remote_as: 65538 +# socket: +# receive_buffer_size: 514 +# send_buffer_size: 4098 +# vrfs: +# - default_metric: 5 +# vrf: vrf1 +# +# After state +# ----------- +# # RP/0/0/CPU0:10#show running-config router bgp # Thu Feb 4 09:54:11.161 UTC # router bgp 65536 @@ -1071,11 +1189,154 @@ EXAMPLES = """ # ! # ! +# Using overridden +# +# Before state +# ------------ +# +# RP/0/0/CPU0:10#show running-config router bgp +# Thu Feb 4 09:44:32.480 UTC +# router bgp 65536 +# bgp confederation identifier 4 +# bgp router-id 192.0.2.10 +# bgp cluster-id 5 +# default-metric 5 +# socket send-buffer-size 4098 +# bgp bestpath med confed +# socket receive-buffer-size 514 +# neighbor 192.0.2.13 +# remote-as 65538 +# bfd fast-detect strict-mode +# bfd multiplier 6 +# bfd minimum-interval 20 +# ! +# vrf vrf1 +# default-metric 5 +# ! +# ! -##### Using deleted ############################################ +- name: Override running config with provided configuration + cisco.iosxr.iosxr_bgp_global: + state: overridden + config: + as_number: 65536 + default_metric: 4 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.14 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 +# +# Task Output: +# ------------- +# +# before: +# as_number: '65536' +# bgp: +# bestpath: +# med: +# confed: true +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 +# default_metric: 5 +# neighbors: +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.13 +# remote_as: 65538 +# socket: +# receive_buffer_size: 514 +# send_buffer_size: 4098 +# vrfs: +# - default_metric: 5 +# vrf: vrf1 +# +# commands: +# - router bgp 65536 +# - default-metric 4 +# - neighbor 192.0.2.14 +# - bfd fast-detect strict-mode +# - bfd minimum-interval 20 +# - bfd multiplier 6 +# - remote-as 65538 +# - no neighbor 192.0.2.13 +# +# after: +# as_number: '65536' +# bgp: +# bestpath: +# med: +# confed: true +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 +# default_metric: 4 +# neighbors: +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.14 +# remote_as: 65538 +# socket: +# receive_buffer_size: 514 +# send_buffer_size: 4098 +# vrfs: +# - default_metric: 5 +# vrf: vrf1 + +# After state +# ----------- +# +# RP/0/0/CPU0:10#show running-config router bgp +# Thu Feb 4 09:54:11.161 UTC +# router bgp 65536 +# bgp confederation identifier 4 +# bgp router-id 192.0.2.10 +# bgp cluster-id 5 +# default-metric 4 +# socket send-buffer-size 4098 +# bgp bestpath med confed +# socket receive-buffer-size 514 +# neighbor 192.0.2.14 +# remote-as 65538 +# bfd fast-detect strict-mode +# bfd multiplier 6 +# bfd minimum-interval 20 +# ! +# vrf vrf1 +# default-metric 5 +# ! +# ! -# configuration on device Before deleted state -# --------------------------------------------- +# Using deleted +# +# Before state +# ------------ # # RP/0/0/CPU0:10#show running-config router bgp # Thu Feb 4 09:54:11.161 UTC @@ -1098,27 +1359,60 @@ EXAMPLES = """ # ! # ! # -# -------------------------------------------------------- -# - name: Delete BGP configurations handled by this module -# cisco.iosxr.iosxr_bgp_global: -# state: deleted -# config: -# as_number: 65536 + +- name: Delete BGP configurations handled by this module + cisco.iosxr.iosxr_bgp_global: + config: + as_number: 65536 + state: deleted + +# +# Task Output: +# ------------- +# +# before: +# as_number: '65536' +# bgp: +# bestpath: +# med: +# confed: true +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 +# default_metric: 4 +# neighbors: +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.14 +# remote_as: 65538 +# socket: +# receive_buffer_size: 514 +# send_buffer_size: 4098 +# vrfs: +# - default_metric: 5 +# vrf: vrf1 # # commands: -# "router bgp 65536", -# "no bgp cluster-id 5", -# "no bgp router-id 192.0.2.10", -# "no bgp bestpath med confed", -# "no bgp confederation identifier 4", -# "no default-metric 4", -# "no socket receive-buffer-size 514", -# "no socket send-buffer-size 4098", -# "no neighbor 192.0.2.14", -# "no vrf vrf1" +# - router bgp 65536 +# - no bgp cluster-id 5 +# - no bgp router-id 192.0.2.10 +# - no bgp bestpath med confed +# - no bgp confederation identifier 4 +# - no default-metric 4 +# - no socket receive-buffer-size 514 +# - no socket send-buffer-size 4098 +# - no neighbor 192.0.2.14 +# - no vrf vrf1 # -# configuration on device after delete -# ------------------------------------------- +# after: +# as_number: '65536' +# +# After state +# ----------- # # RP/0/0/CPU0:10#show running-config router bgp # Thu Feb 4 10:01:08.232 UTC @@ -1126,11 +1420,10 @@ EXAMPLES = """ # ! # - -################# Using Purged ######################################## - -# configuration on device Before Purged state -# -------------------------------------------- +# Using purged +# +# Before state +# ------------ # # RP/0/0/CPU0:10#show running-config router bgp # Thu Feb 4 09:54:11.161 UTC @@ -1138,104 +1431,138 @@ EXAMPLES = """ # bgp confederation identifier 4 # bgp router-id 192.0.2.10 # bgp cluster-id 5 -# default-metric 4 +# default-metric 5 # socket send-buffer-size 4098 # bgp bestpath med confed # socket receive-buffer-size 514 -# address-family ipv4 unicast -# neighbor 192.0.2.14 +# neighbor 192.0.2.13 # remote-as 65538 # bfd fast-detect strict-mode # bfd multiplier 6 # bfd minimum-interval 20 -# address-family ipv4 unicast # ! # vrf vrf1 # default-metric 5 # ! # ! # -# - name: Purge all BGP configurations from the device -# cisco.iosxr.iosxr_bgp_global: -# state: purged + +- name: Purge all BGP configurations from the device + cisco.iosxr.iosxr_bgp_global: + state: purged + +# +# Task Output: +# ------------- +# +# before: +# as_number: '65536' +# bgp: +# bestpath: +# med: +# confed: true +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 +# default_metric: 5 +# neighbors: +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.13 +# remote_as: 65538 +# socket: +# receive_buffer_size: 514 +# send_buffer_size: 4098 +# vrfs: +# - default_metric: 5 +# vrf: vrf1 +# +# commands: +# - no router bgp 65536 # -# commands: -# - no router bgp 65563 +# after: {} # -# configuration on device After purged state: -# --------------------------------------------- +# After state +# ----------- # -# #RP/0/0/CPU0:10#show running-config router bgp -# #Thu Feb 4 09:38:36.245 UTC -# #% No such configuration item(s) -# #RP/0/0/CPU0:10# +# RP/0/0/CPU0:10#show running-config router bgp +# Thu Feb 4 09:38:36.245 UTC +# % No such configuration item(s) +# RP/0/0/CPU0:10# # + # -# ################# Using Rendred ####################################################### +# Using Rendered +# ----------------- # -# - name: Render platform specific configuration lines (without connecting to the device) -# cisco.iosxr.iosxr_bgp_global: -# state: rendered -# config: -# as_number: 1 -# default_metric: 4 -# vrfs: -# - vrf: vrf3 -# bfd: -# minimum_interval: 20 -# multiplier: 10 -# bgp: -# fast_external_fallover: -# disable: True -# router_id: 1.2.3.4 -# auto_policy_soft_reset: -# disable: True -# #rd: -# # auto: True -# # #value: 1 -# timers: -# keepalive_time: 20 -# holdtime: 30 -# - vrf: vrf2 -# bgp: -# enforce_first_as: -# disable: True -# default_metric: 4 -# neighbors: -# - neighbor: 1.1.1.3 -# remote_as: 2 -# graceful_maintenance: -# set: True -# activate: -# #set: True -# inheritance_disable: True -# local_preference: -# value: 1 -# #inheritance_disable: True -# as_prepends: -# value: 2 -# rendered output -# ------------------------------------ -# "router bgp 1", -# "default-metric 4", -# "vrf vrf3", -# "bfd multiplier 10", -# "bfd minimum-interval 20", -# "bgp auto-policy-soft-reset disable", -# "bgp fast-external-fallover disable", -# "bgp router-id 1.2.3.4", -# "timers bgp 20 30", -# "vrf vrf2", -# "neighbor 1.1.1.3", -# "remote-as 2", -# "graceful-maintenance", -# "graceful-maintenance activate inheritance-disable", -# "graceful-maintenance local-preference 1", -# "graceful-maintenance as-prepends 2", -# "bgp enforce-first-as disable", -# "default-metric 4" +- name: >- + Render platform specific configuration lines (without connecting to the + device) + cisco.iosxr.iosxr_bgp_global: + state: rendered + config: + as_number: 1 + default_metric: 4 + vrfs: + - vrf: vrf3 + bfd: + minimum_interval: 20 + multiplier: 10 + bgp: + fast_external_fallover: + disable: true + router_id: 1.2.3.4 + auto_policy_soft_reset: + disable: true + timers: + keepalive_time: 20 + holdtime: 30 + - vrf: vrf2 + bgp: + enforce_first_as: + disable: true + default_metric: 4 + neighbors: + - neighbor: 1.1.1.3 + remote_as: 2 + graceful_maintenance: + set: true + activate: + inheritance_disable: true + local_preference: + value: 1 + as_prepends: + value: 2 + +# +# Task output +# ----------------------- +# rendered: +# - router bgp 1 +# - default-metric 4 +# - vrf vrf3 +# - bfd multiplier 10 +# - bfd minimum-interval 20 +# - bgp auto-policy-soft-reset disable +# - bgp fast-external-fallover disable +# - bgp router-id 1.2.3.4 +# - timers bgp 20 30 +# - vrf vrf2 +# - neighbor 1.1.1.3 +# - remote-as 2 +# - graceful-maintenance +# - graceful-maintenance activate inheritance-disable +# - graceful-maintenance local-preference 1 +# - graceful-maintenance as-prepends 2 +# - bgp enforce-first-as disable +# - default-metric 4 + +# Using parsed # -# ############## Using parsed ##################### # parsed.cfg # ------------ # router bgp 65536 @@ -1257,38 +1584,148 @@ EXAMPLES = """ # bfd minimum-interval 20 # ! # ! -# ------------------------------------ -# -# - name: Parse externally provided BGP config -# cisco.iosxr.iosxr_bgp_global: -# running_config: "{{ lookup('file', 'parsed.cfg') }}" -# state: parsed # -# #Task output using parsed -# as_number: "65536" + +- name: Parse externally provided BGP config + cisco.iosxr.iosxr_bgp_global: + running_config: "{{ lookup('file', 'parsed.cfg') }}" + state: parsed + +# Task output +# ----------------------- +# parsed: +# as_number: '65536' +# bgp: +# bestpath: +# med: +# confed: true +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 # default_metric: 4 +# neighbors: +# - cluster_id: '3' +# neighbor_address: 192.0.2.11 +# remote_as: 65537 +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.14 +# remote_as: 65538 # socket: # receive_buffer_size: 514 # send_buffer_size: 4098 + +# Using gathered +# +# Before state +# ------------ +# + +# RP/0/0/CPU0:10#show running-config router bgp +# Thu Feb 4 09:38:36.245 UTC +# router bgp 65536 +# bgp confederation identifier 4 +# bgp router-id 192.0.2.10 +# bgp cluster-id 5 +# default-metric 5 +# socket send-buffer-size 4098 +# bgp bestpath med confed +# socket receive-buffer-size 514 +# neighbor 192.0.2.13 +# remote-as 65538 +# bfd fast-detect strict-mode +# bfd multiplier 6 +# bfd minimum-interval 20 +# ! +# vrf vrf1 +# default-metric 5 +# ! +# ! + +- name: Gather bgp global facts + cisco.iosxr.iosxr_bgp_global: + state: gathered + +# Task Output: +# ------------ +# +# gathered: +# as_number: '65536' # bgp: -# confederation: -# identifier: 4 # bestpath: # med: # confed: true -# cluster_id: "5" -# router_id: "192.0.2.10" +# cluster_id: '5' +# confederation: +# identifier: 4 +# router_id: 192.0.2.10 +# default_metric: 5 # neighbors: -# - neighbor: 192.0.2.11 -# remote_as: 65537 -# cluster_id: "3" -# - neighbor: "192.0.2.14" -# remote_as: 65538 -# bfd: -# fast_detect: -# strict_mode: true -# multiplier: 6 -# minimum_interval: 20 +# - bfd: +# fast_detect: +# strict_mode: true +# minimum_interval: 20 +# multiplier: 6 +# neighbor_address: 192.0.2.13 +# remote_as: 65538 +# socket: +# receive_buffer_size: 514 +# send_buffer_size: 4098 +# vrfs: +# - default_metric: 5 +# vrf: vrf1 +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: dict + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: dict + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - router bgp 65536 + - bgp cluster-id 5 + - bgp router-id 192.0.2.10 + - bgp bestpath med confed + +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router bgp 1 + - default-metric 4 + - vrf vrf3 +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. """ from ansible.module_utils.basic import AnsibleModule diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_neighbor_address_family.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_neighbor_address_family.py index 85903d307..4657d771a 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_neighbor_address_family.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_neighbor_address_family.py @@ -418,16 +418,16 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true weight: 5 - neighbor_address: 192.0.2.3 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -437,8 +437,8 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.4 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -447,8 +447,8 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.5 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -600,7 +600,7 @@ EXAMPLES = """ # capability orf prefix both # default-originate -- name: Delete the provided configuration +- name: Delete the provided configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: state: deleted config: @@ -608,8 +608,8 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -703,8 +703,8 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast default_originate: set: true weight: 4 @@ -831,7 +831,7 @@ EXAMPLES = """ # capability orf prefix both # default-originate -- name: override the provided configuration +- name: override the provided configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: state: overridden config: @@ -839,8 +839,8 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -912,7 +912,9 @@ EXAMPLES = """ # neighbor 192.0.2.5 # remote-as 65540 -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_bgp_neighbor_address_family: state: rendered config: @@ -920,16 +922,16 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true weight: 5 - neighbor_address: 192.0.2.3 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -939,8 +941,8 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.4 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -949,8 +951,8 @@ EXAMPLES = """ neighbors: - neighbor_address: 192.0.2.5 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -984,8 +986,8 @@ EXAMPLES = """ # # Using parsed # -#parsed.cfg -#------------ +# parsed.cfg +# ------------ # router bgp 65536 # bgp router-id 192.0.1.1 # address-family ipv4 unicast @@ -1067,8 +1069,8 @@ EXAMPLES = """ # capability_orf_prefix: both # # -#Using Gathered -#----------------- +# Using Gathered +# ----------------- # Before state state: # ------------- # RP/0/0/CPU0:iosxr-02#show running-config router bgp @@ -1110,8 +1112,8 @@ EXAMPLES = """ # - name: Gathered the provided configuration with the existing running configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: - config: - state: gathered + config: + state: gathered # Task output @@ -1157,7 +1159,6 @@ EXAMPLES = """ # set: true # capability_orf_prefix: both # - """ from ansible.module_utils.basic import AnsibleModule diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_templates.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_templates.py new file mode 100644 index 000000000..5db2cb2ad --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_bgp_templates.py @@ -0,0 +1,1708 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" +The module file for iosxr_bgp_templates +""" + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +DOCUMENTATION = """ +module: iosxr_bgp_templates +short_description: Manages BGP templates resource module. +description: +- This module configures and manages the attributes of BGP templates on Cisco IOS-XR platforms. +version_added: 6.0.0 +author: Ashwini Mhatre (@amhatre) +notes: +- This module works with connection C(network_cli). +options: + config: + description: BGP template configurations. + type: dict + suboptions: + as_number: + description: Autonomous system number. + type: str + neighbor: + description: A list of BGP neighbor group configurations. + type: list + elements: dict + suboptions: + name: + description: Name of neighbor group. + type: str + address_family: + description: Enable address family and enter its config mode + type: list + elements: dict + suboptions: + afi: + description: address family. + type: str + choices: [ 'ipv4', 'ipv6' ] + safi: + description: Address Family modifier + type: str + choices: [ 'flowspec', 'mdt', 'multicast', 'mvpn', 'rt-filter', 'tunnel', 'unicast', 'labeled-unicast' , 'sr-policy'] + signalling: + type: dict + description: Signalling protocols to disable, BGP or LDP + suboptions: + bgp_disable: + type: bool + description: Select BGP to disable + ldp_disable: + type: bool + description: Select LDP to disable + advertise: + type: dict + description: Per neighbor advertisement options + suboptions: + local_labeled_route: + type: dict + description: Advertisement of routes with local-label + suboptions: + set: + type: bool + description: set local-labeled-route + disable: + type: bool + description: disable local-labeled-route + permanent_network: + type: bool + description: Allow permanent networks for this neighbor + aigp: + description: AIGP attribute + type: dict + suboptions: + disable: + description: Ignore AIGP attribute. + type: bool + set: + description: Set AIGP attribute. + type: bool + send_cost_community_disable: + description: send AIGP attribute. + type: bool + send_med: + description: send med options. + type: dict + suboptions: + set: + type: bool + description: set Send AIGP value in MED. + disable: + description: disable Send AIGP value in MED. + type: bool + allowas_in: + type: dict + description: Allow as-path with my AS present in it. + suboptions: + value: + type: int + description: Number of occurences of AS number 1-10. + set: + type: bool + description: set allowas_in + as_override: + type: dict + description: Override matching AS-number while sending update + suboptions: + set: + type: bool + description: set as_override + inheritance_disable: + type: bool + description: Prevent as-override from being inherited from the parent. + bestpath_origin_as_allow_invalid: + type: bool + description: Change default route selection criteria.Allow BGP origin-AS knobs. + capability_orf_prefix: + type: str + description: Advertise address prefix ORF capability to this neighbor. + choices: [ 'both', 'send', 'none', 'receive' ] + default_originate: + type: dict + description: Originate default route to this neighbor. + suboptions: + set: + type: bool + description: set default route. + route_policy: + type: str + description: Route policy to specify criteria to originate default + inheritance_disable: + type: bool + description: Prevent default-originate from being inherited from the parent. + encapsulation_type_srv6: + type: bool + description: Specify encapsulation type + long_lived_graceful_restart: + type: dict + description: Enable long lived graceful restart support. + suboptions: + capable: + type: bool + description: Treat neighbor as LLGR capable. + stale_time: + type: dict + description: Maximum time to wait before purging long-lived stale routes. + suboptions: + send: + type: int + description: max send time + accept: + type: int + description: max accept time + maximum_prefix: + type: dict + description: Maximum number of prefixes to accept from this peer. + suboptions: + max_limit: + type: int + description: maximum no. of prefix limit.<1-4294967295. + threshold_value: + type: int + description: hreshold value (%) at which to generate a warning msg <1-100>. + restart: + type: int + description: Restart time interval. + warning_only: + type: bool + description: Only give warning message when limit is exceeded. + discard_extra_paths: + description: Discard extra paths when limit is exceeded. + type: bool + multipath: + type: bool + description: Paths from this neighbor is eligible for multipath. + next_hop_self: + type: dict + description: Disable the next hop calculation for this neighbor. + suboptions: + set: + type: bool + description: set next hop self. + inheritance_disable: + type: bool + description: Prevent next_hop_self from being inherited from the parent. + next_hop_unchanged: + type: dict + description: Disable the next hop calculation for this neighbor. + suboptions: + set: + type: bool + description: set next hop unchanged. + inheritance_disable: + type: bool + description: Prevent next_hop_unchanged from being inherited from the parent. + multipath: + type: bool + description: Do not overwrite nexthop before advertising multipaths. + optimal_route_reflection_group_name: + type: str + description: Configure optimal-route-reflection group. + orf_route_policy: &orf_rp + type: str + description: Specify ORF and inbound filtering criteria.' + origin_as: + description: BGP origin-AS knobs. + type: dict + suboptions: + validation: + description: BGP origin-AS validation knobs. + type: dict + suboptions: + disable: + description: Disable RPKI origin-AS validation. + type: bool + remove_private_AS: + type: dict + description: Remove private AS number from outbound updates. + suboptions: + set: + type: bool + description: set remove private As. + inbound: + type: bool + description: Remove private AS number from inbound updates. + entire_aspath: + type: bool + description: remove only if all ASes in the path are private. + inheritance_disable: + type: bool + description: Prevent remove-private-AS from being inherited from the parent. + route_policy: + type: dict + description: Apply route policy to neighbor. + suboptions: + inbound: + type: str + description: Apply route policy to inbound routes. + outbound: + type: str + description: Apply route policy to outbound routes. + route_reflector_client: + type: dict + description: Configure a neighbor as Route Reflector client. + suboptions: + set: + type: bool + description: set route-reflector-client. + inheritance_disable: + type: bool + description: Prevent route-reflector-client from being inherited from the parent. + send_community_ebgp: + description: Send community attribute to this external neighbor. + type: dict + suboptions: + set: + type: bool + description: set send_community_ebgp. + inheritance_disable: + type: bool + description: Prevent send_community_ebgp from being inherited from the parent. + send_community_gshut_ebgp: + description: Allow the g-shut community to be sent to this external neighbor. + type: dict + suboptions: + set: + type: bool + description: set send_community_gshut_ebgp. + inheritance_disable: + type: bool + description: Prevent send_community_gshut_ebgp from being inherited from the parent. + send_extended_community_ebgp: + description: Send extended community attribute to this external neighbor. + type: dict + suboptions: + set: + type: bool + description: set send_extended_community_ebgp. + inheritance_disable: + type: bool + description: Prevent send_extended_community_ebgp from being inherited from the parent. + send_multicast_attributes: + description: Send multicast attributes to this neighbor . + type: dict + suboptions: + set: + type: bool + description: set send_multicast_attributes. + disable: + type: bool + description: Disable send multicast attributes. + soft_reconfiguration: &soft_reconfiguration + description: Per neighbor soft reconfiguration. + type: dict + suboptions: + inbound: + type: dict + description: inbound soft reconfiguration + suboptions: + set: + type: bool + description: set inbound + always: + type: bool + description: Allow inbound soft reconfiguration for this neighbor. Always use soft reconfig, even if route refresh is supported. + inheritance_disable: + type: bool + description: Prevent soft_reconfiguration from being inherited from the parent. + weight: + type: int + description: Set default weight for routes from this neighbor. + update: + type: dict + description: update + suboptions: + out_originator_loopcheck_disable: + type: bool + description: Disable originator loop check + out_originator_loopcheck_set: + type: bool + description: Set originator loop check + use: + description: Inherit configuration for this address-family from an af-group. + type: str + advertisement_interval: + description: Minimum interval between sending BGP routing updates.Example-<0-600>. + type: int + bfd: + description: Configure BFD parameters. + type: dict + suboptions: + fast_detect: + description: Enable Fast detection + type: dict + suboptions: + set: + description: set fast-detect + type: bool + disable: + description: Prevent bfd settings from being inherited from the parent. + type: bool + strict_mode: + description: Hold down neighbor session until BFD session is up + type: bool + minimum_interval: + description: Specifies the BFD session's minimum-interval value for the neighbor. + type: int + multiplier: + description: Specifies the BFD session's multiplier value for the neighbor. + type: int + bmp_activate: + description: Enable BMP logging for this neighbor. + type: dict + suboptions: + server: + description: Enable BMP connection to particular server.Example-<1-8>. + type: int + capability: + description: Advertise capability to the peer. + type: dict + suboptions: + additional_paths: + description: BGP additional-paths commands. + type: dict + suboptions: + send: + type: dict + description: Additional paths Send capability + suboptions: + set: + type: bool + description: set send capability + disable: + type: bool + description: set send capability + receive: + type: dict + description: Additional paths receive capability + suboptions: + set: + type: bool + description: set receive capability + disable: + type: bool + description: set receive capability + suppress: + description: Suppress advertising capability to the peer. + type: dict + suboptions: + four_byte_AS: + description: 4-byte-as capability + type: dict + suboptions: + set: + description: set 4_byte_as. + type: bool + + all: + description: all capability + type: dict + suboptions: + inheritance_disable: + description: Do not inherit this configuration from parent group. + type: bool + set: + description: set all. + type: bool + cluster_id: + description: Cluster ID of this router acting as a route reflector. + type: str + description: + description: Neighbor specific description. + type: str + dmz_link_bandwidth: + description: Propagate the DMZ link bandwidth. + type: dict + suboptions: + inheritance_disable: + description: Do not inherit this configuration from parent group. + type: bool + set: + description: set dmz-link-bandwidth. + type: bool + dscp: + description: Set IP DSCP (DiffServ CodePoint).Please refer vendor document for valid entries. + type: str + ebgp_multihop: + description: Allow EBGP neighbors not on directly connected networks. + type: dict + suboptions: + value: + description: maximum hop count.Example-<1-255>. + type: int + mpls: + description: Disable BGP MPLS forwarding. + type: bool + ebgp_recv_extcommunity_dmz: + description: Receive extcommunity dmz link bandwidth from ebgp neighbor. + type: dict + suboptions: + inheritance_disable: + description: Prevent ebgp-recv-community-dmz from being inherited from parent + type: bool + set: + description: set ebgp-recv-community-dmz. + type: bool + ebgp_send_extcommunity_dmz: + description: Send extcommunity dmz link bandwidth from ebgp neighbor. + type: dict + suboptions: + inheritance_disable: + description: Prevent ebgp-send-community-dmz from being inherited from parent + type: bool + cumulatie: + description: Send cumulative community dmz link bandwidth of all multipaths to ebgp neighbor. + type: bool + set: + description: set ebgp-send-community-dmz. + type: bool + egress_engineering: + type: dict + description: Enable egress peer engineering for this neighbor. + suboptions: + inheritance_disable: + description: Prevent egress-engineering from being inherited from parent + type: bool + set: + description: set egress-engineering. + type: bool + enforce_first_as: + description: Enforce the first AS for EBGP routes + type: dict + suboptions: + disable: + description: disable enforce 1st as + type: bool + graceful_maintenance: + description: + Attributes for Graceful Maintenance. This will cause neighbors to de-prefer routes from this router and + choose alternates. This allows the router to be brought in or out of service gracefully. + type: dict + suboptions: + set: + description: set graceful maintenance. + type: bool + activate: + description: Routes will be announced with the graceful maintenance attributes while activated either here or under router + bgp configuration. + type: dict + suboptions: + inheritance_disable: + description: Prevent activate from being inherited from the parent. + type: bool + set: + description: activate. + type: bool + as_prepends: + description: Number of times to prepend the local AS number to the + AS path of routes. Default=0 + type: dict + suboptions: + inheritance_disable: + description: Prevent as prepends from being inherited from the parent. + type: bool + value: + description: Range of values for as prepends.Example-<0-6> . + type: int + local_preference: + description: local preference with which to advertise routes to ibgp neigbors. Default=No Touch + type: dict + suboptions: + value: + description: Range of values for Local Preference.Example-<0-4294967295> . + type: int + inheritance_disable: + description: Prevent local preference from being inherited from the parent. + type: bool + graceful_restart: + description: Enable graceful restart support for this neighbor. + type: dict + suboptions: + restart_time: + description: Restart time advertised to neighbors in seconds <1-4095>. + type: int + stalepath_time: + description: Maximum time to wait for restart of GR capable peers in seconds <1-4095>. + type: int + ignore_connected_check: + description: Bypass the directly connected nexthop check for single-hop eBGP peering + type: dict + suboptions: + inheritance_disable: + description: Prevent ignore-connected-check from being inherited from the parent + type: bool + set: + description: set ignore-connected-check. + type: bool + idle_watch_time: + type: int + description: Maximum time to wait for deletion of IDLE state dynamic peer. + internal_vpn_client: + type: bool + description: Preserve iBGP CE neighbor path in ATTR_SET across VPN core. + keychain: + description: Set keychain based authentication. + type: dict + suboptions: + name: + description: Name of the key chain - maximum 32 characters. + type: str + inheritance_disable: + description: Prevent keychain from being inherited from parent. + type: bool + local: + type: dict + description: Configure local parameter + suboptions: + address: + description: IPv4 address + type: dict + suboptions: + ipv4_address: + description: IPv4 address <A.B.C.D>. + type: str + inheritance_disable: + description: Prevent local address from being inherited from parent. + type: bool + local_as: + description: Specify local AS number. + type: dict + suboptions: + value: + description: 2 byte, 4 byte As number + type: int + no_prepend: + description: Do not prepend local AS to announcements from this neighbor. + type: dict + suboptions: + set: + type: bool + description: Do not prepend local AS to announcements from this neighbor. + replace_as: + type: dict + description: Prepend only local AS to announcements to this neighbor. + suboptions: + set: + type: bool + description: Prepend only local AS to announcements to this neighbor. + dual_as: + type: bool + description: Dual-AS mode. + inheritance_disable: + description: Prevent local AS from being inherited from parent. + type: bool + local_address_subnet: + type: str + description: Local address subnet of routing updates + log: + description: Logging update messages per neighbor. + type: dict + suboptions: + log_message: + description: Logging update/notification messages per neighbor. + type: dict + suboptions: + in: + description: Inbound log messages + type: dict + suboptions: + value: + description: Range for message log buffer size <1-100>. + type: int + disable: + description: Disable inbound message logging. + type: bool + inheritance_disable: + description: Prevents the msg log from being inherited from the parent. + type: bool + out: + description: Outbound log messages + type: dict + suboptions: + value: + description: Range for message log buffer size <1-100>. + type: int + disable: + description: Disable inbound message logging. + type: bool + inheritance_disable: + description: Prevents the msg log from being inherited from the parent. + type: bool + maximum_peers: + type: int + description: Maximum dynamic neighbors <1-4095>. + password: + type: dict + description: Set a password. + suboptions: + encrypted: + type: str + description: Specifies an ENCRYPTED password will follow. + inheritance_disable: + description: Prevent password from being inherited from parent. + type: bool + peer_set: + type: int + description: Assign this neighbor to a peer-set used for egress peer engineering <1-255>. + precedence: + type: str + choices: ["critical", "flash", "flash-override", "immediate", "internet", "network", "priority","routine"] + description: Set precedence + receive_buffer_size: + description: Set socket and BGP receive buffer size.Example <512-131072>. + type: int + remote_as: + description: Neighbor Autonomous System. + type: int + remote_as_list: + description: Remote as-list configuration + type: str + send_buffer_size: + description: Set socket and BGP send buffer size.Example <4096-131072>. + type: int + session_open_mode: + description: Establish BGP session using this TCP open mode. + type: str + choices: [ 'active-only', 'both', 'passive-only' ] + shutdown: + description: Administratively shut down this neighbor. + type: dict + suboptions: + inheritance_disable: + description: Prevent shutdown from being inherited from parent + type: bool + set: + description: shutdown. + type: bool + tcp: + description: TCP session configuration commands. + type: dict + suboptions: + mss: + description: Maximum Segment Size. + type: dict + suboptions: + value: + description: TCP initial maximum segment size. + type: int + inheritance_disable: + description: Prevent mss from being inherited from parent + type: bool + timers: + description: BGP per neighbor timers. + type: dict + suboptions: + keepalive_time: + description: keepalive interval <0-65535>. + type: int + holdtime: + description: hold time <3-65535> or 0 Disable hold time. + type: int + min_holdtime: + description: Minimum acceptable holdtime from neighbor <3-65535>. + type: int + ttl_security: + description: Enable EBGP TTL security. + type: dict + suboptions: + inheritance_disable: + description: Prevent ttl-security from being inherited from parent + type: bool + set: + description: set ttl-security + type: bool + update: + description: BGP Update configuration. + type: dict + suboptions: + in: + description: Inbound update message handling. + type: dict + suboptions: + filtering: + description: Inbound update message filtering + type: dict + suboptions: + attribute_filter: + description: Attribute-filter configuration. + type: dict + suboptions: + group: + description: Name of group. + type: str + logging: + description: Update filtering syslog message. + type: dict + suboptions: + disable: + description: Disable update filtering syslog message. + type: bool + update_message: + description: Filtered update messages. + type: dict + suboptions: + buffers: + description: Number of buffers to store filtered update messages. + type: int + update_source: + description: Source of routing updates.Refer vendor document for valid values. + type: str + use: + description: Use a neighbor-group and session-group template. + type: dict + suboptions: + neighbor_group: + description: Inherit configuration from a neighbor-group. + type: str + session_group: + description: Inherit address-family independent config from a session-group + type: str + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the Iosxr device by + executing the command B(show running-config router bgp). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. + type: str + state: + description: + - The state the configuration should be left in. + type: str + choices: [deleted, merged, overridden, replaced, gathered, rendered, parsed] + default: merged +""" + +EXAMPLES = """ +# Using merged +# Before state: +# ------------- +# RP/0/RP0/CPU0:10#show running-config router bgp +# Thu Mar 23 10:00:12.668 UTC +# % No such configuration item(s) +# +# RP/0/RP0/CPU0:10# + +- name: Merge the provided configuration with the existing running configuration + cisco.iosxr.iosxr_bgp_templates: + config: + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + set: true + afi: ipv4 + safi: unicast + advertisement_interval: 10 + bfd: + fast_detect: + strict_mode: true + internal_vpn_client: true + name: neighbor-group1 + precedence: critical + - cluster_id: '1' + description: neighbor-group2 + dmz_link_bandwidth: + set: true + ebgp_multihop: + value: 255 + egress_engineering: + set: true + graceful_maintenance: + as_prepends: + value: 0 + set: true + ignore_connected_check: + set: true + internal_vpn_client: true + local: + address: + inheritance_disable: true + local_as: + value: 6 + name: neighbor-group2 + precedence: flash + receive_buffer_size: 512 + send_buffer_size: 4096 + session_open_mode: both + tcp: + mss: + inheritance_disable: true + ttl_security: + set: true + update_source: Loopback919 + state: merged + +# Task Output +# ----------- +# before: {} +# commands: +# - router bgp 65536 +# - neighbor-group neighbor-group1 +# - advertisement-interval 10 +# - bfd fast-detect strict-mode +# - internal-vpn-client +# - precedence critical +# - address-family ipv4 unicast +# - advertise local-labeled-route +# - neighbor-group neighbor-group2 +# - dmz-link-bandwidth +# - description neighbor-group2 +# - cluster-id 1 +# - ebgp-multihop 255 +# - egress-engineering +# - internal-vpn-client +# - ignore-connected-check +# - local-as 6 +# - local address inheritance-disable +# - precedence flash +# - receive-buffer-size 512 +# - send-buffer-size 4096 +# - session-open-mode both +# - tcp mss inheritance-disable +# - update-source Loopback919 +# - ttl-security +# - graceful-maintenance +# - graceful-maintenance as-prepends 0 +# after: +# as_number: '65536' +# neighbor: +# - address_family: +# - advertise: +# local_labeled_route: +# set: true +# afi: ipv4 +# safi: unicast +# advertisement_interval: 10 +# bfd: +# fast_detect: +# strict_mode: true +# internal_vpn_client: true +# name: neighbor-group1 +# precedence: critical +# - cluster_id: '1' +# description: neighbor-group2 +# dmz_link_bandwidth: +# set: true +# ebgp_multihop: +# value: 255 +# egress_engineering: +# set: true +# graceful_maintenance: +# as_prepends: +# value: 0 +# set: true +# ignore_connected_check: +# set: true +# internal_vpn_client: true +# local: +# address: +# inheritance_disable: true +# local_as: +# value: 6 +# name: neighbor-group2 +# precedence: flash +# receive_buffer_size: 512 +# send_buffer_size: 4096 +# session_open_mode: both +# tcp: +# mss: +# inheritance_disable: true +# ttl_security: +# set: true +# update_source: Loopback919 + +# After state: +# ------------ +# RP/0/RP0/CPU0:10#show running-config router bgp +# Thu Mar 23 10:14:33.116 UTC +# router bgp 65536 +# neighbor-group neighbor-group1 +# bfd fast-detect strict-mode +# precedence critical +# advertisement-interval 10 +# internal-vpn-client +# address-family ipv4 unicast +# advertise local-labeled-route +# ! +# ! +# neighbor-group neighbor-group2 +# ebgp-multihop 255 +# egress-engineering +# precedence flash +# graceful-maintenance +# as-prepends 0 +# ! +# tcp mss inheritance-disable +# local-as 6 +# cluster-id 1 +# dmz-link-bandwidth +# description neighbor-group2 +# ttl-security +# local address inheritance-disable +# update-source Loopback919 +# ignore-connected-check +# session-open-mode both +# send-buffer-size 4096 +# receive-buffer-size 512 +# internal-vpn-client +# ! +# ! + + +# Using replaced +# Before state: +# ------------ +# RP/0/RP0/CPU0:10#show running-config router bgp +# Thu Mar 23 10:14:33.116 UTC +# router bgp 65536 +# neighbor-group neighbor-group1 +# bfd fast-detect strict-mode +# precedence critical +# advertisement-interval 10 +# internal-vpn-client +# address-family ipv4 unicast +# advertise local-labeled-route +# ! +# ! +# neighbor-group neighbor-group2 +# ebgp-multihop 255 +# egress-engineering +# precedence flash +# graceful-maintenance +# as-prepends 0 +# ! +# tcp mss inheritance-disable +# local-as 6 +# cluster-id 1 +# dmz-link-bandwidth +# description neighbor-group2 +# ttl-security +# local address inheritance-disable +# update-source Loopback919 +# ignore-connected-check +# session-open-mode both +# send-buffer-size 4096 +# receive-buffer-size 512 +# internal-vpn-client +# ! +# ! + +- name: Replaced given bgp_templates configuration + cisco.iosxr.iosxr_bgp_templates: + config: + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + set: true + afi: ipv4 + safi: unicast + advertisement_interval: 12 + name: neighbor-group1 + precedence: flash + - cluster_id: '2' + description: replace neighbor-group2 + ebgp_multihop: + value: 254 + graceful_maintenance: + as_prepends: + value: 2 + set: true + update_source: Loopback917 + name: neighbor-group2 + state: replaced + +# Task Output +# ----------- +# before: +# as_number: '65536' +# neighbor: +# - address_family: +# - advertise: +# local_labeled_route: +# set: true +# afi: ipv4 +# safi: unicast +# advertisement_interval: 10 +# bfd: +# fast_detect: +# strict_mode: true +# internal_vpn_client: true +# name: neighbor-group1 +# precedence: critical +# - cluster_id: '1' +# description: neighbor-group2 +# dmz_link_bandwidth: +# set: true +# ebgp_multihop: +# value: 255 +# egress_engineering: +# set: true +# graceful_maintenance: +# as_prepends: +# value: 0 +# set: true +# ignore_connected_check: +# set: true +# internal_vpn_client: true +# local: +# address: +# inheritance_disable: true +# local_as: +# value: 6 +# name: neighbor-group2 +# precedence: flash +# receive_buffer_size: 512 +# send_buffer_size: 4096 +# session_open_mode: both +# tcp: +# mss: +# inheritance_disable: true +# ttl_security: +# set: true +# update_source: Loopback919 +# commands: +# - router bgp 65536 +# - neighbor-group neighbor-group1 +# - no bfd fast-detect strict-mode +# - no internal-vpn-client +# - advertisement-interval 12 +# - precedence flash +# - neighbor-group neighbor-group2 +# - no dmz-link-bandwidth +# - no egress-engineering +# - no internal-vpn-client +# - no ignore-connected-check +# - no local-as 6 +# - no local address inheritance-disable +# - no precedence flash +# - no receive-buffer-size 512 +# - no send-buffer-size 4096 +# - no session-open-mode both +# - no tcp mss inheritance-disable +# - no ttl-security +# - description replace neighbor-group2 +# - cluster-id 2 +# - ebgp-multihop 254 +# - update-source Loopback917 +# - graceful-maintenance as-prepends 2 +# after: +# as_number: '65536' +# neighbor: +# - address_family: +# - advertise: +# local_labeled_route: +# set: true +# afi: ipv4 +# safi: unicast +# advertisement_interval: 12 +# name: neighbor-group1 +# precedence: flash +# - cluster_id: '2' +# description: replace neighbor-group2 +# ebgp_multihop: +# value: 254 +# graceful_maintenance: +# as_prepends: +# value: 2 +# set: true +# name: neighbor-group2 +# update_source: Loopback917 + +# After state: +# ------------ +# RP/0/RP0/CPU0:10#show running-config router bgp +# Thu Mar 23 10:23:34.104 UTC +# router bgp 65536 +# neighbor-group neighbor-group1 +# precedence flash +# advertisement-interval 12 +# address-family ipv4 unicast +# advertise local-labeled-route +# ! +# ! +# neighbor-group neighbor-group2 +# ebgp-multihop 254 +# graceful-maintenance +# as-prepends 2 +# ! +# cluster-id 2 +# description replace neighbor-group2 +# update-source Loopback917 +# ! +# ! + + +# Using deleted +# Before state: +# ------------- +# RP/0/RP0/CPU0:10#show running-config router bgp +# Thu Mar 23 10:23:34.104 UTC +# router bgp 65536 +# neighbor-group neighbor-group1 +# precedence flash +# advertisement-interval 12 +# address-family ipv4 unicast +# advertise local-labeled-route +# ! +# ! +# neighbor-group neighbor-group2 +# ebgp-multihop 254 +# graceful-maintenance +# as-prepends 2 +# ! +# cluster-id 2 +# description replace neighbor-group2 +# update-source Loopback917 +# ! +# ! + +- name: Delete given bgp_nbr_address_family configuration + cisco.iosxr.iosxr_bgp_templates: &deleted + config: + state: deleted + +# Task Output +# ----------- +# before: +# as_number: '65536' +# neighbor: +# - address_family: +# - advertise: +# local_labeled_route: +# set: true +# afi: ipv4 +# safi: unicast +# advertisement_interval: 12 +# name: neighbor-group1 +# precedence: flash +# - cluster_id: '2' +# description: replace neighbor-group2 +# ebgp_multihop: +# value: 254 +# graceful_maintenance: +# as_prepends: +# value: 2 +# set: true +# name: neighbor-group2 +# update_source: Loopback917 +# commands: +# - router bgp 65536 +# - no neighbor-group neighbor-group1 +# - no neighbor-group neighbor-group2 +# after: {} + +# After state: +# ------------- +# RP/0/RP0/CPU0:10#show running-config router bgp +# Thu Mar 23 10:00:12.668 UTC +# % No such configuration item(s) +# +# RP/0/RP0/CPU0:10# + +# Using gathered +# Before state: +# ------------- +# RP/0/RP0/CPU0:10#show running-config router bgp +# Thu Mar 23 10:30:38.785 UTC +# router bgp 65536 +# neighbor-group neighbor-group1 +# bfd fast-detect strict-mode +# precedence critical +# advertisement-interval 10 +# internal-vpn-client +# address-family ipv4 unicast +# advertise local-labeled-route +# ! +# ! +# neighbor-group neighbor-group2 +# ebgp-multihop 255 +# egress-engineering +# precedence flash +# graceful-maintenance +# as-prepends 0 +# ! +# tcp mss inheritance-disable +# local-as 6 +# cluster-id 1 +# dmz-link-bandwidth +# description neighbor-group2 +# ttl-security +# local address inheritance-disable +# update-source Loopback919 +# ignore-connected-check +# session-open-mode both +# send-buffer-size 4096 +# receive-buffer-size 512 +# internal-vpn-client +# ! +# ! + +- name: Gather given bgp_templates configuration + cisco.iosxr.iosxr_bgp_templates: &id001 + config: + state: gathered + +# Task output +# ----------- +# gathered: +# as_number: '65536' +# neighbor: +# - address_family: +# - advertise: +# local_labeled_route: +# set: true +# afi: ipv4 +# safi: unicast +# advertisement_interval: 10 +# bfd: +# fast_detect: +# strict_mode: true +# internal_vpn_client: true +# name: neighbor-group1 +# precedence: critical +# - cluster_id: '1' +# description: neighbor-group2 +# dmz_link_bandwidth: +# set: true +# ebgp_multihop: +# value: 255 +# egress_engineering: +# set: true +# graceful_maintenance: +# as_prepends: +# value: 0 +# set: true +# ignore_connected_check: +# set: true +# internal_vpn_client: true +# local: +# address: +# inheritance_disable: true +# local_as: +# value: 6 +# name: neighbor-group2 +# precedence: flash +# receive_buffer_size: 512 +# send_buffer_size: 4096 +# session_open_mode: both +# tcp: +# mss: +# inheritance_disable: true +# ttl_security: +# set: true +# update_source: Loopback919 + + +# Using overridden + +# Before state: +# ------------- +# RP/0/RP0/CPU0:10#show running-config router bgp +# Thu Mar 23 10:30:38.785 UTC +# router bgp 65536 +# neighbor-group neighbor-group1 +# bfd fast-detect strict-mode +# precedence critical +# advertisement-interval 10 +# internal-vpn-client +# address-family ipv4 unicast +# advertise local-labeled-route +# ! +# ! +# neighbor-group neighbor-group2 +# ebgp-multihop 255 +# egress-engineering +# precedence flash +# graceful-maintenance +# as-prepends 0 +# ! +# tcp mss inheritance-disable +# local-as 6 +# cluster-id 1 +# dmz-link-bandwidth +# description neighbor-group2 +# ttl-security +# local address inheritance-disable +# update-source Loopback919 +# ignore-connected-check +# session-open-mode both +# send-buffer-size 4096 +# receive-buffer-size 512 +# internal-vpn-client +# ! +# ! +- name: override given bgp_templates configuration + cisco.iosxr.iosxr_bgp_templates: + config: + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + disable: true + afi: ipv4 + safi: unicast + advertisement_interval: 12 + bfd: + fast_detect: + strict_mode: true + name: neighbor-group1 + precedence: flash + state: overridden + +# Task Output +# ----------- +# before: +# as_number: '65536' +# neighbor: +# - address_family: +# - advertise: +# local_labeled_route: +# set: true +# afi: ipv4 +# safi: unicast +# advertisement_interval: 10 +# bfd: +# fast_detect: +# strict_mode: true +# internal_vpn_client: true +# name: neighbor-group1 +# precedence: critical +# - cluster_id: '1' +# description: neighbor-group2 +# dmz_link_bandwidth: +# set: true +# ebgp_multihop: +# value: 255 +# egress_engineering: +# set: true +# graceful_maintenance: +# as_prepends: +# value: 0 +# set: true +# ignore_connected_check: +# set: true +# internal_vpn_client: true +# local: +# address: +# inheritance_disable: true +# local_as: +# value: 6 +# name: neighbor-group2 +# precedence: flash +# receive_buffer_size: 512 +# send_buffer_size: 4096 +# session_open_mode: both +# tcp: +# mss: +# inheritance_disable: true +# ttl_security: +# set: true +# update_source: Loopback919 +# commands: +# - router bgp 65536 +# - no neighbor-group neighbor-group2 +# - neighbor-group neighbor-group1 +# - no internal-vpn-client +# - advertisement-interval 12 +# - precedence flash +# - address-family ipv4 unicast +# - no advertise local-labeled-route +# - advertise local-labeled-route disable +# after: +# as_number: '65536' +# neighbor: +# - address_family: +# - advertise: +# local_labeled_route: +# disable: true +# afi: ipv4 +# safi: unicast +# advertisement_interval: 12 +# bfd: +# fast_detect: +# strict_mode: true +# name: neighbor-group1 +# precedence: flash + + +# Using rendered +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) + cisco.iosxr.iosxr_bgp_templates: + config: + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + set: true + afi: ipv4 + safi: unicast + advertisement_interval: 10 + bfd: + fast_detect: + strict_mode: true + internal_vpn_client: true + name: neighbor-group1 + precedence: critical + - cluster_id: '1' + description: neighbor-group2 + dmz_link_bandwidth: + set: true + ebgp_multihop: + value: 255 + egress_engineering: + set: true + graceful_maintenance: + as_prepends: + value: 0 + set: true + ignore_connected_check: + set: true + internal_vpn_client: true + local: + address: + inheritance_disable: true + local_as: + value: 6 + name: neighbor-group2 + precedence: flash + receive_buffer_size: 512 + send_buffer_size: 4096 + session_open_mode: both + tcp: + mss: + inheritance_disable: true + ttl_security: + set: true + update_source: Loopback919 + state: rendered + +# Task Output +# ----------- +# rendered: +# - router bgp 65536 +# - neighbor-group neighbor-group1 +# - advertisement-interval 10 +# - bfd fast-detect strict-mode +# - internal-vpn-client +# - precedence critical +# - address-family ipv4 unicast +# - advertise local-labeled-route +# - neighbor-group neighbor-group2 +# - dmz-link-bandwidth +# - description neighbor-group2 +# - cluster-id 1 +# - ebgp-multihop 255 +# - egress-engineering +# - internal-vpn-client +# - ignore-connected-check +# - local-as 6 +# - local address inheritance-disable +# - precedence flash +# - receive-buffer-size 512 +# - send-buffer-size 4096 +# - session-open-mode both +# - tcp mss inheritance-disable +# - update-source Loopback919 +# - ttl-security +# - graceful-maintenance +# - graceful-maintenance as-prepends 0 + + +# Using parsed +- name: Parse externally provided BGP configuration + register: result + cisco.iosxr.iosxr_bgp_templates: + running_config: "{{ lookup('file', 'parsed.cfg') }}" + state: parsed + +# content of pared.cfg +# router bgp 65536 +# neighbor-group neighbor-group1 +# bfd fast-detect strict-mode +# precedence critical +# advertisement-interval 10 +# internal-vpn-client +# address-family ipv4 unicast +# advertise local-labeled-route +# ! +# ! +# neighbor-group neighbor-group2 +# ebgp-multihop 255 +# egress-engineering +# precedence flash +# graceful-maintenance +# as-prepends 0 +# ! +# tcp mss inheritance-disable +# local-as 6 +# cluster-id 1 +# dmz-link-bandwidth +# description neighbor-group2 +# ttl-security +# local address inheritance-disable +# update-source Loopback919 +# idle-watch-time 30 +# ignore-connected-check +# session-open-mode both +# send-buffer-size 4096 +# receive-buffer-size 512 +# internal-vpn-client +# ! +# ! +# Task output +# ----------- +# parsed: +# as_number: '65536' +# neighbor: +# - address_family: +# - advertise: +# local_labeled_route: +# set: true +# afi: ipv4 +# safi: unicast +# advertisement_interval: 10 +# bfd: +# fast_detect: +# strict_mode: true +# internal_vpn_client: true +# name: neighbor-group1 +# precedence: critical +# - cluster_id: '1' +# description: neighbor-group2 +# dmz_link_bandwidth: +# set: true +# ebgp_multihop: +# value: 255 +# egress_engineering: +# set: true +# graceful_maintenance: +# as_prepends: +# value: 0 +# set: true +# ignore_connected_check: +# set: true +# internal_vpn_client: true +# local: +# address: +# inheritance_disable: true +# local_as: +# value: 6 +# name: neighbor-group2 +# precedence: flash +# receive_buffer_size: 512 +# send_buffer_size: 4096 +# session_open_mode: both +# tcp: +# mss: +# inheritance_disable: true +# ttl_security: +# set: true +# update_source: Loopback919 +""" + +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - router bgp 65536 + - neighbor-group neighbor-group1 + - advertisement-interval 10 + - bfd fast-detect strict-mode + - internal-vpn-client +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router bgp 65536 + - neighbor-group neighbor-group1 + - advertisement-interval 10 + - bfd fast-detect strict-mode + - internal-vpn-client +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. +""" + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.bgp_templates.bgp_templates import ( + Bgp_templatesArgs, +) +from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.bgp_templates.bgp_templates import ( + Bgp_templates, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule( + argument_spec=Bgp_templatesArgs.argument_spec, + mutually_exclusive=[["config", "running_config"]], + required_if=[ + ["state", "merged", ["config"]], + ["state", "replaced", ["config"]], + ["state", "overridden", ["config"]], + ["state", "rendered", ["config"]], + ["state", "parsed", ["running_config"]], + ], + supports_check_mode=True, + ) + + result = Bgp_templates(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_command.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_command.py index 5838de0da..814ee5d68 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_command.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_command.py @@ -88,32 +88,32 @@ EXAMPLES = """ - name: run multiple commands on remote nodes cisco.iosxr.iosxr_command: commands: - - show version - - show interfaces - - {command: example command that prompts, prompt: expected prompt, answer: yes} + - show version + - show interfaces + - {command: example command that prompts, prompt: expected prompt, answer: true} - name: run multiple commands and evaluate the output cisco.iosxr.iosxr_command: commands: - - show version - - show interfaces + - show version + - show interfaces wait_for: - - result[0] contains IOS-XR - - result[1] contains Loopback0 + - result[0] contains IOS-XR + - result[1] contains Loopback0 -- name: multiple prompt, multiple answer (mandatory check for all prompts) +- name: 'multiple prompt, multiple answer (mandatory check for all prompts)' cisco.iosxr.iosxr_command: commands: - - command: key config-key password-encryption - prompt: - - "Enter old key :" - - "Enter new key :" - - "Enter confirm key :" - answer: - - "test1234" - - "test12345" - - "test12345" - check_all: true + - command: key config-key password-encryption + prompt: + - 'Enter old key :' + - 'Enter new key :' + - 'Enter confirm key :' + answer: + - test1234 + - test12345 + - test12345 + check_all: true """ RETURN = """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py index f723b5697..7fc59fefa 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_config.py @@ -21,10 +21,11 @@ version_added: 1.0.0 extends_documentation_fragment: - cisco.iosxr.iosxr notes: -- This module works with connection C(network_cli). See L(the IOS-XR Platform Options,../network/user_guide/platform_iosxr.html). +- This module works with connection C(network_cli). + See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_iosxr.html) - This module does not support C(netconf) connection -- Abbreviated commands are NOT idempotent, see L(Network FAQ,../network/user_guide/faq.html - #why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands). +- Abbreviated commands are NOT idempotent, see + U(https://docs.ansible.com/ansible/latest/network/user_guide/faq.html#why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands) - Avoid service disrupting changes (viz. Management IP) from config replace. - Do not use C(end) in the replace config file. - To ensure idempotency and correct diff the configuration lines in the relevant module options should be similar to how they @@ -194,28 +195,26 @@ EXAMPLES = """ - name: configure interface settings cisco.iosxr.iosxr_config: lines: - - description test interface - - ip address 172.31.1.1 255.255.255.0 + - description test interface + - ip address 172.31.1.1 255.255.255.0 parents: interface GigabitEthernet0/0/0/0 - name: load a config from disk and replace the current config cisco.iosxr.iosxr_config: src: config.cfg replace: config - backup: yes + backup: 'yes' -- name: for idempotency, use full-form commands +- name: 'for idempotency, use full-form commands' cisco.iosxr.iosxr_config: lines: - # - shut - - shutdown - # parents: int g0/0/0/1 + - shutdown parents: interface GigabitEthernet0/0/0/1 - name: configurable backup path cisco.iosxr.iosxr_config: src: config.cfg - backup: yes + backup: true backup_options: filename: backup.cfg dir_path: /home/user @@ -227,6 +226,11 @@ commands: returned: If there are commands to run against the host type: list sample: ['hostname foo', 'router ospf 1', 'router-id 1.1.1.1'] +updates: + description: The set of commands that will be pushed to the remote device + returned: If there are commands to run against the host + type: list + sample: ['hostname foo', 'router ospf 1', 'router-id 1.1.1.1'] backup_path: description: The full path to the backup file returned: when backup is yes @@ -344,7 +348,6 @@ def run(module, result): exclusive = module.params["exclusive"] check_mode = module.check_mode label = module.params["label"] - candidate_config = get_candidate(module) running_config = get_running_config(module) @@ -392,6 +395,7 @@ def run(module, result): commands.extend(module.params["after"]) result["commands"] = commands + result["updates"] = commands commit = not check_mode diff = load_config( @@ -437,9 +441,9 @@ def main(): mutually_exclusive = [("lines", "src"), ("parents", "src")] required_if = [ - ("match", "strict", ["lines"]), - ("match", "exact", ["lines"]), - ("replace", "block", ["lines"]), + ("match", "strict", ["lines", "src"], True), + ("match", "exact", ["lines", "src"], True), + ("replace", "block", ["lines", "src"], True), ("replace", "config", ["src"]), ] diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_facts.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_facts.py index 38925b985..c406a18b7 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_facts.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_facts.py @@ -67,25 +67,25 @@ EXAMPLES = """ # Collect only the config and default facts - cisco.iosxr.iosxr_facts: gather_subset: - - config + - config # Do not collect hardware facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!hardware' + - '!hardware' # Collect only the lacp facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - lacp + - lacp # Do not collect lacp_interfaces facts - cisco.iosxr.iosxr_facts: gather_network_resources: - - '!lacp_interfaces' + - '!lacp_interfaces' # Collect lacp and minimal default facts - cisco.iosxr.iosxr_facts: @@ -95,11 +95,11 @@ EXAMPLES = """ # Collect only the interfaces facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - interfaces - - l2_interfaces + - interfaces + - l2_interfaces """ RETURN = """ @@ -147,6 +147,10 @@ ansible_net_memtotal_mb: description: The total memory on the remote device in Mb returned: when hardware is configured type: int +ansible_net_cpu_utilization: + description: The current CPU utilization of the device + returned: when hardware is configured + type: dict # config ansible_net_config: diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_hostname.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_hostname.py index a41aaf77d..7ea657a32 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_hostname.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_hostname.py @@ -71,9 +71,9 @@ EXAMPLES = """ # Before state: # ------------- -#RP/0/RP0/CPU0:ios#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC -#hostname ios +# RP/0/RP0/CPU0:ios#show running-config hostname +# Thu Jan 20 19:48:56.011 UTC +# hostname ios # Merged play: # ------------ @@ -94,7 +94,7 @@ EXAMPLES = """ # ------------ # RP/0/0/CPU0:Router1#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC +# Thu Jan 20 19:48:56.011 UTC # hostname Router1 @@ -103,7 +103,7 @@ EXAMPLES = """ # ------------- # RP/0/0/CPU0:Router1#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC +# Thu Jan 20 19:48:56.011 UTC # hostname Router1 # Deleted play: @@ -122,9 +122,9 @@ EXAMPLES = """ # After state: # ------------ -#RP/0/RP0/CPU0:ios#show running-config hostname -#Thu Jan 20 19:55:12.971 UTC -#hostname ios +# RP/0/RP0/CPU0:ios#show running-config hostname +# Thu Jan 20 19:55:12.971 UTC +# hostname ios # Using state: overridden # Before state: @@ -151,17 +151,17 @@ EXAMPLES = """ # After state: # ------------ -#RP/0/RP0/CPU0:RouterTest#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC -#hostname RouterTest +# RP/0/RP0/CPU0:RouterTest#show running-config hostname +# Thu Jan 20 19:48:56.011 UTC +# hostname RouterTest # Using state: replaced # Before state: # ------------- -#RP/0/RP0/CPU0:RouterTest#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC -#hostname RouterTest +# RP/0/RP0/CPU0:RouterTest#show running-config hostname +# Thu Jan 20 19:48:56.011 UTC +# hostname RouterTest # Replaced play: # -------------- @@ -185,9 +185,9 @@ EXAMPLES = """ # Before state: # ------------- -#RP/0/RP0/CPU0:RouterTest#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC -#hostname RouterTest +# RP/0/RP0/CPU0:RouterTest#show running-config hostname +# Thu Jan 20 19:48:56.011 UTC +# hostname RouterTest # Gathered play: # -------------- diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_interfaces.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_interfaces.py index b1c169cbc..bfa25edca 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_interfaces.py @@ -34,7 +34,10 @@ author: - Sumit Jaiswal (@justjais) - Rohit Thakur (@rohitthakur2590) notes: -- This module works with connection C(network_cli). See L(the IOS-XR Platform Options,../network/user_guide/platform_iosxr.html). +- This module works with connection C(network_cli). + See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_iosxr.html) +- The module examples uses callback plugin (stdout_callback = yaml) to generate task + output in yaml format. options: config: description: A dictionary of interface options @@ -102,221 +105,335 @@ options: EXAMPLES = """ # Using merged + # Before state: # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# vrf custB -# ipv4 address 178.18.169.23 255.255.255.0 -# dot1q native vlan 30 +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# description Replaced by Ansible Team -# mtu 2000 -# vrf custB -# ipv4 address 10.10.0.2 255.255.255.0 -# dot1q native vlan 1021 +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! + - name: Configure Ethernet interfaces cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - duplex: full + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + duplex: full state: merged + +# Task Output +# ----------- +# +# before: +# - enabled: true +# name: Loopback888 +# - enabled: true +# name: Loopback999 +# commands: +# - interface GigabitEthernet0/0/0/2 +# - description Configured by Ansible +# - no shutdown +# - interface GigabitEthernet0/0/0/3 +# - description Configured by Ansible Network +# - duplex full +# - shutdown +# after: +# - enabled: true +# name: Loopback888 +# - enabled: true +# name: Loopback999 +# - description: Configured by Ansible +# enabled: true +# name: GigabitEthernet0/0/0/2 +# - description: Configured by Ansible Network +# duplex: full +# enabled: false +# name: GigabitEthernet0/0/0/3 + # After state: # ------------ # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# description Configured and Merged by Ansible Network -# vrf custB -# ipv4 address 178.18.169.23 255.255.255.0 -# dot1q native vlan 30 +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# description Configured and Merged by Ansible Network -# mtu 2600 -# vrf custB -# ipv4 address 10.10.0.2 255.255.255.0 +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp +# ! +# interface preconfigure GigabitEthernet0/0/0/2 +# description Configured by Ansible +# ! +# interface preconfigure GigabitEthernet0/0/0/3 +# description Configured by Ansible Network # duplex full # shutdown -# dot1q native vlan 1021 # ! + # Using replaced + # Before state: # ------------ # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# description Configured by Ansible -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# description Test -# vrf custB -# ipv4 address 178.18.169.23 255.255.255.0 -# dot1q native vlan 30 +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# vrf custB -# ipv4 address 10.10.0.2 255.255.255.0 -# dot1q native vlan 1021 +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp +# ! +# interface preconfigure GigabitEthernet0/0/0/2 +# description Configured by Ansible # ! -- name: Configure following interfaces and replace their existing config +# interface preconfigure GigabitEthernet0/0/0/3 +# description Configured by Ansible Network +# duplex full +# shutdown +# ! + +- name: Replace their existing configuration per interface cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - mtu: 2000 - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - duplex: auto + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + mtu: 2000 + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + duplex: auto state: replaced + +# Task Output +# ----------- +# +# before: +# - enabled: true +# name: Loopback888 +# - enabled: true +# name: Loopback999 +# - description: Configured by Ansible +# enabled: true +# name: GigabitEthernet0/0/0/2 +# - description: Configured by Ansible Network +# duplex: full +# enabled: false +# name: GigabitEthernet0/0/0/3 +# commands: +# - interface GigabitEthernet0/0/0/2 +# - mtu 2000 +# - interface GigabitEthernet0/0/0/3 +# - duplex half +# after: +# - enabled: true +# name: Loopback888 +# - enabled: true +# name: Loopback999 +# - description: Configured by Ansible +# enabled: true +# mtu: 2000 +# name: GigabitEthernet0/0/0/2 +# - description: Configured by Ansible Network +# duplex: half +# enabled: false +# name: GigabitEthernet0/0/0/3 + # After state: # ------------ # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# description Configured by Ansible -# shutdown +# interface Loopback888 +# ! +# interface Loopback999 +# ! +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/2 -# description Configured and Replaced by Ansible +# interface preconfigure GigabitEthernet0/0/0/2 +# description Configured by Ansible # mtu 2000 -# vrf custB -# ipv4 address 178.18.169.23 255.255.255.0 -# dot1q native vlan 30 # ! -# interface GigabitEthernet0/0/0/3 -# description Configured and Replaced by Ansible Network -# vrf custB -# ipv4 address 10.10.0.2 255.255.255.0 +# interface preconfigure GigabitEthernet0/0/0/3 +# description Configured by Ansible Network # duplex half # shutdown -# dot1q native vlan 1021 # ! + # Using overridden + # Before state: # ------------ # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# description Configured by Ansible -# vrf custB -# ipv4 address 178.18.169.23 255.255.255.0 -# dot1q native vlan 30 +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp +# ! +# interface preconfigure GigabitEthernet0/0/0/2 # description Configured by Ansible -# mtu 2600 -# vrf custB -# ipv4 address 10.10.0.2 255.255.255.0 -# duplex full +# mtu 2000 +# ! +# interface preconfigure GigabitEthernet0/0/0/3 +# description Configured by Ansible Network +# duplex half # shutdown -# dot1q native vlan 1021 # ! -- name: Override interfaces + +- name: Override interfaces configuration cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - duplex: auto - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - speed: 1000 + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + duplex: auto + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + speed: 1000 state: overridden + +# Task Output +# ----------- +# +# before: +# - enabled: true +# name: Loopback888 +# - enabled: true +# name: Loopback999 +# - description: Configured by Ansible +# enabled: true +# mtu: 2000 +# name: GigabitEthernet0/0/0/2 +# - description: Configured by Ansible Network +# duplex: half +# enabled: false +# name: GigabitEthernet0/0/0/3 +# commands: +# - interface GigabitEthernet0/0/0/2 +# - no mtu +# - duplex half +# - interface GigabitEthernet0/0/0/3 +# - no description +# - no shutdown +# - no duplex +# after: +# - enabled: true +# name: Loopback888 +# - enabled: true +# name: Loopback999 +# - description: Configured by Ansible +# duplex: half +# enabled: true +# name: GigabitEthernet0/0/0/2 +# - enabled: true +# name: GigabitEthernet0/0/0/3 + # After state: # ------------ # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# description Configured and Overridden by Ansible Network -# vrf custB -# ipv4 address 178.18.169.23 255.255.255.0 -# speed 1000 -# dot1q native vlan 30 +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# description Configured and Overridden by Ansible Network -# mtu 2000 -# vrf custB -# ipv4 address 10.10.0.2 255.255.255.0 -# duplex full -# shutdown -# dot1q native vlan 1021 +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp +# ! +# interface preconfigure GigabitEthernet0/0/0/2 +# description Configured by Ansible +# duplex half # ! +# interface preconfigure GigabitEthernet0/0/0/3 +# ! + # Using deleted + # Before state: # ------------ # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# description Configured and Overridden by Ansible Network -# vrf custB -# ipv4 address 178.18.169.23 255.255.255.0 -# speed 1000 -# dot1q native vlan 30 +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# description Configured and Overridden by Ansible Network -# mtu 2000 -# vrf custB -# ipv4 address 10.10.0.2 255.255.255.0 -# duplex full -# shutdown -# dot1q native vlan 1021 +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp +# ! +# interface preconfigure GigabitEthernet0/0/0/2 +# description Configured by Ansible +# duplex half # ! -- name: Delete IOSXR interfaces as in given arguments +# interface preconfigure GigabitEthernet0/0/0/3 +# ! + +- name: Delete interfaces arguments cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/2 + - name: GigabitEthernet0/0/0/3 state: deleted + +# Task Output +# ----------- +# +# before: +# - enabled: true +# name: Loopback888 +# - enabled: true +# name: Loopback999 +# - description: Configured by Ansible +# duplex: half +# enabled: true +# name: GigabitEthernet0/0/0/2 +# - enabled: true +# name: GigabitEthernet0/0/0/3 +# commands: +# - interface GigabitEthernet0/0/0/2 +# - no description +# - no duplex +# after: +# - enabled: true +# name: Loopback888 +# - enabled: true +# name: Loopback999 +# - enabled: true +# name: GigabitEthernet0/0/0/2 +# - enabled: true +# name: GigabitEthernet0/0/0/3 + # After state: # ------------ # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# vrf custB -# ipv4 address 178.18.169.23 255.255.255.0 -# dot1q native vlan 30 +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# vrf custB -# ipv4 address 10.10.0.2 255.255.255.0 -# dot1q native vlan 1021 +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! +# interface preconfigure GigabitEthernet0/0/0/2 +# ! +# interface preconfigure GigabitEthernet0/0/0/3 +# ! + # Using parsed -# parsed.cfg -# ------------ + +# File: parsed.cfg +# ---------------- # # interface Loopback888 # description test for ansible @@ -337,95 +454,76 @@ EXAMPLES = """ # interface GigabitEthernet0/0/0/4 # shutdown # ! -# - name: Convert ACL interfaces config to argspec without connecting to the appliance + +# - name: Parse provided configuration # cisco.iosxr.iosxr_interfaces: # running_config: "{{ lookup('file', './parsed.cfg') }}" # state: parsed -# Task Output (redacted) -# ----------------------- -# "parsed": [ -# { -# "name": "MgmtEth0/RP0/CPU0/0" -# }, -# { -# "access_groups": [ -# { -# "acls": [ -# { -# "direction": "in", -# "name": "acl_1" -# }, -# { -# "direction": "out", -# "name": "acl_2" -# } -# ], -# "afi": "ipv4" -# }, -# { -# "acls": [ -# { -# "direction": "in", -# "name": "acl6_1" -# }, -# { -# "direction": "out", -# "name": "acl6_2" -# } -# ], -# "afi": "ipv6" -# } -# ], -# "name": "GigabitEthernet0/0/0/0" -# }, -# { -# "access_groups": [ -# { -# "acls": [ -# { -# "direction": "out", -# "name": "acl_1" -# } -# ], -# "afi": "ipv4" -# } -# ], -# "name": "GigabitEthernet0/0/0/1" -# } -# ] -# } + +# Task Output +# ----------- +# +# parsed: +# - name: MgmtEth0/RP0/CPU0/0 +# - access_groups: +# - acls: +# - direction: in +# name: acl_1 +# - direction: out +# name: acl_2 +# afi: ipv4 +# - acls: +# - direction: in +# name: acl6_1 +# - direction: out +# name: acl6_2 +# afi: ipv6 +# name: GigabitEthernet0/0/0/0 +# - access_groups: +# - acls: +# - direction: out +# name: acl_1 +# afi: ipv4 +# name: GigabitEthernet0/0/0/1 + + # Using rendered + - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/0 - description: Configured and Merged by Ansible-Network - mtu: 110 - enabled: true - duplex: half - - name: GigabitEthernet0/0/0/1 - description: Configured and Merged by Ansible-Network - mtu: 2800 - enabled: false - speed: 100 - duplex: full + - name: GigabitEthernet0/0/0/0 + description: Configured and Merged by Ansible-Network + mtu: 110 + enabled: true + duplex: half + - name: GigabitEthernet0/0/0/1 + description: Configured and Merged by Ansible-Network + mtu: 2800 + enabled: false + speed: 100 + duplex: full state: rendered -# Task Output (redacted) -# ----------------------- -# "rendered": [ -# "interface GigabitEthernet0/0/0/0", -# "description Configured and Merged by Ansible-Network", -# "mtu 110", -# "duplex half", -# "no shutdown", -# "interface GigabitEthernet0/0/0/1", -# "description Configured and Merged by Ansible-Network", -# "mtu 2800", -# "speed 100", -# "duplex full", -# "shutdown" -# ] + +# Task Output +# ----------- +# +# rendered: +# - interface GigabitEthernet0/0/0/0 +# - description Configured and Merged by Ansible-Network +# - mtu 110 +# - duplex half +# - no shutdown +# - interface GigabitEthernet0/0/0/1 +# - description Configured and Merged by Ansible-Network +# - mtu 2800 +# - speed 100 +# - duplex full +# - shutdown + + # Using gathered + # Before state: # ------------ # @@ -449,58 +547,28 @@ EXAMPLES = """ # interface GigabitEthernet0/0/0/4 # shutdown # ! -- name: Gather IOSXR interfaces as in given arguments + +- name: Gather facts for interfaces cisco.iosxr.iosxr_interfaces: config: state: gathered -# Task Output (redacted) -# ----------------------- -# -# "gathered": [ -# { -# "description": "test for ansible", -# "enabled": false, -# "name": "Loopback888" -# }, -# { -# "description": "Configured and Merged by Ansible-Network", -# "duplex": "half", -# "enabled": true, -# "mtu": 110, -# "name": "GigabitEthernet0/0/0/0" -# }, -# { -# "enabled": false, -# "name": "GigabitEthernet0/0/0/3" -# }, -# { -# "enabled": false, -# "name": "GigabitEthernet0/0/0/4" -# } -# ] -# After state: -# ------------ + +# Task Output +# ----------- # -# RP/0/0/CPU0:an-iosxr-02#show running-config interface -# interface Loopback888 -# description test for ansible -# shutdown -# ! -# interface MgmtEth0/0/CPU0/0 -# ipv4 address 10.8.38.70 255.255.255.0 -# ! -# interface GigabitEthernet0/0/0/0 -# description Configured and Merged by Ansible-Network -# mtu 110 -# ipv4 address 172.31.1.1 255.255.255.0 -# duplex half -# ! -# interface GigabitEthernet0/0/0/3 -# shutdown -# ! -# interface GigabitEthernet0/0/0/4 -# shutdown -# ! +# gathered: +# - description: test for ansible +# enabled: false +# name: Loopback888 +# - description: Configured and Merged by Ansible-Network +# duplex: half +# enabled: true +# mtu: 110 +# name: GigabitEthernet0/0/0/0 +# - enabled: false +# name: GigabitEthernet0/0/0/3 +# - enabled: false +# name: GigabitEthernet0/0/0/4 """ RETURN = """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_l2_interfaces.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_l2_interfaces.py index 2c5da2d4d..0614dbda4 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_l2_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_l2_interfaces.py @@ -120,8 +120,19 @@ options: list when configuring Q-in-any vlan as input. Note, that this option is valid only with respect to Sub-Interface and is not valid when configuring for Interface. + - This option is DEPRECATED and replaced with qvlan, + this attribute will be removed after 2026-06-01. type: list elements: int + qvlan: + description: + - 802.1Q VLAN configuration. Note that it can accept either 2 VLAN IDs when + configuring Q-in-Q VLAN, or it will accept 1 VLAN ID and 'any' as input + list when configuring Q-in-any vlan as input. Note, that this option is + valid only with respect to Sub-Interface and is not valid when configuring + for Interface. + type: list + elements: str propagate: description: - Propagate Layer 2 transport events. Note that it will work only when the @@ -172,20 +183,21 @@ EXAMPLES = """ - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/3 - native_vlan: 20 - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: tunnel - - name: GigabitEthernet0/0/0/3.900 - l2transport: true - q_vlan: - - 20 - - 40 + - name: GigabitEthernet0/0/0/3 + native_vlan: 20 + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: tunnel + - name: GigabitEthernet0/0/0/3.900 + l2transport: true + q_vlan: + - 20 + - 40 state: merged + # After state: # ------------ # @@ -234,20 +246,23 @@ EXAMPLES = """ # dot1q vlan 20 40 # ! -- name: Replaces device configuration of listed interfaces with provided configuration +- name: >- + Replaces device configuration of listed interfaces with provided + configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: forward - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - any + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: forward + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - any state: replaced + # After state: # ------------- # @@ -299,17 +314,18 @@ EXAMPLES = """ - name: Override device configuration of all interfaces with provided configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: forward - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - any + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: forward + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - any state: overridden + # After state: # ------------- # @@ -358,7 +374,7 @@ EXAMPLES = """ - name: "Delete L2 attributes of given interfaces (Note: This won't delete the interface itself)" cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 + - name: GigabitEthernet0/0/0/4 state: deleted # After state: @@ -500,25 +516,21 @@ EXAMPLES = """ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_l2_interfaces: config: - - - name: GigabitEthernet0/0/0/1 - native_vlan: 10 - l2transport: true - l2protocol: - - - pvst: tunnel - - - cdp: forward - propagate: true - - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - 40 - - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 + - name: GigabitEthernet0/0/0/1 + native_vlan: 10 + l2transport: true + l2protocol: + - pvst: tunnel + - cdp: forward + propagate: true + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - 40 + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 state: rendered + # Task Output (redacted) # ----------------------- # "rendered": [ @@ -645,9 +657,6 @@ EXAMPLES = """ # shutdown # dot1q native vlan 40 # ! - - - """ RETURN = """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_l3_interfaces.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_l3_interfaces.py index 98785f6b4..babf38a90 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_l3_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_l3_interfaces.py @@ -113,56 +113,70 @@ EXAMPLES = """ # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# shutdown +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# ipv4 address 192.168.0.2 255.255.255.0 -# shutdown +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/3.700 +# interface preconfigure GigabitEthernet0/0/0/2 # ! -# interface GigabitEthernet0/0/0/4 -# ipv6 address fd5d:12c9:2201:1::1/64 -# shutdown +# interface preconfigure GigabitEthernet0/0/0/3 # ! - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/2 - ipv4: - - address: 192.168.0.1/24 - - name: GigabitEthernet0/0/0/3 - ipv4: - - address: 192.168.2.1/24 - secondary: true + - name: GigabitEthernet0/0/0/2 + ipv4: + - address: 192.168.0.1/24 + - name: GigabitEthernet0/0/0/3 + ipv4: + - address: 192.168.2.1/24 + secondary: true state: merged +# Task Output +# ----------- +# +# before: +# - name: Loopback888 +# - name: Loopback999 +# - name: GigabitEthernet0/0/0/2 +# - name: GigabitEthernet0/0/0/3 +# commands: +# - interface GigabitEthernet0/0/0/2 +# - ipv4 address 192.168.0.1 255.255.255.0 +# - interface GigabitEthernet0/0/0/3 +# - ipv4 address 192.168.2.1 255.255.255.0 secondary +# after: +# - name: Loopback888 +# - name: Loopback999 +# - ipv4: +# - address: 192.168.0.1/24 +# name: GigabitEthernet0/0/0/2 +# - ipv4: +# - address: 192.168.2.1/24 +# secondary: true +# name: GigabitEthernet0/0/0/3 + # After state: # ------------ # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# ipv4 address 192.168.0.1 255.255.255.0 -# shutdown +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# ipv4 address 192.168.1.0 255.255.255.0 -# ipv4 address 192.168.2.1 255.255.255.0 secondary -# shutdown +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/3.700 +# interface preconfigure GigabitEthernet0/0/0/2 +# ipv4 address 192.168.0.1 255.255.255.0 # ! -# interface GigabitEthernet0/0/0/4 -# ipv6 address fd5d:12c9:2201:1::1/64 -# shutdown +# interface preconfigure GigabitEthernet0/0/0/3 +# ipv4 address 192.168.2.1 255.255.255.0 secondary # ! # Using overridden @@ -171,57 +185,76 @@ EXAMPLES = """ # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# ipv4 address 192.168.0.1 255.255.255.0 -# shutdown +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# ipv4 address 192.168.1.0 255.255.255.0 -# shutdown +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/3.700 +# interface preconfigure GigabitEthernet0/0/0/2 +# ipv4 address 192.168.0.1 255.255.255.0 # ! -# interface GigabitEthernet0/0/0/4 -# ipv6 address fd5d:12c9:2201:1::1/64 -# shutdown +# interface preconfigure GigabitEthernet0/0/0/3 +# ipv4 address 192.168.2.1 255.255.255.0 secondary # ! - name: Override device configuration of all interfaces with provided configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - ipv4: - - address: 192.168.0.1/24 - - name: GigabitEthernet0/0/0/3.700 - ipv4: - - address: 192.168.0.2/24 - - address: 192.168.2.1/24 - secondary: true + - name: GigabitEthernet0/0/0/3 + ipv4: + - address: 192.168.0.2/24 + - address: 192.168.2.1/24 + secondary: true state: overridden + +# Task Output +# ----------- +# +# before: +# - name: Loopback888 +# - name: Loopback999 +# - ipv4: +# - address: 192.168.0.1/24 +# name: GigabitEthernet0/0/0/2 +# - ipv4: +# - address: 192.168.2.1/24 +# secondary: true +# name: GigabitEthernet0/0/0/3 +# commands: +# - interface GigabitEthernet0/0/0/2 +# - no ipv4 address +# - interface GigabitEthernet0/0/0/3 +# - ipv4 address 192.168.0.2 255.255.255.0 +# - ipv4 address 192.168.0.1 255.255.255.0 +# after: +# - name: Loopback888 +# - name: Loopback999 +# - name: GigabitEthernet0/0/0/2 +# - ipv4: +# - address: 192.168.0.1/24 +# - address: 192.168.2.1/24 +# secondary: true +# name: GigabitEthernet0/0/0/3 + # After state: # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# shutdown +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# ipv4 address 192.168.0.1 255.255.255.0 -# shutdown +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/3.700 -# ipv4 address 192.168.0.2 255.255.255.0 -# ipv4 address 192.168.2.1 255.255.255.0 secondary +# interface preconfigure GigabitEthernet0/0/0/2 # ! -# interface GigabitEthernet0/0/0/4 -# shutdown +# interface preconfigure GigabitEthernet0/0/0/3 +# ipv4 address 192.168.0.1 255.255.255.0 +# ipv4 address 192.168.2.1 255.255.255.0 secondary # ! # Using replaced @@ -230,55 +263,78 @@ EXAMPLES = """ # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# shutdown +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# ipv4 address 192.168.0.2 255.255.255.0 -# shutdown +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/3.700 -# ipv4 address 192.168.0.1 255.255.255.0 +# interface preconfigure GigabitEthernet0/0/0/2 # ! -# interface GigabitEthernet0/0/0/4 -# ipv6 address fd5d:12c9:2201:1::1/64 -# shutdown +# interface preconfigure GigabitEthernet0/0/0/3 +# ipv4 address 192.168.0.1 255.255.255.0 +# ipv4 address 192.168.2.1 255.255.255.0 secondary # ! -- name: Replaces device configuration of listed interfaces with provided configuration +- name: >- + Replaces device configuration of listed interfaces with provided + configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - ipv6: - - address: fd5d:12c9:2201:1::1/64 - - name: GigabitEthernet0/0/0/4 - ipv4: - - address: 192.168.0.2/24 + - name: GigabitEthernet0/0/0/3 + ipv6: + - address: 'fd5d:12c9:2201:1::1/64' + - name: GigabitEthernet0/0/0/2 + ipv4: + - address: 192.168.0.2/24 state: replaced + +# Task Output +# ----------- +# +# before: +# - name: Loopback888 +# - name: Loopback999 +# - name: GigabitEthernet0/0/0/2 +# - ipv4: +# - address: 192.168.0.1/24 +# - address: 192.168.2.1/24 +# secondary: true +# name: GigabitEthernet0/0/0/3 +# commands: +# - interface GigabitEthernet0/0/0/3 +# - no ipv4 address +# - ipv6 address fd5d:12c9:2201:1::1/64 +# - interface GigabitEthernet0/0/0/2 +# - ipv4 address 192.168.0.2 255.255.255.0 +# after: +# - name: Loopback888 +# - name: Loopback999 +# - ipv4: +# - address: 192.168.0.2/24 +# name: GigabitEthernet0/0/0/2 +# - ipv6: +# - address: fd5d:12c9:2201:1::1/64 +# name: GigabitEthernet0/0/0/3 + # After state: # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# shutdown -# ! -# interface GigabitEthernet0/0/0/2 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/3 -# ipv6 address fd5d:12c9:2201:1::1/64 -# shutdown +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3.700 -# ipv4 address 192.168.0.1 255.255.255.0 +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/4 +# interface preconfigure GigabitEthernet0/0/0/2 # ipv4 address 192.168.0.2 255.255.255.0 -# shutdown +# ! +# interface preconfigure GigabitEthernet0/0/0/3 +# ipv6 address fd5d:12c9:2201:1::1/64 # ! # Using deleted @@ -287,112 +343,180 @@ EXAMPLES = """ # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# ipv4 address 192.168.2.1 255.255.255.0 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# ipv4 address 192.168.3.1 255.255.255.0 -# shutdown +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# ipv4 address 192.168.0.2 255.255.255.0 -# shutdown +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/3.700 -# ipv4 address 192.168.0.1 255.255.255.0 +# interface preconfigure GigabitEthernet0/0/0/2 +# ipv4 address 192.168.0.2 255.255.255.0 # ! -# interface GigabitEthernet0/0/0/4 +# interface preconfigure GigabitEthernet0/0/0/3 # ipv6 address fd5d:12c9:2201:1::1/64 -# shutdown # ! -- name: "Delete L3 attributes of given interfaces (Note: This won't delete the interface itself)" +- name: Delete attributes for interfaces (This won't delete the interface itself) cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - - name: GigabitEthernet0/0/0/4 - - name: GigabitEthernet0/0/0/3.700 + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/4 + - name: GigabitEthernet0/0/0/3.700 state: deleted + +# Task Output +# ----------- +# +# before: +# - name: Loopback888 +# - name: Loopback999 +# - ipv4: +# - address: 192.168.0.2/24 +# name: GigabitEthernet0/0/0/2 +# - ipv6: +# - address: fd5d:12c9:2201:1::1/64 +# name: GigabitEthernet0/0/0/3 +# commands: +# - interface GigabitEthernet0/0/0/3 +# - no ipv6 address +# after: +# - name: Loopback888 +# - name: Loopback999 +# - ipv4: +# - address: 192.168.0.2/24 +# name: GigabitEthernet0/0/0/2 +# - name: GigabitEthernet0/0/0/3 + # After state: # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 -# ipv4 address 192.168.2.1 255.255.255.0 -# shutdown +# interface Loopback888 # ! -# interface GigabitEthernet0/0/0/2 -# ipv4 address 192.168.3.1 255.255.255.0 -# shutdown +# interface Loopback999 # ! -# interface GigabitEthernet0/0/0/3 -# shutdown +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp # ! -# interface GigabitEthernet0/0/0/3.700 +# interface preconfigure GigabitEthernet0/0/0/2 +# ipv4 address 192.168.0.2 255.255.255.0 # ! -# interface GigabitEthernet0/0/0/4 -# shutdown +# interface preconfigure GigabitEthernet0/0/0/3 # ! -# Using Deleted without any config passed -# "(NOTE: This will delete all of configured resource module attributes from each configured interface)" +# Using deleted - will delete all interface configuration and not interface # Before state: # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 +# interface Loopback888 +# ! +# interface Loopback999 +# ! +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp +# ! +# interface preconfigure GigabitEthernet0/0/0/1 # ipv4 address 192.168.2.1 255.255.255.0 # shutdown # ! -# interface GigabitEthernet0/0/0/2 +# interface preconfigure GigabitEthernet0/0/0/2 # ipv4 address 192.168.3.1 255.255.255.0 # shutdown # ! -# interface GigabitEthernet0/0/0/3 +# interface preconfigure GigabitEthernet0/0/0/3 # ipv4 address 192.168.0.2 255.255.255.0 # shutdown # ! -# interface GigabitEthernet0/0/0/3.700 +# interface preconfigure GigabitEthernet0/0/0/3.700 # ipv4 address 192.168.0.1 255.255.255.0 # ! -# interface GigabitEthernet0/0/0/4 +# interface preconfigure GigabitEthernet0/0/0/4 # ipv6 address fd5d:12c9:2201:1::1/64 # shutdown # ! - -- name: "Delete L3 attributes of all interfaces (Note: This won't delete the interface itself)" +- name: "Delete L3 config of all interfaces (This won't delete the interface itself)" cisco.iosxr.iosxr_l3_interfaces: state: deleted +# Task Output +# ----------- +# +# before: +# - name: Loopback888 +# - name: Loopback999 +# - ipv4: +# - address: 192.168.2.1/24 +# name: GigabitEthernet0/0/0/1 +# - ipv4: +# - address: 192.168.3.1/24 +# name: GigabitEthernet0/0/0/2 +# - ipv4: +# - address: 192.168.0.2/24 +# name: GigabitEthernet0/0/0/3 +# - ipv4: +# - address: 192.168.0.1/24 +# name: GigabitEthernet0/0/0/3.700 +# - ipv6: +# - address: fd5d:12c9:2201:1::1/64 +# name: GigabitEthernet0/0/0/4 +# commands: +# - interface GigabitEthernet0/0/0/1 +# - no ipv4 address +# - interface GigabitEthernet0/0/0/2 +# - no ipv4 address +# - interface GigabitEthernet0/0/0/3 +# - no ipv4 address +# - interface GigabitEthernet0/0/0/3.700 +# - no ipv4 address +# - interface GigabitEthernet0/0/0/4 +# - no ipv6 address +# after: +# - name: Loopback888 +# - name: Loopback999 +# - name: GigabitEthernet0/0/0/1 +# - name: GigabitEthernet0/0/0/2 +# - name: GigabitEthernet0/0/0/3 +# - name: GigabitEthernet0/0/0/3.700 +# - name: GigabitEthernet0/0/0/4 + # After state: # ------------- # # viosxr#show running-config interface -# interface GigabitEthernet0/0/0/1 +# interface Loopback888 +# ! +# interface Loopback999 +# ! +# interface MgmtEth0/RP0/CPU0/0 +# ipv4 address dhcp +# ! +# interface preconfigure GigabitEthernet0/0/0/1 # shutdown # ! -# interface GigabitEthernet0/0/0/2 +# interface preconfigure GigabitEthernet0/0/0/2 # shutdown # ! -# interface GigabitEthernet0/0/0/3 +# interface preconfigure GigabitEthernet0/0/0/3 # shutdown # ! -# interface GigabitEthernet0/0/0/3.700 +# interface preconfigure GigabitEthernet0/0/0/3.700 # ! -# interface GigabitEthernet0/0/0/4 +# interface preconfigure GigabitEthernet0/0/0/4 # shutdown # ! # Using parsed -# parsed.cfg -# ------------ + +# File: parsed.cfg +# ---------------- # -# nterface Loopback888 +# interface Loopback888 # description test for ansible # shutdown # ! @@ -423,79 +547,60 @@ EXAMPLES = """ # ipv4 address 192.0.22.1 255.255.255.0 # ipv4 address 192.0.23.1 255.255.255.0 # ! -# - name: Convert L3 interfaces config to argspec without connecting to the appliance -# cisco.iosxr.iosxr_l3_interfaces: -# running_config: "{{ lookup('file', './parsed.cfg') }}" -# state: parsed -# Task Output (redacted) -# ----------------------- -# "parsed": [ -# { -# "ipv4": [ -# { -# "address": "192.0.2.1 255.255.255.0" -# }, -# { -# "address": "192.0.2.2 255.255.255.0", -# "secondary": true -# } -# ], -# "ipv6": [ -# { -# "address": "2001:db8:0:3::/64" -# } -# ], -# "name": "GigabitEthernet0/0/0/0" -# }, -# { -# "name": "GigabitEthernet0/0/0/1" -# }, -# { -# "ipv4": [ -# { -# "address": "192.0.22.1 255.255.255.0" -# }, -# { -# "address": "192.0.23.1 255.255.255.0" -# } -# ], -# "name": "GigabitEthernet0/0/0/3" -# } -# ] +- name: Convert L3 interfaces config to argspec without connecting to the appliance + cisco.iosxr.iosxr_l3_interfaces: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed + +# Task Output +# ----------- +# +# parsed: +# - ipv4: +# - address: 192.0.2.1 255.255.255.0 +# - address: 192.0.2.2 255.255.255.0 +# secondary: true +# ipv6: +# - address: 2001:db8:0:3::/64 +# name: GigabitEthernet0/0/0/0 +# - name: GigabitEthernet0/0/0/1 +# - ipv4: +# - address: 192.0.22.1 255.255.255.0 +# - address: 192.0.23.1 255.255.255.0 +# name: GigabitEthernet0/0/0/3 # Using rendered + - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_l3_interfaces: config: + - name: GigabitEthernet0/0/0/0 + ipv4: + - address: 198.51.100.1/24 + - name: GigabitEthernet0/0/0/1 + ipv6: + - address: '2001:db8:0:3::/64' + ipv4: + - address: 192.0.2.1/24 + - address: 192.0.2.2/24 + secondary: true + state: rendered - - name: GigabitEthernet0/0/0/0 - ipv4: - - - address: 198.51.100.1/24 - - - name: GigabitEthernet0/0/0/1 - ipv6: - - - address: 2001:db8:0:3::/64 - ipv4: - - address: 192.0.2.1/24 +# Task Output +# ----------- +# +# rendered: +# - interface GigabitEthernet0/0/0/0 +# - ipv4 address 198.51.100.1 255.255.255.0 +# - interface GigabitEthernet0/0/0/1 +# - ipv4 address 192.0.2.2 255.255.255.0 secondary +# - ipv4 address 192.0.2.1 255.255.255.0 +# - ipv6 address 2001:db8:0:3::/64 - - address: 192.0.2.2/24 - secondary: true - state: rendered -# Task Output (redacted) -# ----------------------- -# "rendered": [ -# "interface GigabitEthernet0/0/0/0", -# "ipv4 address 198.51.100.1 255.255.255.0", -# "interface GigabitEthernet0/0/0/1", -# "ipv4 address 192.0.2.2 255.255.255.0 secondary", -# "ipv4 address 192.0.2.1 255.255.255.0", -# "ipv6 address 2001:db8:0:3::/64" -# ] # Using gathered + # Before state: # ------------ # @@ -534,84 +639,27 @@ EXAMPLES = """ # shutdown # dot1q native vlan 40 # ! -- name: Gather IOSXR l3 interfaces as in given arguments + +- name: Gather l3 interfaces facts cisco.iosxr.iosxr_l3_interfaces: config: state: gathered -# Task Output (redacted) -# ----------------------- -# -# "gathered": [ -# { -# "name": "Loopback888" -# }, -# { -# "ipv4": [ -# { -# "address": "192.0.2.1 255.255.255.0" -# }, -# { -# "address": "192.0.2.2 255.255.255.0", -# "secondary": true -# } -# ], -# "ipv6": [ -# { -# "address": "2001:db8:0:3::/64" -# } -# ], -# "name": "GigabitEthernet0/0/0/0" -# }, -# { -# "name": "GigabitEthernet0/0/0/1" -# }, -# { -# "name": "GigabitEthernet0/0/0/3" -# }, -# { -# "name": "GigabitEthernet0/0/0/4" -# } -# ] -# After state: -# ------------ -# -# RP/0/0/CPU0:an-iosxr-02#show running-config interface -# interface Loopback888 -# description test for ansible -# shutdown -# ! -# interface MgmtEth0/0/CPU0/0 -# ipv4 address 10.8.38.70 255.255.255.0 -# ! -# interface GigabitEthernet0/0/0/0 -# description Configured and Merged by Ansible-Network -# mtu 66 -# ipv4 address 192.0.2.1 255.255.255.0 -# ipv4 address 192.0.2.2 255.255.255.0 secondary -# ipv6 address 2001:db8:0:3::/64 -# duplex half -# ! -# interface GigabitEthernet0/0/0/1 -# description Configured and Merged by Ansible-Network -# mtu 66 -# speed 100 -# duplex full -# dot1q native vlan 10 -# l2transport -# l2protocol cdp forward -# l2protocol pvst tunnel -# propagate remote-status -# ! -# ! -# interface GigabitEthernet0/0/0/3 -# shutdown -# ! -# interface GigabitEthernet0/0/0/4 -# shutdown -# dot1q native vlan 40 -# ! - +# Task Output +# ----------- +# +# gathered: +# - name: Loopback888 +# - ipv4: +# - address: 192.0.2.1 255.255.255.0 +# - address: 192.0.2.2 255.255.255.0 +# secondary: true +# ipv6: +# - address: 2001:db8:0:3::/64 +# name: GigabitEthernet0/0/0/0 +# - name: GigabitEthernet0/0/0/1 +# - name: GigabitEthernet0/0/0/3 +# - name: GigabitEthernet0/0/0/4 """ RETURN = """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lacp.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lacp.py index 7d54d992c..f4fd19ae5 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lacp.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lacp.py @@ -87,6 +87,7 @@ options: - parsed - rendered - gathered + - overridden default: merged """ EXAMPLES = """ @@ -328,8 +329,6 @@ EXAMPLES = """ # RP/0/0/CPU0:an-iosxr-02#show running-config lacp # lacp system mac 00c1.4c00.bd15 # lacp system priority - - """ RETURN = """ before: diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lacp_interfaces.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lacp_interfaces.py index 1ebeaae8f..07a93d0e5 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lacp_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lacp_interfaces.py @@ -165,19 +165,18 @@ EXAMPLES = """ - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: actor - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: Bundle-Ether11 - system: - mac: 00c2.4c00.bd15 - - - name: GigabitEthernet0/0/0/1 - period: 200 + - name: Bundle-Ether10 + churn_logging: actor + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: Bundle-Ether11 + system: + mac: 00c2.4c00.bd15 + - name: GigabitEthernet0/0/0/1 + period: 200 state: merged + # # # ----------- @@ -265,13 +264,13 @@ EXAMPLES = """ - name: Replace LACP configuration of listed interfaces with provided configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: partner - - - name: GigabitEthernet0/0/0/2 - period: 300 + - name: Bundle-Ether10 + churn_logging: partner + - name: GigabitEthernet0/0/0/2 + period: 300 state: replaced + # # # ----------- @@ -361,15 +360,15 @@ EXAMPLES = """ - name: Override all interface LACP configuration with provided configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether12 - churn_logging: both - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: GigabitEthernet0/0/0/1 - period: 300 + - name: Bundle-Ether12 + churn_logging: both + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: GigabitEthernet0/0/0/1 + period: 300 state: overridden + # # # ----------- @@ -454,16 +453,18 @@ EXAMPLES = """ # ! # -- name: Deleted LACP configurations of provided interfaces (Note - This won't delete +- name: >- + Deleted LACP configurations of provided interfaces (Note - This won't delete the interface itself) cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - - name: Bundle-Ether11 - - name: GigabitEthernet0/0/0/1 - - name: GigabitEthernet0/0/0/2 + - name: Bundle-Ether10 + - name: Bundle-Ether11 + - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/2 state: deleted + # # # ----------- @@ -559,19 +560,18 @@ EXAMPLES = """ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: actor - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: Bundle-Ether11 - system: - mac: 00c2.4c00.bd15 - - - name: GigabitEthernet0/0/0/1 - period: 200 + - name: Bundle-Ether10 + churn_logging: actor + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: Bundle-Ether11 + system: + mac: 00c2.4c00.bd15 + - name: GigabitEthernet0/0/0/1 + period: 200 state: rendered + # ------------- # Output # ------------- @@ -587,8 +587,6 @@ EXAMPLES = """ # - "interface GigabitEthernet0/0/0/1" # - " lacp period 200" # - - """ RETURN = """ before: diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lag_interfaces.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lag_interfaces.py index 6d1dacec1..4732dbfde 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lag_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lag_interfaces.py @@ -157,26 +157,26 @@ EXAMPLES = """ - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/3 - mode: inherit - mode: active - links: - max_active: 5 - min_active: 2 - load_balancing_hash: src-ip - - - name: Bundle-Ether12 - members: - - member: GigabitEthernet0/0/0/2 - mode: passive - - member: GigabitEthernet0/0/0/4 - mode: passive - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/3 + mode: inherit + mode: active + links: + max_active: 5 + min_active: 2 + load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - member: GigabitEthernet0/0/0/2 + mode: passive + - member: GigabitEthernet0/0/0/4 + mode: passive + load_balancing_hash: dst-ip state: merged + # # # ----------- @@ -267,15 +267,14 @@ EXAMPLES = """ - name: Replace device configuration of listed Bundles with provided configurations cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether12 - members: - - name: GigabitEthernet0/0/0/2 - mode: passive - - - name: Bundle-Ether11 - members: - - name: GigabitEthernet0/0/0/4 - load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - name: GigabitEthernet0/0/0/2 + mode: passive + - name: Bundle-Ether11 + members: + - name: GigabitEthernet0/0/0/4 + load_balancing_hash: src-ip state: replaced # # @@ -376,15 +375,16 @@ EXAMPLES = """ - name: Overrides all device configuration with provided configuration cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/2 - mode: inherit - mode: active - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/2 + mode: inherit + mode: active + load_balancing_hash: dst-ip state: overridden + # # # ------------ @@ -474,15 +474,17 @@ EXAMPLES = """ # # -- name: Delete attributes of given bundles and removes member interfaces from them +- name: >- + Delete attributes of given bundles and removes member interfaces from them (Note - This won't delete the bundles themselves) cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - - name: Bundle-Ether11 - - name: Bundle-Ether12 + - name: Bundle-Ether10 + - name: Bundle-Ether11 + - name: Bundle-Ether12 state: deleted + # # # ------------ @@ -736,25 +738,24 @@ EXAMPLES = """ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/3 - mode: inherit - mode: active - links: - max_active: 5 - min_active: 2 - load_balancing_hash: src-ip - - - name: Bundle-Ether12 - members: - - member: GigabitEthernet0/0/0/2 - mode: passive - - member: GigabitEthernet0/0/0/4 - mode: passive - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/3 + mode: inherit + mode: active + links: + max_active: 5 + min_active: 2 + load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - member: GigabitEthernet0/0/0/2 + mode: passive + - member: GigabitEthernet0/0/0/4 + mode: passive + load_balancing_hash: dst-ip state: rendered # Output: @@ -787,9 +788,6 @@ EXAMPLES = """ # - " bundle id 12 mode passive" # ] # -# - - """ RETURN = """ before: diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lldp_global.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lldp_global.py index 9c99fc8a4..c3eb21ddb 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lldp_global.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lldp_global.py @@ -108,6 +108,7 @@ options: - parsed - gathered - rendered + - overridden default: merged """ @@ -425,9 +426,6 @@ EXAMPLES = """ # "lldp tlv-select management-address disable", # "lldp timer 3000" # ] - - - """ RETURN = """ before: diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lldp_interfaces.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lldp_interfaces.py index f88d132e5..0322a0e1f 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lldp_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_lldp_interfaces.py @@ -120,17 +120,17 @@ EXAMPLES = """ - name: Merge provided configuration with running configuration cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge - transmit: false - - - name: GigabitEthernet0/0/0/2 - destination: - mac_address: ieee-nearest-bridge - receive: false + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge + transmit: false + - name: GigabitEthernet0/0/0/2 + destination: + mac_address: ieee-nearest-bridge + receive: false state: merged + # # # ------------------------ @@ -242,15 +242,17 @@ EXAMPLES = """ # # -- name: Replace existing LLDP configurations of specified interfaces with provided +- name: >- + Replace existing LLDP configurations of specified interfaces with provided configuration cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge state: replaced + # # # ------------------------ @@ -366,13 +368,16 @@ EXAMPLES = """ # # -- name: Override the LLDP configurations of all the interfaces with provided configurations +- name: >- + Override the LLDP configurations of all the interfaces with provided + configurations cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - transmit: false + - name: GigabitEthernet0/0/0/1 + transmit: false state: overridden + # # # ------------------------ @@ -638,17 +643,15 @@ EXAMPLES = """ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge - transmit: false - - - name: GigabitEthernet0/0/0/2 - destination: - mac_address: ieee-nearest-bridge - receive: false + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge + transmit: false + - name: GigabitEthernet0/0/0/2 + destination: + mac_address: ieee-nearest-bridge + receive: false state: rendered - # ------------------------ # Module Execution Result # ------------------------ @@ -661,7 +664,6 @@ EXAMPLES = """ # "lldp receive disable", # "lldp destination mac-address ieee-nearest-bridge" # ] - """ RETURN = """ before: diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging.py index 9889f568f..abca845df 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging.py @@ -201,18 +201,18 @@ EXAMPLES = """ - name: Configure logging using aggregate cisco.iosxr.iosxr_logging: aggregate: - - {dest: console, level: warning} - - {dest: buffered, size: 4800000} - - {dest: file, name: file3, size: 2048} - - {dest: host, name: host3, level: critical} + - {dest: console, level: warning} + - {dest: buffered, size: 4800000} + - {dest: file, name: file3, size: 2048} + - {dest: host, name: host3, level: critical} - name: Delete logging using aggregate cisco.iosxr.iosxr_logging: aggregate: - - {dest: console, level: warning} - - {dest: buffered, size: 4800000} - - {dest: file, name: file3, size: 2048} - - {dest: host, name: host3, level: critical} + - {dest: console, level: warning} + - {dest: buffered, size: 4800000} + - {dest: file, name: file3, size: 2048} + - {dest: host, name: host3, level: critical} state: absent """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging_global.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging_global.py index 4d25dcaab..55dd23f6b 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging_global.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging_global.py @@ -364,56 +364,56 @@ options: """ EXAMPLES = """ # Using merged -#----------------- +# ----------------- # Before state -#RP/0/0/CPU0:10#show running-config logging -#Thu Feb 4 09:38:36.245 UTC -#% No such configuration item(s) -#RP/0/0/CPU0:10# +# RP/0/0/CPU0:10#show running-config logging +# Thu Feb 4 09:38:36.245 UTC +# % No such configuration item(s) +# RP/0/0/CPU0:10# # # - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_logging_global: - config: - buffered: - size: 2097152 - severity: warnings - correlator: - buffer_size: 1024 - events: - display_location: True - files: - - maxfilesize: '1024' - name: test - path: test - severity: info - hostnameprefix: test - hosts: - - host: 1.1.1.1 - port: default - severity: critical - vrf: default - ipv4: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - source_interfaces: - - interface: GigabitEthernet0/0/0/0 - vrf: test - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test2 - vrf: test - trap: - severity: informational - state: merged + config: + buffered: + size: 2097152 + severity: warnings + correlator: + buffer_size: 1024 + events: + display_location: true + files: + - maxfilesize: '1024' + name: test + path: test + severity: info + hostnameprefix: test + hosts: + - host: 1.1.1.1 + port: default + severity: critical + vrf: default + ipv4: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + source_interfaces: + - interface: GigabitEthernet0/0/0/0 + vrf: test + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test2 + vrf: test + trap: + severity: informational + state: merged # # # After state: -#------------------------------------------- -#RP/0/0/CPU0:10#show running-config logging +# ------------------------------------------- +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -432,8 +432,8 @@ EXAMPLES = """ # logging localfilesize 1024 # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test -#------------------------------------------------ -#Module execution +# ------------------------------------------------ +# Module execution # # "after": { # "buffered": { @@ -582,8 +582,8 @@ EXAMPLES = """ # Using replaced: # ----------------------------------------------------------- # -#Before state -#RP/0/0/CPU0:10#show running-config logging +# Before state +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -602,42 +602,42 @@ EXAMPLES = """ # logging localfilesize 1024 # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test -#----------------------------------------------------------- +# ----------------------------------------------------------- # - name: Replace BGP configuration with provided configuration cisco.iosxr.iosxr_logging_global: - state: replaced - config: - buffered: - severity: errors - correlator: - buffer_size: 1024 - files: - - maxfilesize: '1024' - name: test - path: test1 - severity: info - hostnameprefix: test1 - hosts: - - host: 1.1.1.3 - port: default - severity: critical - vrf: default - ipv6: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test - vrf: test - trap: - severity: critical + state: replaced + config: + buffered: + severity: errors + correlator: + buffer_size: 1024 + files: + - maxfilesize: '1024' + name: test + path: test1 + severity: info + hostnameprefix: test1 + hosts: + - host: 1.1.1.3 + port: default + severity: critical + vrf: default + ipv6: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test + vrf: test + trap: + severity: critical # # After state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:31:51.709 UTC # logging tls-server test # vrf test @@ -653,7 +653,7 @@ EXAMPLES = """ # logging correlator buffer-size 1024 # logging localfilesize 1024 # logging hostnameprefix test1 -#----------------------------------------------------------------- +# ----------------------------------------------------------------- # # Module Execution: # "after": { @@ -773,7 +773,7 @@ EXAMPLES = """ # Using deleted: # ----------------------------------------------------------- # Before state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -793,15 +793,15 @@ EXAMPLES = """ # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test # -#----------------------------------------------------------- +# ----------------------------------------------------------- - name: Delete given logging_global configuration cisco.iosxr.iosxr_logging_global: - state: deleted + state: deleted # # After state: -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # -#------------------------------------------------------------- +# ------------------------------------------------------------- # Module Execution: # # "after": {}, @@ -887,7 +887,7 @@ EXAMPLES = """ # using gathered: # ------------------------------------------------------------ # Before state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -910,9 +910,9 @@ EXAMPLES = """ # - name: Gather iosxr_logging_global facts using gathered state cisco.iosxr.iosxr_logging_global: - state: gathered + state: gathered # -#------------------------------------------------------------- +# ------------------------------------------------------------- # Module Execution: # # "changed": false, @@ -979,7 +979,7 @@ EXAMPLES = """ # # # Using parsed: -#--------------------------------------------------------------- +# --------------------------------------------------------------- # # parsed.cfg # @@ -1004,9 +1004,9 @@ EXAMPLES = """ # - name: Parse externally provided Logging global config to agnostic model cisco.iosxr.iosxr_logging_global: - running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" - state: parsed -#---------------------------------------------------------------- + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed +# ---------------------------------------------------------------- # Module execution: # "changed": false, # "parsed": { @@ -1066,44 +1066,46 @@ EXAMPLES = """ # # Using rendered: # ---------------------------------------------------------------------------- -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_logging_global: - state: rendered - config: - buffered: - size: 2097152 - severity: warnings - correlator: - buffer_size: 1024 - events: - display_location: True - files: - - maxfilesize: '1024' - name: test - path: test - severity: info - hostnameprefix: test - hosts: - - host: 1.1.1.1 - port: default - severity: critical - vrf: default - ipv4: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - source_interfaces: - - interface: GigabitEthernet0/0/0/0 - vrf: test - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test2 - vrf: test - trap: - severity: informational -#---------------------------------------------------------------- + state: rendered + config: + buffered: + size: 2097152 + severity: warnings + correlator: + buffer_size: 1024 + events: + display_location: true + files: + - maxfilesize: '1024' + name: test + path: test + severity: info + hostnameprefix: test + hosts: + - host: 1.1.1.1 + port: default + severity: critical + vrf: default + ipv4: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + source_interfaces: + - interface: GigabitEthernet0/0/0/0 + vrf: test + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test2 + vrf: test + trap: + severity: informational +# ---------------------------------------------------------------- # Module Execution: # "rendered": [ # "logging buffered errors", @@ -1126,7 +1128,7 @@ EXAMPLES = """ # Using overridden: # --------------------------------------------------------------------------------- # Before state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -1146,42 +1148,42 @@ EXAMPLES = """ # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test # -#----------------------------------------------------------- +# ----------------------------------------------------------- # - name: Overridde logging global configuration with provided configuration cisco.iosxr.iosxr_logging_global: - state: overridden - config: - buffered: - severity: errors - correlator: - buffer_size: 1024 - files: - - maxfilesize: '1024' - name: test - path: test1 - severity: info - hostnameprefix: test1 - hosts: - - host: 1.1.1.3 - port: default - severity: critical - vrf: default - ipv6: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test - vrf: test - trap: - severity: critical + state: overridden + config: + buffered: + severity: errors + correlator: + buffer_size: 1024 + files: + - maxfilesize: '1024' + name: test + path: test1 + severity: info + hostnameprefix: test1 + hosts: + - host: 1.1.1.3 + port: default + severity: critical + vrf: default + ipv6: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test + vrf: test + trap: + severity: critical # # After state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:31:51.709 UTC # logging tls-server test # vrf test @@ -1197,7 +1199,7 @@ EXAMPLES = """ # logging correlator buffer-size 1024 # logging localfilesize 1024 # logging hostnameprefix test1 -#----------------------------------------------------------------- +# ----------------------------------------------------------------- # # Module Execution: # "after": { diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ntp_global.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ntp_global.py index 94ca24f4c..bdcf2e523 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ntp_global.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ntp_global.py @@ -273,51 +273,51 @@ EXAMPLES = """ # ------------ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_ntp_global: - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl1 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/0 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af11 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.1 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/0 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl1 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/0 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af11 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.1 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/0 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # ------------ # "commands": [ @@ -485,52 +485,52 @@ EXAMPLES = """ # ---------------- - name: Override BGP configuration with provided configuration cisco.iosxr.iosxr_ntp_global: - state: overridden - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl4 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/1 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af12 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.3 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/1 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + state: overridden + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl4 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/1 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af12 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.3 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/1 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # --------------- # "commands": [ @@ -616,52 +616,52 @@ EXAMPLES = """ # ---------------- - name: Replaced BGP configuration with provided configuration cisco.iosxr.iosxr_ntp_global: - state: replaced - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl4 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/1 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af12 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.3 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/1 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + state: replaced + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl4 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/1 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af12 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.3 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/1 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # --------------- # "commands": [ @@ -822,7 +822,9 @@ EXAMPLES = """ # Using state: rendered # Rendered play: # -------------- -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_ntp_global: state: rendered config: diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospf_interfaces.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospf_interfaces.py index 02ec5acb7..5ee6930f2 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospf_interfaces.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospf_interfaces.py @@ -492,7 +492,7 @@ EXAMPLES = """ address_family: - afi: ipv4 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.3 cost: 20 @@ -501,7 +501,7 @@ EXAMPLES = """ keychain: cisco - afi: ipv6 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.2 cost: 30 @@ -509,76 +509,42 @@ EXAMPLES = """ # # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": [] +# Task Output: +# ------------ # -# "commands": [ -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20", -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest", -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco", -# "router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30" -# ] +# before: [] # -# "after": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "message_digest": { -# "keychain": "cisco" -# } -# }, -# "cost": 20, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.3" -# }, -# "process_id": "LAB3" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "cost": 30, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.2" -# }, -# "process_id": "LAB3" -# } -# ] -# } -# ], -# "name": "GigabitEthernet0/0/0/0", -# "type": "gigabitethernet" -# } -# ] +# commands: +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20 +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco +# - router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30 # +# after: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: cisco +# cost: 20 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB3 +# - afi: ipv6 +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.2 +# process_id: LAB3 +# name: GigabitEthernet0/0/0/0 +# type: gigabitethernet # -# ------------ -# After state +# After state: # ------------ # # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf # Thu Oct 23 06:00:57.217 UTC -# router ospf LAB -# area 0.0.0.0 -# ! -# area 0.0.0.9 -# ! -# ! -# router ospf LAB1 -# area 0.0.0.1 -# ! -# area 0.0.0.3 -# ! -# ! # router ospf LAB3 # area 0.0.0.3 # interface GigabitEthernet0/0/0/0 @@ -587,30 +553,22 @@ EXAMPLES = """ # ! # ! # ! -# router ospf ipv4 +# router ospfv3 LAB3 +# area 0.0.0.2 +# interface GigabitEthernet0/0/0/0 +# cost 30 +# ! +# ! # ! # Using replaced # -# ------------ -# Before state -# ------------ +# Before state: +# ------------- # # # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf # Thu Oct 23 06:00:57.217 UTC -# router ospf LAB -# area 0.0.0.0 -# ! -# area 0.0.0.9 -# ! -# ! -# router ospf LAB1 -# area 0.0.0.1 -# ! -# area 0.0.0.3 -# ! -# ! # router ospf LAB3 # area 0.0.0.3 # interface GigabitEthernet0/0/0/0 @@ -619,7 +577,12 @@ EXAMPLES = """ # ! # ! # ! -# router ospf ipv4 +# router ospfv3 LAB3 +# area 0.0.0.2 +# interface GigabitEthernet0/0/0/0 +# cost 30 +# ! +# ! # ! - name: Replace OSPF interfaces configuration @@ -630,7 +593,7 @@ EXAMPLES = """ address_family: - afi: ipv4 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.3 cost: 30 @@ -639,130 +602,84 @@ EXAMPLES = """ keychain: ciscoiosxr - afi: ipv6 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.2 cost: 30 state: replaced - -# # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "message_digest": { -# "keychain": "cisco" -# } -# }, -# "cost": 20, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.3" -# }, -# "process_id": "LAB3" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "cost": 30, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.2" -# }, -# "process_id": "LAB3" -# } -# ] -# } -# ], -# "name": "GigabitEthernet0/0/0/0", -# "type": "gigabitethernet" -# } -# ] +# Task Output: +# ------------ # -# "commands": [ -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 30", -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest", -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain ciscoiosxr" -# ] +# before: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: cisco +# cost: 20 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB3 +# - afi: ipv6 +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.2 +# process_id: LAB3 +# name: GigabitEthernet0/0/0/0 +# type: gigabitethernet # -# "after": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "message_digest": { -# "keychain": "ciscoiosxr" -# } -# }, -# "cost": 30, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.3" -# }, -# "process_id": "LAB3" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "cost": 30, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.2" -# }, -# "process_id": "LAB3" -# } -# ] -# } -# ], -# "name": "GigabitEthernet0/0/0/0", -# "type": "gigabitethernet" -# } -# ] +# commands: +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 30 +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain ciscoiosxr # +# after: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: ciscoiosxr +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB3 +# - afi: ipv6 +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.2 +# process_id: LAB3 +# name: GigabitEthernet0/0/0/0 +# type: gigabitethernet # -# ----------- -# After state -# ----------- +# After state: +# ------------ # # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf # Thu Oct 23 06:10:39.827 UTC -# router ospf LAB -# area 0.0.0.0 -# ! -# area 0.0.0.9 -# ! -# ! -# router ospf LAB1 -# area 0.0.0.1 -# ! -# area 0.0.0.3 -# ! -# ! # router ospf LAB3 # area 0.0.0.3 # interface GigabitEthernet0/0/0/0 # cost 30 # authentication message-digest keychain ciscoiosxr # ! +# router ospfv3 LAB3 +# area 0.0.0.2 +# interface GigabitEthernet0/0/0/0 +# cost 30 +# ! # ! # ! -# router ospf ipv4 -# ! +# Using overridden +# +# Before state +# ------------ +# - name: Override existing OSPF interfaces configuration cisco.iosxr.iosxr_ospf_interfaces: config: @@ -771,7 +688,7 @@ EXAMPLES = """ address_family: - afi: ipv4 processes: - - process_id: "LAB1" + - process_id: LAB1 area: area_id: 0.0.0.3 cost: 10 @@ -782,98 +699,56 @@ EXAMPLES = """ # # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "message_digest": { -# "keychain": "ciscoiosxr" -# } -# }, -# "cost": 30, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.3" -# }, -# "process_id": "LAB3" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "cost": 30, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.2" -# }, -# "process_id": "LAB3" -# } -# ] -# } -# ], -# "name": "GigabitEthernet0/0/0/0", -# "type": "gigabitethernet" -# } -# ] +# Task Output: +# ------------ # -# "commands": [ -# "no router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0", -# "no router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0", -# "router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 cost 10", -# "router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest", -# "router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest keychain iosxr" -# ] +# before: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: ciscoiosxr +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB3 +# - afi: ipv6 +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.2 +# process_id: LAB3 +# name: GigabitEthernet0/0/0/0 +# type: gigabitethernet # -# "after": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "message_digest": { -# "keychain": "iosxr" -# } -# }, -# "cost": 10, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.3" -# }, -# "process_id": "LAB1" -# } -# ] -# } -# ], -# "name": "GigabitEthernet0/0/0/1", -# "type": "gigabitethernet" -# } -# ] +# commands: +# - no router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 +# - no router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 +# - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 cost 10 +# - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest +# - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest keychain iosxr # +# after: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: iosxr +# cost: 10 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB1 +# name: GigabitEthernet0/0/0/1 +# type: gigabitethernet # -# ----------- -# After state -# ----------- +# After state: +# ------------ # # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf # Thu Oct 23 06:28:15.025 UTC -# router ospf LAB -# area 0.0.0.0 -# ! -# area 0.0.0.9 -# ! -# ! # router ospf LAB1 -# area 0.0.0.1 -# ! # area 0.0.0.3 # interface GigabitEthernet0/0/0/1 # cost 10 @@ -885,27 +760,20 @@ EXAMPLES = """ # area 0.0.0.3 # ! # ! -# router ospf ipv4 +# router ospfv3 LAB3 +# area 0.0.0.2 +# ! # ! # Using deleted # -# ------------ -# Before state -# ------------ +# Before state: +# ------------- # # # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf # Thu Oct 23 06:28:15.025 UTC -# router ospf LAB -# area 0.0.0.0 -# ! -# area 0.0.0.9 -# ! -# ! # router ospf LAB1 -# area 0.0.0.1 -# ! # area 0.0.0.3 # interface GigabitEthernet0/0/0/1 # cost 10 @@ -915,9 +783,18 @@ EXAMPLES = """ # ! # router ospf LAB3 # area 0.0.0.3 +# interface GigabitEthernet0/0/0/0 +# cost 20 +# authentication message-digest keychain cisco +# ! # ! # ! -# router ospf ipv4 +# router ospfv3 LAB3 +# area 0.0.0.2 +# interface GigabitEthernet0/0/0/0 +# cost 30 +# ! +# ! # ! - name: Deleted existing OSPF interfaces from the device @@ -928,70 +805,91 @@ EXAMPLES = """ state: deleted # +# Task Output: +# ------------ # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "message_digest": { -# "keychain": "iosxr" -# } -# }, -# "cost": 10, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.3" -# }, -# "process_id": "LAB1" -# } -# ] -# } -# ], -# "name": "GigabitEthernet0/0/0/1", -# "type": "gigabitethernet" -# } -# ], -# -# "commands": [ -# "no router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1" -# ] +# before: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: iosxr +# cost: 10 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB1 +# name: GigabitEthernet0/0/0/1 +# type: gigabitethernet +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: cisco +# cost: 20 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB3 +# - afi: ipv6 +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.2 +# process_id: LAB3 +# name: GigabitEthernet0/0/0/0 +# type: gigabitethernet # -# "after": [] +# commands: +# - no router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1] # +# after: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: cisco +# cost: 20 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB3 +# - afi: ipv6 +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.2 +# process_id: LAB3 +# name: GigabitEthernet0/0/0/0 +# type: gigabitethernet # -# ----------- -# After state -# ----------- +# After state: +# ------------ # # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf # Thu Oct 23 06:34:38.319 UTC -# router ospf LAB -# area 0.0.0.0 -# ! -# area 0.0.0.9 -# ! -# ! # router ospf LAB1 -# area 0.0.0.1 -# ! # area 0.0.0.3 # ! # ! # router ospf LAB3 # area 0.0.0.3 +# interface GigabitEthernet0/0/0/0 +# cost 20 +# authentication message-digest keychain cisco +# ! # ! # ! -# router ospf ipv4 +# router ospfv3 LAB3 +# area 0.0.0.2 +# interface GigabitEthernet0/0/0/0 +# cost 30 +# ! +# ! # ! # Using parsed +# # parsed.cfg # ------------ # router ospf LAB @@ -1016,46 +914,30 @@ EXAMPLES = """ # ! # router ospf ipv4 # ! -- name: Parsed the device configuration to get output commands +- name: Parsed running config and display structured facts. cisco.iosxr.iosxr_ospf_interfaces: running_config: "{{ lookup('file', './parsed.cfg') }}" state: parsed # +# Task Output: +# ------------ # -# ------------------------- -# Module Execution Result -# ------------------------- -# -# -# "parsed": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "message_digest": { -# "keychain": "cisco" -# } -# }, -# "cost": 20, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.3" -# }, -# "process_id": "LAB3" -# } -# ] -# } -# ], -# "name": "GigabitEthernet0/0/0/0", -# "type": "gigabitethernet" -# } -# ] -# +# parsed: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: cisco +# cost: 20 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB3 +# name: GigabitEthernet0/0/0/0 +# type: gigabitethernet + # Using rendered # -# - name: Render the commands for provided configuration cisco.iosxr.iosxr_ospf_interfaces: config: @@ -1064,35 +946,30 @@ EXAMPLES = """ address_family: - afi: ipv4 processes: - - process_id: "LAB3" - area: - area_id: 0.0.0.3 + - process_id: LAB3 + area: + area_id: 0.0.0.3 cost: 20 authentication: message_digest: keychain: cisco - afi: ipv6 processes: - - process_id: "LAB3" - area: - area_id: 0.0.0.2 + - process_id: LAB3 + area: + area_id: 0.0.0.2 cost: 30 state: rendered # +# Task Output: +# ------------ # -# ------------------------- -# Module Execution Result -# ------------------------- -# -# -# "rendered": [ -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20", -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest", -# "router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco", -# "router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30" -# ] - +# rendered: +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20 +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest +# - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco +# - router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30 # Using gathered # @@ -1101,18 +978,6 @@ EXAMPLES = """ # # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf # Thu Oct 23 06:50:38.743 UTC -# router ospf LAB -# area 0.0.0.0 -# ! -# area 0.0.0.9 -# ! -# ! -# router ospf LAB1 -# area 0.0.0.1 -# ! -# area 0.0.0.3 -# ! -# ! # router ospf LAB3 # area 0.0.0.3 # interface GigabitEthernet0/0/0/0 @@ -1121,7 +986,12 @@ EXAMPLES = """ # ! # ! # ! -# router ospf ipv4 +# router ospfv3 LAB3 +# area 0.0.0.2 +# interface GigabitEthernet0/0/0/0 +# cost 30 +# ! +# ! # ! @@ -1129,49 +999,73 @@ EXAMPLES = """ cisco.iosxr.iosxr_ospf_interfaces: state: gathered # +# Task Output: +# ------------ # -# ------------------------- -# Module Execution Result -# ------------------------- -# -# "gathered": [ -# { -# "address_family": [ -# { -# "afi": "ipv4", -# "authentication": { -# "message_digest": { -# "keychain": "cisco" -# } -# }, -# "cost": 20, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.3" -# }, -# "process_id": "LAB3" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "cost": 30, -# "processes": [ -# { -# "area": { -# "area_id": "0.0.0.2" -# }, -# "process_id": "LAB3" -# } -# ] -# } -# ], -# "name": "GigabitEthernet0/0/0/0", -# "type": "gigabitethernet" -# } -# ] -# +# gathered: +# - address_family: +# - afi: ipv4 +# authentication: +# message_digest: +# keychain: cisco +# cost: 20 +# processes: +# - area: +# area_id: 0.0.0.3 +# process_id: LAB3 +# - afi: ipv6 +# cost: 30 +# processes: +# - area: +# area_id: 0.0.0.2 +# process_id: LAB3 +# name: GigabitEthernet0/0/0/0 +# type: gigabitethernet +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20 + - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest + +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20 + +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. """ from ansible.module_utils.basic import AnsibleModule diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospfv2.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospfv2.py index 4b41338d4..f86a75a62 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospfv2.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospfv2.py @@ -1077,173 +1077,132 @@ EXAMPLES = """ cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: '27' - areas: - - area_id: '10' - hello_interval: 2 + - process_id: '27' + areas: + - area_id: '10' + hello_interval: 2 + authentication: + keychain: ansi11393 + - process_id: '26' + adjacency_stagger: + max_adjacency: 20 + min_adjacency: 10 + - process_id: '10' authentication: - keychain: ansi11393 - - process_id: '26' - adjacency_stagger: - max_adjacency: 20 - min_adjacency: 10 - - process_id: '10' - authentication: - keychain: ansible_test1102 - areas: - - area_id: '11' - default_cost: 5 - cost: 11 - - area_id: 22 - default_cost: 6 - - process_id: '30' - areas: - - area_id: 11 - default_cost: 5 - - area_id: 22 - default_cost: 6 - - cost: 2 - default_metric: 10 - transmit_delay: 2 - hello_interval: 1 - dead_interval: 2 - retransmit_interval: 2 - weight: 2 - packet_size: 577 - priority: 1 - router_id: 2.2.2.2 - demand_circuit: enable - passive: disable - summary_in: enable - flood_reduction: disable - mtu_ignore: enable - external_out: disable + keychain: ansible_test1102 + areas: + - area_id: '11' + default_cost: 5 + cost: 11 + - area_id: 22 + default_cost: 6 + - process_id: '30' + areas: + - area_id: 11 + default_cost: 5 + - area_id: 22 + default_cost: 6 + cost: 2 + default_metric: 10 + transmit_delay: 2 + hello_interval: 1 + dead_interval: 2 + retransmit_interval: 2 + weight: 2 + packet_size: 577 + priority: 1 + router_id: 2.2.2.2 + demand_circuit: enable + passive: disable + summary_in: enable + flood_reduction: disable + mtu_ignore: enable + external_out: disable state: merged +# Task Output: +# ------------ # +# before: {} +# +# commands: +# - router ospf 30 +# - cost 2 +# - weight 2 +# - passive disable +# - priority 1 +# - flood-reduction disable +# - default-metric 10 +# - router-id 2.2.2.2 +# - demand-circuit enable +# - packet-size 577 +# - transmit-delay 2 +# - summary-in enable +# - external-out disable +# - dead-interval 2 +# - hello-interval 1 +# - retransmit-interval 2 +# - mtu-ignore enable +# - area 11 default-cost 5 +# - area 22 default-cost 6 +# - router ospf 26 +# - adjacency stagger 10 20 +# - router ospf 10 +# - authentication keychain ansible_test1102 +# - area 11 default-cost 5 +# - area 11 cost 11 +# - area 22 default-cost 6 +# - router ospf 27 +# - area 10 authentication keychain ansi11393 +# - area 10 hello-interval 2 +# +# after: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# authentication: +# keychain: ansible_test1102 +# process_id: '10' +# - adjacency_stagger: +# max_adjacency: 20 +# min_adjacency: 10 +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# keychain: ansi11393 +# hello_interval: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: enable +# external_out: disable +# flood_reduction: disable +# hello_interval: 1 +# mtu_ignore: enable +# packet_size: 577 +# passive: disable +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# summary_in: enable +# transmit_delay: 2 +# weight: 2 # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": {} -# -# "commands": [ -# "router ospf 30", -# "cost 2", -# "weight 2", -# "passive disable", -# "priority 1", -# "flood-reduction disable", -# "default-metric 10", -# "router-id 2.2.2.2", -# "demand-circuit enable", -# "packet-size 577", -# "transmit-delay 2", -# "summary-in enable", -# "external-out disable", -# "dead-interval 2", -# "hello-interval 1", -# "retransmit-interval 2", -# "mtu-ignore enable", -# "area 11 default-cost 5", -# "area 22 default-cost 6", -# "router ospf 26", -# "adjacency stagger 10 20", -# "authentication message-digest keychain ansible1101pass", -# "router ospf 27", -# "area 10 authentication keychain ansi11393", -# "area 10 hello-interval 2", -# "router ospf 10", -# "authentication keychain ansible_test1102", -# "area 11 default-cost 5", -# "area 11 cost 11", -# "area 22 default-cost 6" -# ] -# -# "after": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "authentication": { -# "keychain": "ansible_test1102" -# }, -# "process_id": "10" -# }, -# { -# "adjacency_stagger": { -# "max_adjacency": 20, -# "min_adjacency": 10 -# }, -# "authentication": { -# "message_digest": { -# "keychain": "ansible1101pass" -# } -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": "enable", -# "external_out": "disable", -# "flood_reduction": "disable", -# "hello_interval": 1, -# "mtu_ignore": "enable", -# "packet_size": 577, -# "passive": "disable", -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "summary_in": "enable", -# "transmit_delay": 2, -# "weight": 2 -# } -# ] -# } -# -# -# ------------ -# After state +# After state: # ------------ # -# RP/0/RP0/CPU0:anton#show running-config router ospf -# Thu Jun 11 16:06:44.406 UTC # router ospf 10 # authentication keychain ansible_test1102 # area 11 @@ -1255,14 +1214,13 @@ EXAMPLES = """ # ! # ! # router ospf 26 -# authentication message-digest keychain ansible1101pass # adjacency stagger 10 20 # ! # router ospf 27 # area 10 -# authentication keychain ansi11393 +# authentication keychain ansi11393 # hello-interval 2 -# ! +# ! # ! # router ospf 30 # router-id 2.2.2.2 @@ -1288,14 +1246,11 @@ EXAMPLES = """ # default-cost 6 # ! # ! -# - # Using replaced # -# ------------ -# Before state -# ------------ +# Before state: +# ------------- # # # RP/0/RP0/CPU0:anton#show running-config router ospf @@ -1311,14 +1266,13 @@ EXAMPLES = """ # ! # ! # router ospf 26 -# authentication message-digest keychain ansible1101pass # adjacency stagger 10 20 # ! # router ospf 27 # area 10 -# authentication keychain ansi11393 +# authentication keychain ansi11393 # hello-interval 2 -# ! +# ! # ! # router ospf 30 # router-id 2.2.2.2 @@ -1345,199 +1299,128 @@ EXAMPLES = """ # ! # ! # - -- name: Replace OSPFv2 routes configurations from the device +- name: Replace running OSPFv2 routes configurations with provided config. cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 - - area_id: 20 - cost: 2 - default_cost: 2 - authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + - area_id: 20 + cost: 2 + default_cost: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 state: replaced +# Task Output: +# ------------ # +# before: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# authentication: +# keychain: ansible_test1102 +# process_id: '10' +# - adjacency_stagger: +# max_adjacency: 20 +# min_adjacency: 10 +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# keychain: ansi11393 +# hello_interval: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: enable +# external_out: disable +# flood_reduction: disable +# hello_interval: 1 +# mtu_ignore: enable +# packet_size: 577 +# passive: disable +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# summary_in: enable +# transmit_delay: 2 +# weight: 2 +# +# commands: +# - router ospf 27 +# - no area 10 authentication keychain ansi11393 +# - area 20 authentication keychain ansi11393 +# - area 20 default-cost 2 +# - area 20 cost 2 +# +# after: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# authentication: +# keychain: ansible_test1102 +# process_id: '10' +# - adjacency_stagger: +# max_adjacency: 20 +# min_adjacency: 10 +# process_id: '26' +# - areas: +# - area_id: '10' +# hello_interval: 2 +# - area_id: '20' +# authentication: +# keychain: ansi11393 +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: enable +# external_out: disable +# flood_reduction: disable +# hello_interval: 1 +# mtu_ignore: enable +# packet_size: 577 +# passive: disable +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# summary_in: enable +# transmit_delay: 2 +# weight: 2 # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "authentication": { -# "keychain": "ansible_test1102" -# }, -# "process_id": "10" -# }, -# { -# "adjacency_stagger": { -# "max_adjacency": 20, -# "min_adjacency": 10 -# }, -# "authentication": { -# "message_digest": { -# "keychain": "ansible1101pass" -# } -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": "enable", -# "external_out": "disable", -# "flood_reduction": "disable", -# "hello_interval": 1, -# "mtu_ignore": "enable", -# "packet_size": 577, -# "passive": "disable", -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "summary_in": "enable", -# "transmit_delay": 2, -# "weight": 2 -# } -# ] -# } -# -# "commands": [ -# "router ospf 27", -# "no area 10 authentication keychain ansi11393", -# "area 20 authentication keychain ansi11393", -# "area 20 default-cost 2", -# "area 20 cost 2" -# ] -# -# "after": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "authentication": { -# "keychain": "ansible_test1102" -# }, -# "process_id": "10" -# }, -# { -# "adjacency_stagger": { -# "max_adjacency": 20, -# "min_adjacency": 10 -# }, -# "authentication": { -# "message_digest": { -# "keychain": "ansible1101pass" -# } -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# }, -# { -# "area_id": "20", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "cost": 2, -# "default_cost": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": "enable", -# "external_out": "disable", -# "flood_reduction": "disable", -# "hello_interval": 1, -# "mtu_ignore": "enable", -# "packet_size": 577, -# "passive": "disable", -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "summary_in": "enable", -# "transmit_delay": 2, -# "weight": 2 -# } -# ] -# } -# -# -# ----------- -# After state -# ----------- +# After state: +# ------------ # # RP/0/RP0/CPU0:anton(config)#do show running-config router ospf # Thu Jun 11 16:40:31.038 UTC @@ -1552,7 +1435,6 @@ EXAMPLES = """ # ! # ! # router ospf 26 -# authentication message-digest keychain ansible1101pass # adjacency stagger 10 20 # ! # router ospf 27 @@ -1589,15 +1471,11 @@ EXAMPLES = """ # default-cost 6 # ! # ! -# - # Using overridden # -# ------------ -# Before state -# ------------ -# +# Before state: +# ------------- # # RP/0/RP0/CPU0:anton#show running-config router ospf # Thu Jun 11 16:06:44.406 UTC @@ -1612,14 +1490,17 @@ EXAMPLES = """ # ! # ! # router ospf 26 -# authentication message-digest keychain ansible1101pass # adjacency stagger 10 20 # ! # router ospf 27 # area 10 -# authentication keychain ansi11393 # hello-interval 2 -# ! +# ! +# area 20 +# cost 2 +# authentication keychain ansi11393 +# default-cost 2 +# ! # ! # router ospf 30 # router-id 2.2.2.2 @@ -1645,195 +1526,141 @@ EXAMPLES = """ # default-cost 6 # ! # ! -# -- name: Override existing OSPFv2 configurations from the device +- name: Override existing OSPFv2 configurations with provided config. cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 - authentication: - keychain: ansi11393 - - area_id: 20 - cost: 2 - default_cost: 2 - authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + authentication: + keychain: ansi11393 + - area_id: 20 + cost: 2 + default_cost: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 state: overridden + # +# Task Output: +# ------------ # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "authentication": { -# "keychain": "ansible_test1102" -# }, -# "process_id": "10" -# }, -# { -# "adjacency_stagger": { -# "max_adjacency": 20, -# "min_adjacency": 10 -# }, -# "authentication": { -# "message_digest": { -# "keychain": "ansible1101pass" -# } -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": "enable", -# "external_out": "disable", -# "flood_reduction": "disable", -# "hello_interval": 1, -# "mtu_ignore": "enable", -# "packet_size": 577, -# "passive": "disable", -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "summary_in": "enable", -# "transmit_delay": 2, -# "weight": 2 -# } -# ] -# } -# -# "commands": [ -# "router ospf 10", -# "no authentication keychain ansible_test1102", -# "no area 11 default-cost 5", -# "no area 11 cost 11", -# "no area 22 default-cost 6", -# "router ospf 30", -# "no cost 2", -# "no weight 2", -# "no passive disable", -# "no priority 1", -# "no flood-reduction disable", -# "no default-metric 10", -# "no router-id 2.2.2.2", -# "no demand-circuit enable", -# "no packet-size 577", -# "no transmit-delay 2", -# "no summary-in enable", -# "no external-out disable", -# "no dead-interval 2", -# "no hello-interval 1", -# "no retransmit-interval 2", -# "no mtu-ignore enable", -# "no area 11 default-cost 5", -# "no area 22 default-cost 6", -# "router ospf 27", -# "area 20 authentication keychain ansi11393", -# "area 20 default-cost 2", -# "area 20 cost 2" -# ] -# -# "after": { -# "processes": [ -# { -# "process_id": "10" -# }, -# { -# "adjacency_stagger": { -# "max_adjacency": 20, -# "min_adjacency": 10 -# }, -# "authentication": { -# "message_digest": { -# "keychain": "ansible1101pass" -# } -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "hello_interval": 2 -# }, -# { -# "area_id": "20", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "cost": 2, -# "default_cost": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "process_id": "30" -# } -# ] -# } +# before: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# authentication: +# keychain: ansible_test1102 +# process_id: '10' +# - adjacency_stagger: +# max_adjacency: 20 +# min_adjacency: 10 +# process_id: '26' +# - areas: +# - area_id: '10' +# hello_interval: 2 +# - area_id: '20' +# authentication: +# keychain: ansi11393 +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: enable +# external_out: disable +# flood_reduction: disable +# hello_interval: 1 +# mtu_ignore: enable +# packet_size: 577 +# passive: disable +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# summary_in: enable +# transmit_delay: 2 +# weight: 2 + # +# commands: +# - router ospf 10 +# - no authentication keychain ansible_test1102 +# - no area 11 default-cost 5 +# - no area 11 cost 11 +# - no area 22 default-cost 6 +# - router ospf 30 +# - no cost 2 +# - no weight 2 +# - no passive disable +# - no priority 1 +# - no flood-reduction disable +# - no default-metric 10 +# - no router-id 2.2.2.2 +# - no demand-circuit enable +# - no packet-size 577 +# - no transmit-delay 2 +# - no summary-in enable +# - no external-out disable +# - no dead-interval 2 +# - no hello-interval 1 +# - no retransmit-interval 2 +# - no mtu-ignore enable +# - no area 11 default-cost 5 +# - no area 22 default-cost 6 +# - router ospf 27 +# - area 10 authentication keychain ansi11393 +# +# after: +# processes: +# - process_id: '10' +# - adjacency_stagger: +# max_adjacency: 20 +# min_adjacency: 10 +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# keychain: ansi11393 +# hello_interval: 2 +# - area_id: '20' +# authentication: +# keychain: ansi11393 +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - process_id: '30' # -# ----------- -# After state -# ----------- +# After state: +# ------------ # # RP/0/RP0/CPU0:anton#show running-config router ospf # Thu Jun 11 16:50:36.332 UTC # router ospf 10 +# area 11 +# ! +# area 22 +# ! # ! # router ospf 26 -# authentication message-digest keychain ansible1101pass # adjacency stagger 10 20 # ! # router ospf 27 @@ -1848,16 +1675,17 @@ EXAMPLES = """ # ! # ! # router ospf 30 +# area 11 +# ! +# area 22 +# ! # ! # - # Using deleted # -# ------------ -# Before state -# ------------ -# +# Before state: +# ------------- # # RP/0/RP0/CPU0:anton#show running-config router ospf # Thu Jun 11 16:06:44.406 UTC @@ -1872,14 +1700,18 @@ EXAMPLES = """ # ! # ! # router ospf 26 -# authentication message-digest keychain ansible1101pass # adjacency stagger 10 20 # ! # router ospf 27 # area 10 -# authentication keychain ansi11393 +# authentication keychain ansi11393 # hello-interval 2 -# ! +# ! +# area 20 +# cost 2 +# authentication keychain ansi11393 +# default-cost 2 +# ! # ! # router ospf 30 # router-id 2.2.2.2 @@ -1905,163 +1737,136 @@ EXAMPLES = """ # default-cost 6 # ! # ! -# -- name: Deleted existing OSPFv2 configurations from the device +- name: Deleted provided ospfv2 processes. cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: '10' - - process_id: '26' - - process_id: '27' - - process_id: '30' + - process_id: '10' + - process_id: '26' + - process_id: '27' + - process_id: '30' state: deleted + # +# Task Output: +# ------------ # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "authentication": { -# "keychain": "ansible_test1102" -# }, -# "process_id": "10" -# }, -# { -# "adjacency_stagger": { -# "max_adjacency": 20, -# "min_adjacency": 10 -# }, -# "authentication": { -# "message_digest": { -# "keychain": "ansible1101pass" -# } -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": "enable", -# "external_out": "disable", -# "flood_reduction": "disable", -# "hello_interval": 1, -# "mtu_ignore": "enable", -# "packet_size": 577, -# "passive": "disable", -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "summary_in": "enable", -# "transmit_delay": 2, -# "weight": 2 -# } -# ] -# }, -# -# "commands": [ -# "router ospf 10", -# "no authentication keychain ansible_test1102", -# "no area 11 default-cost 5", -# "no area 11 cost 11", -# "no area 22 default-cost 6", -# "router ospf 26", -# "no adjacency stagger 10 20", -# "no authentication message-digest keychain ansible1101pass", -# "router ospf 27", -# "no area 10 authentication keychain ansi11393", -# "no area 10 hello-interval 2", -# "router ospf 30", -# "no cost 2", -# "no weight 2", -# "no passive disable", -# "no priority 1", -# "no flood-reduction disable", -# "no default-metric 10", -# "no router-id 2.2.2.2", -# "no demand-circuit enable", -# "no packet-size 577", -# "no transmit-delay 2", -# "no summary-in enable", -# "no external-out disable", -# "no dead-interval 2", -# "no hello-interval 1", -# "no retransmit-interval 2", -# "no mtu-ignore enable", -# "no area 11 default-cost 5", -# "no area 22 default-cost 6" -# ] -# -# "after": { -# "processes": [ -# { -# "process_id": "10" -# }, -# { -# "process_id": "26" -# }, -# { -# "process_id": "27" -# }, -# { -# "process_id": "30" -# } -# ] -# } -# -# -# ----------- -# After state -# ----------- +# before: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# authentication: +# keychain: ansible_test1102 +# process_id: '10' +# - adjacency_stagger: +# max_adjacency: 20 +# min_adjacency: 10 +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# keychain: ansi11393 +# hello_interval: 2 +# - area_id: '20' +# authentication: +# keychain: ansi11393 +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: enable +# external_out: disable +# flood_reduction: disable +# hello_interval: 1 +# mtu_ignore: enable +# packet_size: 577 +# passive: disable +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# summary_in: enable +# transmit_delay: 2 +# weight: 2 +# +# commands: +# - router ospf 10 +# - no authentication keychain ansible_test1102 +# - no area 11 default-cost 5 +# - no area 11 cost 11 +# - no area 22 default-cost 6 +# - router ospf 26 +# - no adjacency stagger 10 20 +# - router ospf 27 +# - no area 10 authentication keychain ansi11393 +# - no area 10 hello-interval 2 +# - no area 20 authentication keychain ansi11393 +# - no area 20 default-cost 2 +# - no area 20 cost 2 +# - router ospf 30 +# - no cost 2 +# - no weight 2 +# - no passive disable +# - no priority 1 +# - no flood-reduction disable +# - no default-metric 10 +# - no router-id 2.2.2.2 +# - no demand-circuit enable +# - no packet-size 577 +# - no transmit-delay 2 +# - no summary-in enable +# - no external-out disable +# - no dead-interval 2 +# - no hello-interval 1 +# - no retransmit-interval 2 +# - no mtu-ignore enable +# - no area 11 default-cost 5 +# - no area 22 default-cost 6 +# +# after: +# processes: +# - process_id: '10' +# - process_id: '26' +# - process_id: '27' +# - process_id: '30' + +# After state: +# ------------ # # RP/0/RP0/CPU0:anton(config)#show running-config router ospf # Thu Jun 11 17:07:34.218 UTC # router ospf 10 +# area 11 +# ! +# area 22 +# ! # ! # router ospf 26 # ! # router ospf 27 +# area 10 +# ! +# area 20 +# ! # ! # router ospf 30 +# area 11 +# ! +# area 22 +# ! # ! @@ -2113,184 +1918,146 @@ EXAMPLES = """ # default-cost 6 # ! # ! +# - name: Parsed the device configuration to get output commands cisco.iosxr.iosxr_ospfv2: running_config: "{{ lookup('file', './parsed.cfg') }}" state: parsed # +# Task Output: +# ------------ # -# ------------------------- -# Module Execution Result -# ------------------------- -# -# -# "parsed": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "authentication": { -# "keychain": "ansible_test1102" -# }, -# "process_id": "10" -# }, -# { -# "adjacency_stagger": { -# "max_adjacency": 20, -# "min_adjacency": 10 -# }, -# "authentication": { -# "message_digest": { -# "keychain": "ansible1101pass" -# } -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": "enable", -# "external_out": "disable", -# "flood_reduction": "disable", -# "hello_interval": 1, -# "mtu_ignore": "enable", -# "packet_size": 577, -# "passive": "disable", -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "summary_in": "enable", -# "transmit_delay": 2, -# "weight": 2 -# } -# ] -# } - - +# parsed: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# authentication: +# keychain: ansible_test1102 +# process_id: '10' +# - adjacency_stagger: +# max_adjacency: 20 +# min_adjacency: 10 +# authentication: +# message_digest: +# keychain: ansible1101pass +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# keychain: ansi11393 +# hello_interval: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: enable +# external_out: disable +# flood_reduction: disable +# hello_interval: 1 +# mtu_ignore: enable +# packet_size: 577 +# passive: disable +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# summary_in: enable +# transmit_delay: 2 +# weight: 2 # Using rendered # -# - name: Render the commands for provided configuration cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 + - process_id: 10 authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 - - process_id: 10 - authentication: - keychain: ansible_test1102 - areas: - - area_id: 11 - default_cost: 5 - cost: 11 - - area_id: 22 - default_cost: 6 - - process_id: 30 - areas: - - area_id: 11 - default_cost: 5 - - area_id: 22 - default_cost: 6 - - cost: 2 - default_metric: 10 - transmit_delay: 2 - hello_interval: 1 - dead_interval: 2 - retransmit_interval: 2 - weight: 2 - packet_size: 577 - priority: 1 - router_id: 2.2.2.2 - demand_circuit: enable - passive: disable - summary_in: enable - flood_reduction: disable - mtu_ignore: enable - external_out: disable + keychain: ansible_test1102 + areas: + - area_id: 11 + default_cost: 5 + cost: 11 + - area_id: 22 + default_cost: 6 + - process_id: 30 + areas: + - area_id: 11 + default_cost: 5 + - area_id: 22 + default_cost: 6 + cost: 2 + default_metric: 10 + transmit_delay: 2 + hello_interval: 1 + dead_interval: 2 + retransmit_interval: 2 + weight: 2 + packet_size: 577 + priority: 1 + router_id: 2.2.2.2 + demand_circuit: enable + passive: disable + summary_in: enable + flood_reduction: disable + mtu_ignore: enable + external_out: disable state: rendered + # +# Task Output: +# ------------ # -# ------------------------- -# Module Execution Result -# ------------------------- -# -# -# "rendered": [ -# "router ospf 27", -# "area 10 authentication keychain ansi11393", -# "area 10 hello-interval 2", -# "router ospf 26", -# "adjacency stagger 10 20", -# "authentication message-digest keychain ansible1101pass", -# "router ospf 10", -# "authentication keychain ansible_test1102", -# "area 11 default-cost 5", -# "area 11 cost 11", -# "area 22 default-cost 6", -# "router ospf 30", -# "cost 2", -# "weight 2", -# "passive disable", -# "priority 1", -# "flood-reduction disable", -# "default-metric 10", -# "router-id 2.2.2.2", -# "demand-circuit enable", -# "packet-size 577", -# "transmit-delay 2", -# "summary-in enable", -# "external-out disable", -# "dead-interval 2", -# "hello-interval 1", -# "retransmit-interval 2", -# "mtu-ignore enable", -# "area 11 default-cost 5", -# "area 22 default-cost 6" -# ] +# rendered: +# - router ospf 27 +# - area 10 authentication keychain ansi11393 +# - area 10 hello-interval 2 +# - router ospf 26 +# - adjacency stagger 10 20 +# - router ospf 10 +# - authentication keychain ansible_test1102 +# - area 11 default-cost 5 +# - area 11 cost 11 +# - area 22 default-cost 6 +# - router ospf 30 +# - cost 2 +# - weight 2 +# - passive disable +# - priority 1 +# - flood-reduction disable +# - default-metric 10 +# - router-id 2.2.2.2 +# - demand-circuit enable +# - packet-size 577 +# - transmit-delay 2 +# - summary-in enable +# - external-out disable +# - dead-interval 2 +# - hello-interval 1 +# - retransmit-interval 2 +# - mtu-ignore enable +# - area 11 default-cost 5 +# - area 22 default-cost 6 # Using gathered @@ -2311,14 +2078,15 @@ EXAMPLES = """ # ! # ! # router ospf 26 -# authentication message-digest keychain ansible1101pass # adjacency stagger 10 20 # ! # router ospf 27 # area 10 -# authentication keychain ansi11393 +# authentication keychain ansi11393 # hello-interval 2 -# ! +# ! +# area 20 +# ! # ! # router ospf 30 # router-id 2.2.2.2 @@ -2350,84 +2118,52 @@ EXAMPLES = """ state: gathered # # -# ------------------------- -# Module Execution Result -# ------------------------- +# Task Output: +# ------------ # -# "gathered": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "authentication": { -# "keychain": "ansible_test1102" -# }, -# "process_id": "10" -# }, -# { -# "adjacency_stagger": { -# "max_adjacency": 20, -# "min_adjacency": 10 -# }, -# "authentication": { -# "message_digest": { -# "keychain": "ansible1101pass" -# } -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "authentication": { -# "keychain": "ansi11393" -# }, -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": "enable", -# "external_out": "disable", -# "flood_reduction": "disable", -# "hello_interval": 1, -# "mtu_ignore": "enable", -# "packet_size": 577, -# "passive": "disable", -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "summary_in": "enable", -# "transmit_delay": 2, -# "weight": 2 -# } -# ] -# } +# gathered: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# authentication: +# keychain: ansible_test1102 +# process_id: '10' +# - adjacency_stagger: +# max_adjacency: 20 +# min_adjacency: 10 +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# keychain: ansi11393 +# hello_interval: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: enable +# external_out: disable +# flood_reduction: disable +# hello_interval: 1 +# mtu_ignore: enable +# packet_size: 577 +# passive: disable +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# summary_in: enable +# transmit_delay: 2 +# weight: 2 # # After state: # ------------- @@ -2479,8 +2215,6 @@ EXAMPLES = """ # ! # ! # -# - """ RETURN = """ before: @@ -2504,6 +2238,27 @@ commands: sample: - "router ospf 30" - "authentication message-digest keychain 'ansible1101pass'" +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router ospf 27 + - area 10 authentication keychain ansi11393 +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: dict + sample: > + This output will always be in the same format as the + module argspec. """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospfv3.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospfv3.py index c4a52e556..b86e4ff1b 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospfv3.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospfv3.py @@ -1653,105 +1653,75 @@ EXAMPLES = """ retransmit_interval: 2 packet_size: 577 priority: 1 - router_id: '2.2.2.2' + router_id: 2.2.2.2 demand_circuit: true mtu_ignore: true state: merged # +# Task Output: +# ------------ +# +# before: {} # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": {} -# -# "commands": [ -# "router ospfv3 10", -# "area 11 default-cost 5", -# "area 11 cost 11", -# "area 22 default-cost 6", -# "router ospfv3 26", -# "authentication disable", -# "router ospfv3 27", -# "area 10 hello-interval 2", -# "router ospfv3 30", -# "cost 2", -# "priority 1", -# "default-metric 10", -# "router-id 2.2.2.2", -# "demand-circuit", -# "packet-size 577", -# "transmit-delay 2", -# "dead-interval 2", -# "hello-interval 1", -# "retransmit-interval 2", -# "mtu-ignore", -# "area 11 default-cost 5", -# "area 22 default-cost 6" -# ] -# -# "after": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "process_id": "10" -# }, -# { -# "authentication": { -# "disable": true -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": true, -# "hello_interval": 1, -# "mtu_ignore": true, -# "packet_size": 577, -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "transmit_delay": 2 -# } -# ] -# } +# - router ospfv3 10 +# - area 11 default-cost 5 +# - area 11 cost 11 +# - area 22 default-cost 6 +# - router ospfv3 26 +# - authentication disable +# - router ospfv3 27 +# - area 10 hello-interval 2 +# - router ospfv3 30 +# - cost 2 +# - priority 1 +# - default-metric 10 +# - router-id 2.2.2.2 +# - demand-circuit +# - packet-size 577 +# - transmit-delay 2 +# - dead-interval 2 +# - hello-interval 1 +# - retransmit-interval 2 +# - mtu-ignore +# - area 11 default-cost 5 +# - area 22 default-cost 6 # +# after: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# process_id: '10' +# - authentication: +# disable: true +# process_id: '26' +# - areas: +# - area_id: '10' +# hello_interval: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: true +# hello_interval: 1 +# mtu_ignore: true +# packet_size: 577 +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# transmit_delay: 2 # -# ------------ -# After state +# After state: # ------------ # # RP/0/RP0/CPU0:anton#show running-config router ospfv3 @@ -1771,10 +1741,6 @@ EXAMPLES = """ # area 10 # hello-interval 2 # ! -# area 20 -# ! -# area 30 -# ! # ! # router ospfv3 30 # cost 2 @@ -1794,6 +1760,15 @@ EXAMPLES = """ # area 22 # default-cost 6 # ! +# ! + +# Using replaced +# +# Before state: +# ------------- +# +# +# RP/0/RP0/CPU0:anton#show running-config router ospf # router ospfv3 10 # area 11 # cost 11 @@ -1810,10 +1785,6 @@ EXAMPLES = """ # area 10 # hello-interval 2 # ! -# area 20 -# ! -# area 30 -# ! # ! # router ospfv3 30 # cost 2 @@ -1835,16 +1806,107 @@ EXAMPLES = """ # ! # ! +- name: Replace OSPFv3 routes configurations from the device + cisco.iosxr.iosxr_ospfv3: + config: + processes: + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + - area_id: 20 + cost: 2 + default_cost: 2 + - process_id: 26 + authentication: + disable: true + state: replaced - -# Using replaced # -# ------------ -# Before state +# Task Output: # ------------ # +# before: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# process_id: '10' +# - authentication: +# disable: true +# process_id: '26' +# - areas: +# - area_id: '10' +# hello_interval: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: true +# hello_interval: 1 +# mtu_ignore: true +# packet_size: 577 +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# transmit_delay: 2 # -# RP/0/RP0/CPU0:anton#show running-config router ospf +# commands: +# - router ospfv3 27 +# - area 20 default-cost 2 +# - area 20 cost 2 +# +# after: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# process_id: '10' +# - authentication: +# disable: true +# process_id: '26' +# - areas: +# - area_id: '10' +# hello_interval: 2 +# - area_id: '20' +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: true +# hello_interval: 1 +# mtu_ignore: true +# packet_size: 577 +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# transmit_delay: 2 +# +# +# After state: +# ------------ +# +# RP/0/RP0/CPU0:anton(config)#do show running-config router ospfv3 # router ospfv3 10 # area 11 # cost 11 @@ -1862,8 +1924,8 @@ EXAMPLES = """ # hello-interval 2 # ! # area 20 -# ! -# area 30 +# cost 2 +# default-cost 2 # ! # ! # router ospfv3 30 @@ -1884,6 +1946,13 @@ EXAMPLES = """ # area 22 # default-cost 6 # ! +# ! + +# Using overridden +# +# Before state: +# ------------- +# # router ospfv3 10 # area 11 # cost 11 @@ -1901,8 +1970,8 @@ EXAMPLES = """ # hello-interval 2 # ! # area 20 -# ! -# area 30 +# cost 2 +# default-cost 2 # ! # ! # router ospfv3 30 @@ -1925,7 +1994,7 @@ EXAMPLES = """ # ! # ! -- name: Replace OSPFv3 routes configurations from the device +- name: Override existing OSPFv3 configurations from the device cisco.iosxr.iosxr_ospfv3: config: processes: @@ -1933,153 +2002,152 @@ EXAMPLES = """ areas: - area_id: 10 hello_interval: 2 + authentication: + disable: true - area_id: 20 cost: 2 default_cost: 2 + authentication: + disable: true - process_id: 26 - authentication: - disable: true - state: replaced + areas: + - area_id: 10 + hello_interval: 2 + authentication: + disable: true + state: overridden # +# Task Output: +# ------------ # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "process_id": "10" -# }, -# { -# "authentication": { -# "disable": true -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": true, -# "hello_interval": 1, -# "mtu_ignore": true, -# "packet_size": 577, -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "transmit_delay": 2 -# } -# ] -# } -# -# "commands": [ -# "router ospfv3 27", -# "area 20 default-cost 2", -# "area 20 cost 2" -# ] -# -# "after": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "process_id": "10" -# }, -# { -# "authentication": { -# "disable": true -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# }, -# { -# "area_id": "20", -# "cost": 2, -# "default_cost": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": true, -# "hello_interval": 1, -# "mtu_ignore": true, -# "packet_size": 577, -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "transmit_delay": 2 -# } -# ] -# } -# -# -# ----------- -# After state -# ----------- +# before: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# process_id: '10' +# - authentication: +# disable: true +# process_id: '26' +# - areas: +# - area_id: '10' +# hello_interval: 2 +# - area_id: '20' +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: true +# hello_interval: 1 +# mtu_ignore: true +# packet_size: 577 +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# transmit_delay: 2 # -# RP/0/RP0/CPU0:anton(config)#do show running-config router ospfv3 +# commands: +# - router ospfv3 10 +# - no area 11 default-cost 5 +# - no area 11 cost 11 +# - no area 22 default-cost 6 +# - router ospfv3 30 +# - no cost 2 +# - no priority 1 +# - no default-metric 10 +# - no router-id 2.2.2.2 +# - no demand-circuit +# - no packet-size 577 +# - no transmit-delay 2 +# - no dead-interval 2 +# - no hello-interval 1 +# - no retransmit-interval 2 +# - no mtu-ignore +# - no area 11 default-cost 5 +# - no area 22 default-cost 6 +# - router ospfv3 27 +# - area 10 authentication disable +# - area 20 authentication disable +# - router ospfv3 26 +# - no authentication disable +# - area 10 authentication disable +# - area 10 hello-interval 2 +# +# after: +# processes: +# - process_id: '10' +# - areas: +# - area_id: '10' +# authentication: +# disable: true +# hello_interval: 2 +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# disable: true +# hello_interval: 2 +# - area_id: '20' +# authentication: +# disable: true +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - process_id: '30' +# +# After state: +# ------------ +# +# RP/0/RP0/CPU0:anton#show running-config router ospfv3 +# router ospfv3 10 +# area 11 +# ! +# area 22 +# ! +# ! +# router ospfv3 26 +# area 10 +# authentication disable +# hello-interval 2 +# ! +# ! +# router ospfv3 27 +# area 10 +# authentication disable +# hello-interval 2 +# ! +# area 20 +# cost 2 +# authentication disable +# default-cost 2 +# ! +# ! +# router ospfv3 30 +# area 11 +# ! +# area 22 +# ! +# ! + +# Using deleted +# +# Before state: +# ------------- +# +# +# RP/0/RP0/CPU0:anton#show running-config router ospfv3 # router ospfv3 10 # area 11 # cost 11 @@ -2091,17 +2159,21 @@ EXAMPLES = """ # ! # router ospfv3 26 # authentication disable +# area 10 +# authentication disable +# hello-interval 2 +# ! # ! # router ospfv3 27 # area 10 +# authentication disable # hello-interval 2 # ! # area 20 # cost 2 +# authentication disable # default-cost 2 # ! -# area 30 -# ! # ! # router ospfv3 30 # cost 2 @@ -2123,165 +2195,108 @@ EXAMPLES = """ # ! # ! - -- name: Override existing OSPFv3 configurations from the device +- name: Deleted existing OSPFv3 configurations from the device cisco.iosxr.iosxr_ospfv3: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 - authentication: - disable: true - - area_id: 20 - cost: 2 - default_cost: 2 - authentication: - disable: true - - process_id: 26 - areas: - - area_id: 10 - hello_interval: 2 - authentication: - disable: true - state: overridden + - process_id: '10' + - process_id: '26' + - process_id: '27' + - process_id: '30' + state: deleted + # +# Task Output: +# ------------ +# +# before: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# process_id: '10' +# - areas: +# - area_id: '10' +# authentication: +# disable: true +# hello_interval: 2 +# authentication: +# disable: true +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# disable: true +# hello_interval: 2 +# - area_id: '20' +# authentication: +# disable: true +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: true +# hello_interval: 1 +# mtu_ignore: true +# packet_size: 577 +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# transmit_delay: 2 # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "process_id": "10" -# }, -# { -# "authentication": { -# "disable": true -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# }, -# { -# "area_id": "20", -# "cost": 2, -# "default_cost": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": true, -# "hello_interval": 1, -# "mtu_ignore": true, -# "packet_size": 577, -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "transmit_delay": 2 -# } -# ] -# } -# -# "commands": [ -# "router ospfv3 10", -# "no area 11 default-cost 5", -# "no area 11 cost 11", -# "no area 22 default-cost 6", -# "router ospfv3 30", -# "no cost 2", -# "no priority 1", -# "no default-metric 10", -# "no router-id 2.2.2.2", -# "no demand-circuit", -# "no packet-size 577", -# "no transmit-delay 2", -# "no dead-interval 2", -# "no hello-interval 1", -# "no retransmit-interval 2", -# "no mtu-ignore", -# "no area 11 default-cost 5", -# "no area 22 default-cost 6", -# "router ospfv3 26", -# "area 10 hello-interval 4" -# ] -# -# "after": { -# "processes": [ -# { -# "process_id": "10" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 4 -# } -# ], -# "authentication": { -# "disable": true -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# }, -# { -# "area_id": "20", -# "cost": 2, -# "default_cost": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "process_id": "30" -# } -# ] -# } -# -# -# ----------- -# After state -# ----------- +# commands: +# - router ospfv3 10 +# - no area 11 default-cost 5 +# - no area 11 cost 11 +# - no area 22 default-cost 6 +# - router ospfv3 26 +# - no authentication disable +# - no area 10 authentication disable +# - no area 10 hello-interval 2 +# - router ospfv3 27 +# - no area 10 authentication disable +# - no area 10 hello-interval 2 +# - no area 20 authentication disable +# - no area 20 default-cost 2 +# - no area 20 cost 2 +# - router ospfv3 30 +# - no cost 2 +# - no priority 1 +# - no default-metric 10 +# - no router-id 2.2.2.2 +# - no demand-circuit +# - no packet-size 577 +# - no transmit-delay 2 +# - no dead-interval 2 +# - no hello-interval 1 +# - no retransmit-interval 2 +# - no mtu-ignore +# - no area 11 default-cost 5 +# - no area 22 default-cost 6 # -# RP/0/RP0/CPU0:anton#show running-config router ospfv3 +# after: +# processes: +# - process_id: '10' +# - process_id: '26' +# - process_id: '27' +# - process_id: '30' +# +# After state: +# ------------ +# +# RP/0/RP0/CPU0:anton(config)#show running-config router ospfv3 # router ospfv3 10 # area 11 # ! @@ -2289,20 +2304,13 @@ EXAMPLES = """ # ! # ! # router ospfv3 26 -# authentication disable # area 10 -# hello-interval 4 # ! # ! # router ospfv3 27 # area 10 -# hello-interval 2 # ! # area 20 -# cost 2 -# default-cost 2 -# ! -# area 30 # ! # ! # router ospfv3 30 @@ -2312,143 +2320,182 @@ EXAMPLES = """ # ! # ! - - # Using deleted # -# ------------ -# Before state -# ------------ +# Before state: +# ------------- # # # RP/0/RP0/CPU0:anton#show running-config router ospfv3 # router ospfv3 10 # area 11 +# cost 11 +# default-cost 5 # ! # area 22 +# default-cost 6 # ! # ! # router ospfv3 26 # authentication disable # area 10 -# hello-interval 4 +# authentication disable +# hello-interval 2 # ! # ! # router ospfv3 27 # area 10 +# authentication disable # hello-interval 2 # ! # area 20 # cost 2 +# authentication disable # default-cost 2 # ! -# area 30 -# ! # ! # router ospfv3 30 +# cost 2 +# priority 1 +# mtu-ignore +# packet-size 577 +# dead-interval 2 +# retransmit-interval 2 +# demand-circuit +# hello-interval 1 +# transmit-delay 2 +# router-id 2.2.2.2 +# default-metric 10 # area 11 +# default-cost 5 # ! # area 22 +# default-cost 6 # ! # ! - name: Deleted existing OSPFv3 configurations from the device cisco.iosxr.iosxr_ospfv3: config: - processes: - - process_id: '10' - - process_id: '26' - - process_id: '27' - - process_id: '30' state: deleted # +# Task Output: +# ------------ +# +# before: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# process_id: '10' +# - areas: +# - area_id: '10' +# authentication: +# disable: true +# hello_interval: 2 +# authentication: +# disable: true +# process_id: '26' +# - areas: +# - area_id: '10' +# authentication: +# disable: true +# hello_interval: 2 +# - area_id: '20' +# authentication: +# disable: true +# cost: 2 +# default_cost: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: true +# hello_interval: 1 +# mtu_ignore: true +# packet_size: 577 +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# transmit_delay: 2 +# +# commands: +# - router ospfv3 10 +# - no area 11 default-cost 5 +# - no area 11 cost 11 +# - no area 22 default-cost 6 +# - router ospfv3 26 +# - no authentication disable +# - no area 10 authentication disable +# - no area 10 hello-interval 2 +# - router ospfv3 27 +# - no area 10 authentication disable +# - no area 10 hello-interval 2 +# - no area 20 authentication disable +# - no area 20 default-cost 2 +# - no area 20 cost 2 +# - router ospfv3 30 +# - no cost 2 +# - no priority 1 +# - no default-metric 10 +# - no router-id 2.2.2.2 +# - no demand-circuit +# - no packet-size 577 +# - no transmit-delay 2 +# - no dead-interval 2 +# - no hello-interval 1 +# - no retransmit-interval 2 +# - no mtu-ignore +# - no area 11 default-cost 5 +# - no area 22 default-cost 6 # -# ------------------------ -# Module Execution Result -# ------------------------ -# -# "before": { -# "processes": [ -# { -# "process_id": "10" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 4 -# } -# ], -# "authentication": { -# "disable": true -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# }, -# { -# "area_id": "20", -# "cost": 2, -# "default_cost": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "process_id": "30" -# } -# ] -# }, -# -# "commands": [ -# "router ospfv3 26", -# "no authentication disable", -# "no area 10 hello-interval 4", -# "router ospfv3 27", -# "no area 10 hello-interval 2", -# "no area 20 default-cost 2", -# "no area 20 cost 2" -# ] -# -# "after": { -# "processes": [ -# { -# "process_id": "10" -# }, -# { -# "process_id": "26" -# }, -# { -# "process_id": "27" -# }, -# { -# "process_id": "30" -# } -# ] -# } -# -# -# ----------- -# After state -# ----------- +# after: +# processes: +# - process_id: '10' +# - process_id: '26' +# - process_id: '27' +# - process_id: '30' +# +# After state: +# ------------ # # RP/0/RP0/CPU0:anton(config)#show running-config router ospfv3 # router ospfv3 10 +# area 11 +# ! +# area 22 +# ! # ! # router ospfv3 26 +# area 10 +# ! # ! # router ospfv3 27 +# area 10 +# ! +# area 20 +# ! # ! # router ospfv3 30 +# area 11 +# ! +# area 22 +# ! # ! # Using parsed +# # parsed.cfg # ------------ # router ospfv3 10 @@ -2493,72 +2540,45 @@ EXAMPLES = """ state: parsed # # -# ------------------------- -# Module Execution Result -# ------------------------- -# -# -# "parsed": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "process_id": "10" -# }, -# { -# "authentication": { -# "disable": true -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": true, -# "hello_interval": 1, -# "mtu_ignore": true, -# "packet_size": 577, -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "transmit_delay": 2 -# } -# ] -# } +# Task Output: +# ------------ +# +# parsed: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# process_id: '10' +# - authentication: +# disable: true +# process_id: '26' +# - areas: +# - area_id: '10' +# hello_interval: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: true +# hello_interval: 1 +# mtu_ignore: true +# packet_size: 577 +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# transmit_delay: 2 # # Using rendered # -# - name: Render the commands for provided configuration cisco.iosxr.iosxr_ospfv3: config: @@ -2598,35 +2618,32 @@ EXAMPLES = """ # # -# ------------------------- -# Module Execution Result -# ------------------------- -# -# -# "rendered": [ -# "router ospfv3 27", -# "area 10 hello-interval 2", -# "router ospfv3 26", -# "authentication disable", -# "router ospfv3 10", -# "area 11 default-cost 5", -# "area 11 cost 11", -# "area 22 default-cost 6", -# "router ospfv3 30", -# "cost 2", -# "priority 1", -# "default-metric 10", -# "router-id 2.2.2.2", -# "demand-circuit", -# "packet-size 577", -# "transmit-delay 2", -# "dead-interval 2", -# "hello-interval 1", -# "retransmit-interval 2", -# "mtu-ignore", -# "area 11 default-cost 5", -# "area 22 default-cost 6" -# ] +# Task Output: +# ------------ +# +# rendered: +# - router ospfv3 27 +# - area 10 hello-interval 2 +# - router ospfv3 26 +# - authentication disable +# - router ospfv3 10 +# - area 11 default-cost 5 +# - area 11 cost 11 +# - area 22 default-cost 6 +# - router ospfv3 30 +# - cost 2 +# - priority 1 +# - default-metric 10 +# - router-id 2.2.2.2 +# - demand-circuit +# - packet-size 577 +# - transmit-delay 2 +# - dead-interval 2 +# - hello-interval 1 +# - retransmit-interval 2 +# - mtu-ignore +# - area 11 default-cost 5 +# - area 22 default-cost 6 # Using gathered @@ -2634,7 +2651,7 @@ EXAMPLES = """ # Before state: # ------------- # -# RP/0/RP0/CPU0:anton#show running-config router ospf +# RP/0/RP0/CPU0:anton#show running-config router ospfv3 # router ospfv3 10 # area 11 # cost 11 @@ -2655,8 +2672,6 @@ EXAMPLES = """ # ! # area 20 # ! -# area 30 -# ! # ! # router ospfv3 30 # cost 2 @@ -2683,69 +2698,91 @@ EXAMPLES = """ state: gathered # # -# ------------------------- -# Module Execution Result -# ------------------------- -# -# "gathered": { -# "processes": [ -# { -# "areas": [ -# { -# "area_id": "11", -# "cost": 11, -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "process_id": "10" -# }, -# { -# "authentication": { -# "disable": true -# }, -# "process_id": "26" -# }, -# { -# "areas": [ -# { -# "area_id": "10", -# "hello_interval": 2 -# } -# ], -# "process_id": "27" -# }, -# { -# "areas": [ -# { -# "area_id": "11", -# "default_cost": 5 -# }, -# { -# "area_id": "22", -# "default_cost": 6 -# } -# ], -# "cost": 2, -# "dead_interval": 2, -# "default_metric": 10, -# "demand_circuit": true, -# "hello_interval": 1, -# "mtu_ignore": true, -# "packet_size": 577, -# "priority": 1, -# "process_id": "30", -# "retransmit_interval": 2, -# "router_id": "2.2.2.2", -# "transmit_delay": 2 -# } -# ] -# } +# Task Output: +# ------------ +# +# gathered: +# processes: +# - areas: +# - area_id: '11' +# cost: 11 +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# process_id: '10' +# - authentication: +# disable: true +# process_id: '26' +# - areas: +# - area_id: '10' +# hello_interval: 2 +# process_id: '27' +# - areas: +# - area_id: '11' +# default_cost: 5 +# - area_id: '22' +# default_cost: 6 +# cost: 2 +# dead_interval: 2 +# default_metric: 10 +# demand_circuit: true +# hello_interval: 1 +# mtu_ignore: true +# packet_size: 577 +# priority: 1 +# process_id: '30' +# retransmit_interval: 2 +# router_id: 2.2.2.2 +# transmit_delay: 2 # """ +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: dict + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: dict + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + - router ospfv3 10 + - area 11 default-cost 5 + - area 11 cost 11 + - area 22 default-cost 6 + +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - router ospfv3 27 + - area 10 hello-interval 2 +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +""" from ansible.module_utils.basic import AnsibleModule diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_prefix_lists.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_prefix_lists.py index 1fccc8521..c47998020 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_prefix_lists.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_prefix_lists.py @@ -101,59 +101,108 @@ options: EXAMPLES = """ # Using merged + + # Before state -#RP/0/0/CPU0:10#show running-config -#Thu Feb 4 09:38:36.245 UTC -#% No such configuration item(s) -#RP/0/0/CPU0:10# +# RP/0/0/CPU0:10#show running-config +# Thu Feb 4 09:38:36.245 UTC +# % No such configuration item(s) +# RP/0/0/CPU0:10# # + + - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_prefix_lists: - state: merged - config: - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: deny - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL_2_REMARK - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_2_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - name: pl2 - entries: - - sequence: 5 - action: remark - description: TEST_PL2_REMARK - - name: pl3 - entries: - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 + state: merged + config: + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: deny + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL_2_REMARK + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_2_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - name: pl2 + entries: + - sequence: 5 + action: remark + description: TEST_PL2_REMARK + - name: pl3 + entries: + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 + +# Task Output +# ------------- +# before: [] +# commands: +# - ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48 +# - ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK +# - ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK +# - ipv4 prefix-list pl1 4 permit 10.0.0.0/24 +# - ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK +# - ipv4 prefix-list pl3 6 permit 35.0.0.0/8 eq 0 +# after: +# - afi: ipv6 +# prefix_lists: +# - name: pl_1 +# entries: +# - prefix: 2001:db8:1234::/48 +# action: deny +# sequence: 1 +# - name: pl_2 +# entries: +# - sequence: 2 +# action: remark +# description: TEST_PL_2_REMARK +# - afi: ipv4 +# prefix_lists: +# - name: pl1 +# entries: +# - sequence: 3 +# action: remark +# description: TEST_PL1_2_REMARK +# - sequence: 4 +# action: permit +# prefix: 10.0.0.0/24 +# - name: pl2 +# entries: +# - sequence: 5 +# action: remark +# description: TEST_PL2_REMARK +# - name: pl3 +# entries: +# - sequence: 6 +# action: permit +# prefix: 35.0.0.0/8 +# eq: 0 + -# # After state: -# -#RP/0/0/CPU0:10#show running-config +# ------------ +# RP/0/0/CPU0:10#show running-config # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! # ipv6 prefix-list pl_2 -# 2 remark TEST_PL_2_REMARK +# 2 remark TEST_PL_2_REMAR # ! # ipv4 prefix-list pl1 # 3 remark TEST_PL1_2_REMARK @@ -166,91 +215,13 @@ EXAMPLES = """ # 6 permit 35.0.0.0/8 eq 0 # ! -#Module execution -# -# "after": [ -# { -# "afi": "ipv6", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "deny", -# "prefix": "2001:db8:1234::/48", -# "sequence": 1 -# } -# ], -# "name": "pl_1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL_2_REMARK", -# "sequence": 2 -# } -# ], -# "name": "pl_2" -# } -# ] -# }, -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_2_REMARK", -# "sequence": 3 -# }, -# { -# "action": "permit", -# "prefix": "10.0.0.0/24", -# "sequence": 4 -# } -# ], -# "name": "pl1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL2_REMARK", -# "sequence": 5 -# } -# ], -# "name": "pl2" -# }, -# { -# "entries": [ -# { -# "action": "permit", -# "prefix": "35.0.0.0/8", -# "sequence": 6, -# "eq": 0 -# } -# ], -# "name": "pl3" -# }, -# ] -# } -# ], -# "before": [], -# "changed": true, -# "commands": [ -# "ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48", -# "ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK", -# "ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK", -# "ipv4 prefix-list pl1 4 permit 10.0.0.0/24", -# "ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK" -# "ipv4 prefix-list pl3 6 permit 35.0.0.0/8 eq 0" -# ] -#----------------------------------------------------------------------- + # Using replaced: -# -------------- -# Before state -#RP/0/0/CPU0:10#show running-config + + +# Before state: +# ------------- +# RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -266,33 +237,100 @@ EXAMPLES = """ # 5 remark TEST_PL2_REMARK # ! # -# -- name: Replace device configurations of listed prefix lists with provided configurations + + +- name: >- + Replace device configurations of listed prefix lists with provided + configurations register: result - cisco.iosxr.iosxr_prefix_lists: &id001 + cisco.iosxr.iosxr_prefix_lists: config: - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: permit - prefix: 10.0.0.0/24 - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: permit - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL1_2 + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: permit + prefix: 10.0.0.0/24 + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: permit + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL1_2 state: replaced + + +# Task Output +# ------------- +# before: +# - afi: ipv6 +# prefix_lists: +# - entries: +# - action: deny +# prefix: 2001:db8:1234::/48 +# sequence: 1 +# name: pl_1 +# - entries: +# - action: remark +# description: TEST_PL_2_REMARK +# sequence: 2 +# name: pl_2 +# - afi: ipv4 +# prefix_lists: +# - entries: +# - action: remark +# description: TEST_PL1_2_REMARK +# sequence: 3 +# - action: permit +# prefix: 10.0.0.0/24 +# sequence: 4 +# name: pl1 +# - entries: +# - action: remark +# description: TEST_PL2_REMARK +# sequence: 5 +# name: pl2 +# commands: +# - no ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK +# - no ipv4 prefix-list pl1 4 permit 10.0.0.0/24 +# - ipv4 prefix-list pl1 3 permit 10.0.0.0/24 +# - ipv6 prefix-list pl_2 2 remark TEST_PL1_2 +# after: +# - afi: ipv6 +# prefix_lists: +# - entries: +# - action: deny +# prefix: 2001:db8:1234::/48 +# sequence: 1 +# name: pl_1 +# - entries: +# - action: remark +# description: TEST_PL1_2 +# sequence: 2 +# name: pl_2 +# - afi: ipv4 +# prefix_lists: +# - entries: +# - action: permit +# prefix: 10.0.0.0/24 +# sequence: 3 +# name: pl1 +# - entries: +# - action: remark +# description: TEST_PL2_REMARK +# sequence: 5 +# name: pl2 + + # After state: -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -308,179 +346,14 @@ EXAMPLES = """ # # Module Execution: # -# "after": [ -# { -# "afi": "ipv6", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "deny", -# "prefix": "2001:db8:1234::/48", -# "sequence": 1 -# } -# ], -# "name": "pl_1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_2", -# "sequence": 2 -# } -# ], -# "name": "pl_2" -# } -# ] -# }, -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "permit", -# "prefix": "10.0.0.0/24", -# "sequence": 3 -# } -# ], -# "name": "pl1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL2_REMARK", -# "sequence": 5 -# } -# ], -# "name": "pl2" -# } -# ] -# } -# ], -# "before": [ -# { -# "afi": "ipv6", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "deny", -# "prefix": "2001:db8:1234::/48", -# "sequence": 1 -# } -# ], -# "name": "pl_1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL_2_REMARK", -# "sequence": 2 -# } -# ], -# "name": "pl_2" -# } -# ] -# }, -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_2_REMARK", -# "sequence": 3 -# }, -# { -# "action": "permit", -# "prefix": "10.0.0.0/24", -# "sequence": 4 -# } -# ], -# "name": "pl1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL2_REMARK", -# "sequence": 5 -# } -# ], -# "name": "pl2" -# } -# ] -# } -# ], -# "changed": true, -# "commands": [ -# "no ipv4 prefix-list pl1 3 remark TEST_PL1_2_REMARK", -# "no ipv4 prefix-list pl1 4 permit 10.0.0.0/24", -# "ipv4 prefix-list pl1 3 permit 10.0.0.0/24", -# "ipv6 prefix-list pl_2 2 remark TEST_PL1_2" -# ], -# "invocation": { -# "module_args": { -# "config": [ -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "permit", -# "description": null, -# "prefix": "10.0.0.0/24", -# "sequence": 3 -# } -# ], -# "name": "pl1" -# } -# ] -# }, -# { -# "afi": "ipv6", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "permit", -# "description": null, -# "prefix": "2001:db8:1234::/48", -# "sequence": 1 -# } -# ], -# "name": "pl_1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_2", -# "prefix": null, -# "sequence": 2 -# } -# ], -# "name": "pl_2" -# } -# ] -# } -# ], -# "running_config": null, -# "state": "replaced" -# } -# } -# } -#------------------------------------------------------------------ + + # Using deleted: -# ------------- + + # Before state: -#RP/0/0/CPU0:10#show running-config +# ------------- +# RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -501,99 +374,61 @@ EXAMPLES = """ cisco.iosxr.iosxr_prefix_lists: state: deleted +# Task Output +# ------------- +# before: +# - afi: ipv6 +# prefix_lists: +# - name: pl_1 +# entries: +# - prefix: 2001:db8:1234::/48 +# action: deny +# sequence: 1 +# - name: pl_2 +# entries: +# - sequence: 2 +# action: remark +# description: TEST_PL_2_REMARK +# - afi: ipv4 +# prefix_lists: +# - name: pl1 +# entries: +# - sequence: 3 +# action: remark +# description: TEST_PL1_2_REMARK +# - sequence: 4 +# action: permit +# prefix: 10.0.0.0/24 +# - name: pl2 +# entries: +# - sequence: 5 +# action: remark +# description: TEST_PL2_REMARK +# - name: pl3 +# entries: +# - sequence: 6 +# action: permit +# prefix: 35.0.0.0/8 +# eq: 0 +# commands: +# - no ipv6 prefix-list pl_1 +# - no ipv6 prefix-list pl_2 +# - no ipv4 prefix-list pl1 +# - no ipv4 prefix-list pl2 +# - no ipv4 prefix-list pl3 +# after: [] + + # After state: -#RP/0/0/CPU0:10#show running-config -# -# -# Module Execution: -# -# "after": [], -# "before": [ -# { -# "afi": "ipv6", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "deny", -# "prefix": "2001:db8:1234::/48", -# "sequence": 1 -# } -# ], -# "name": "pl_1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_2", -# "sequence": 2 -# } -# ], -# "name": "pl_2" -# } -# ] -# }, -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "permit", -# "prefix": "10.0.0.0/24", -# "sequence": 3 -# } -# ], -# "name": "pl1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL2_REMARK", -# "sequence": 5 -# } -# ], -# "name": "pl2" -# }, -# { -# "entries": [ -# { -# "action": "permit", -# "prefix": " 35.0.0.0/8", -# "sequence": 6, -# "eq": 0 -# } -# ], -# "name": "pl3" -# }, -# ] -# } -# ], -# "changed": true, -# "commands": [ -# "no ipv6 prefix-list pl_1", -# "no ipv6 prefix-list pl_2", -# "no ipv4 prefix-list pl1", -# "no ipv4 prefix-list pl2" -# "no ipv4 prefix-list pl3" -# ], -# "invocation": { -# "module_args": { -# "config": null, -# "running_config": null, -# "state": "deleted" -# } -# } -# } -#--------------------------------------------------------------------------------- +# RP/0/0/CPU0:10#show running-config # + # using gathered: -# -------------- -# Before state: -#RP/0/0/CPU0:10#show running-config -# + + +# After state: +# ------------ +# RP/0/0/CPU0:10#show running-config # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! @@ -606,91 +441,57 @@ EXAMPLES = """ # ! # ipv4 prefix-list pl2 # 5 remark TEST_PL2_REMARK -#! +# ! # ipv4 prefix-list pl3 # 6 permit 35.0.0.0/8 eq 0 -#! +# ! + + - name: Gather ACL interfaces facts using gathered state cisco.iosxr.iosxr_prefix_lists: - state: gathered -# -# Module Execution: -# -# "gathered": [ -# { -# "afi": "ipv6", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "deny", -# "prefix": "2001:db8:1234::/48", -# "sequence": 1 -# } -# ], -# "name": "pl_1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL_2_REMARK", -# "sequence": 2 -# } -# ], -# "name": "pl_2" -# } -# ] -# }, -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_2_REMARK", -# "sequence": 3 -# }, -# { -# "action": "permit", -# "prefix": "10.0.0.0/24", -# "sequence": 4 -# } -# ], -# "name": "pl1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL2_REMARK", -# "sequence": 5 -# } -# ], -# "name": "pl2" -# }, -# { -# "entries": [ -# { -# "action": "permit", -# "prefix": "35.0.0.0/8", -# "sequence": 6, -# "eq": 0 -# } -# ], -# "name": "pl3" -# }, -# ] -# } -# ], -# "changed": false, -#-------------------------------------------------------------------------- + state: gathered + +# gathered: +# - afi: ipv6 +# prefix_lists: +# - name: pl_1 +# entries: +# - prefix: 2001:db8:1234::/48 +# action: deny +# sequence: 1 +# - name: pl_2 +# entries: +# - sequence: 2 +# action: remark +# description: TEST_PL_2_REMARK +# - afi: ipv4 +# prefix_lists: +# - name: pl1 +# entries: +# - sequence: 3 +# action: remark +# description: TEST_PL1_2_REMARK +# - sequence: 4 +# action: permit +# prefix: 10.0.0.0/24 +# - name: pl2 +# entries: +# - sequence: 5 +# action: remark +# description: TEST_PL2_REMARK +# - name: pl3 +# entries: +# - sequence: 6 +# action: permit +# prefix: 35.0.0.0/8 +# eq: 0 + + # Using parsed: -# -------------- -# + + # parsed.cfg -#------------------------------ +# ------------------------------ # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! @@ -703,129 +504,93 @@ EXAMPLES = """ # ! # ipv4 prefix-list pl2 # 5 remark TEST_PL2_REMARK -#! -# ipv4 prefix-list pl3 -# 6 permit 35.0.0.0/8 eq 0 -# -# + + - name: Parse externally provided Prefix_lists config to agnostic model cisco.iosxr.iosxr_prefix_lists: - running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" - state: parsed -# -# Module execution: -#"parsed": [ -# { -# "afi": "ipv6", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "deny", -# "prefix": "2001:db8:1234::/48", -# "sequence": 1 -# } -# ], -# "name": "pl_1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL_2_REMARK", -# "sequence": 2 -# } -# ], -# "name": "pl_2" -# } -# ] -# }, -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_2_REMARK", -# "sequence": 3 -# }, -# { -# "action": "permit", -# "prefix": "10.0.0.0/24", -# "sequence": 4 -# } -# ], -# "name": "pl1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL2_REMARK", -# "sequence": 5 -# } -# ], -# "name": "pl2" -# }, -# { -# "entries": [ -# { -# "action": "permit", -# "prefix": "35.0.0.0/8", -# "sequence": 6, -# "eq": 0 -# } -# ], -# "name": "pl3" -# }, -# ] -# } -# ] -# -#---------------------------------------------------------------------------- + running_config: '{{ lookup(''file'', ''./fixtures/parsed.cfg'') }}' + state: parsed + + +# Task Output +# ------------- +# parsed: +# - afi: ipv6 +# prefix_lists: +# - name: pl_1 +# entries: +# - prefix: 2001:db8:1234::/48 +# action: deny +# sequence: 1 +# - name: pl_2 +# entries: +# - sequence: 2 +# action: remark +# description: TEST_PL_2_REMARK +# - afi: ipv4 +# prefix_lists: +# - name: pl1 +# entries: +# - sequence: 3 +# action: remark +# description: TEST_PL1_2_REMARK +# - sequence: 4 +# action: permit +# prefix: 10.0.0.0/24 +# - name: pl2 +# entries: +# - sequence: 5 +# action: remark +# description: TEST_PL2_REMARK +# - sequence: 6 +# action: permit +# prefix: 35.0.0.0/8 +# eq: 0 + + # Using rendered: -# -------------- -# + + - name: Render platform specific commands from task input using rendered state register: result cisco.iosxr.iosxr_prefix_lists: - config: - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: deny - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL_2_REMARK - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_2_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - name: pl2 - entries: - - sequence: 5 - action: remark - description: TEST_PL2_REMARK - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 - - state: rendered -# After state: -# Module Execution: + config: + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: deny + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL_2_REMARK + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_2_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - name: pl2 + entries: + - sequence: 5 + action: remark + description: TEST_PL2_REMARK + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 + state: rendered + + +# Task Output +# ------------- # "rendered": [ # "ipv6 prefix-list pl_1 1 deny 2001:db8:1234::/48", # "ipv6 prefix-list pl_2 2 remark TEST_PL_2_REMARK", @@ -834,12 +599,13 @@ EXAMPLES = """ # "ipv4 prefix-list pl2 5 remark TEST_PL2_REMARK", # "ipv4 prefix-list pl2 6 permit 35.0.0.0/8 eq 0" # ] -# -#--------------------------------------------------------------------------------- + # Using overridden: -# -------------- + + # Before state: -#RP/0/0/CPU0:10#show running-config +# ------------- +# RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -856,175 +622,88 @@ EXAMPLES = """ # - name: Overridde all Prefix_lists configuration with provided configuration cisco.iosxr.iosxr_prefix_lists: - config: - - afi: ipv4 - prefix_lists: - - name: pl3 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_3_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 - state: overridden + config: + - afi: ipv4 + prefix_lists: + - name: pl3 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_3_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 + state: overridden + + +# Task Output +# ------------- +# before: +# - afi: ipv6 +# prefix_lists: +# - entries: +# - action: deny +# prefix: 2001:db8:1234::/48 +# sequence: 1 +# name: pl_1 +# - entries: +# - action: remark +# description: TEST_PL_2_REMARK +# sequence: 2 +# name: pl_2 +# - afi: ipv4 +# prefix_lists: +# - entries: +# - action: remark +# description: TEST_PL1_2_REMARK +# sequence: 3 +# - action: permit +# prefix: 10.0.0.0/24 +# sequence: 4 +# name: pl1 +# - entries: +# - action: remark +# description: TEST_PL2_REMARK +# sequence: 5 +# name: pl2 +# commands: +# - no ipv6 prefix-list pl_1 +# - no ipv6 prefix-list pl_2 +# - no ipv4 prefix-list pl1 +# - no ipv4 prefix-list pl2 +# - ipv4 prefix-list pl3 3 remark TEST_PL1_3_REMARK +# - ipv4 prefix-list pl3 4 permit 10.0.0.0/24 +# - ipv4 prefix-list pl3 6 permit 35.0.0.0/8 eq 0 +# after: +# - afi: ipv4 +# prefix_lists: +# - entries: +# - action: remark +# description: TEST_PL1_3_REMARK +# sequence: 3 +# - action: permit +# prefix: 10.0.0.0/24 +# sequence: 4 +# - action: permit +# prefix: 35.0.0.0/8 +# sequence: 6 +# eq: 0 +# name: pl3 + # After state: -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # -#ipv4 prefix-list pl3 +# ipv4 prefix-list pl3 # 3 remark TEST_PL1_3_REMARK # 4 permit 10.0.0.0/24 # 6 permit 35.0.0.0/8 eq 0 # ! -#! -# # Module Execution: -# "after": [ -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_3_REMARK", -# "sequence": 3 -# }, -# { -# "action": "permit", -# "prefix": "10.0.0.0/24", -# "sequence": 4 -# }, -# { -# "action": "permit", -# "prefix": "35.0.0.0/8", -# "sequence": 6, -# "eq": 0 -# } -# ], -# "name": "pl3" -# } -# ] -# } -# ], -# "before": [ -# { -# "afi": "ipv6", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "deny", -# "prefix": "2001:db8:1234::/48", -# "sequence": 1 -# } -# ], -# "name": "pl_1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL_2_REMARK", -# "sequence": 2 -# } -# ], -# "name": "pl_2" -# } -# ] -# }, -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_2_REMARK", -# "sequence": 3 -# }, -# { -# "action": "permit", -# "prefix": "10.0.0.0/24", -# "sequence": 4 -# } -# ], -# "name": "pl1" -# }, -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL2_REMARK", -# "sequence": 5 -# } -# ], -# "name": "pl2" -# } -# ] -# } -# ], -# "changed": true, -# "commands": [ -# "no ipv6 prefix-list pl_1", -# "no ipv6 prefix-list pl_2", -# "no ipv4 prefix-list pl1", -# "no ipv4 prefix-list pl2", -# "ipv4 prefix-list pl3 3 remark TEST_PL1_3_REMARK", -# "ipv4 prefix-list pl3 4 permit 10.0.0.0/24", -# "ipv4 prefix-list pl3 6 permit 35.0.0.0/8 eq 0" -# ], -# "invocation": { -# "module_args": { -# "config": [ -# { -# "afi": "ipv4", -# "prefix_lists": [ -# { -# "entries": [ -# { -# "action": "remark", -# "description": "TEST_PL1_3_REMARK", -# "prefix": null, -# "sequence": 3, -# "ge": null, -# "le": null, -# "eq": null -# }, -# { -# "action": "permit", -# "description": null, -# "prefix": "10.0.0.0/24", -# "sequence": 4, -# "ge": null, -# "le": null, -# "eq": null -# }, -# { -# "action": "permit", -# "description": null, -# "prefix": "35.0.0.0/8", -# "sequence": 6, -# "ge": null, -# "le": null, -# "eq": 0 -# } -# ], -# "name": "pl3" -# } -# ] -# } -# ], -# "running_config": null, -# "state": "overridden" -# } -# } -# } -# +# ! """ RETURN = """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_snmp_server.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_snmp_server.py index 43d7016d0..9bc685756 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_snmp_server.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_snmp_server.py @@ -910,101 +910,102 @@ EXAMPLES = """ # --------------------- EMPTY ----------------- # Merged play: # ------------ + - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_snmp_server: - config: - vrfs: - - hosts: - - community: test1 - host: 1.1.1.1 - traps: true - vrf: vrf1 - users: - - Ipv4_acl: test1 - Ipv6_acl: test2 - group: test2 - user: u1 - version: v1 - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 12 - targets: - - host: 1.1.1.2 - name: test + config: + vrfs: + - hosts: + - community: test1 + host: 1.1.1.1 + traps: true + vrf: vrf1 + users: + - Ipv4_acl: test1 + Ipv6_acl: test2 + group: test2 + user: u1 + version: v1 + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 12 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 4 + inform: + retries: 7 + chassis_id: test2 + packetsize: 490 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1024 + communities: + - name: test2 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm1 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test1 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 1 + logging_threshold_pdu_processing: 1 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + addrpool: + high: true + low: true + bfd: true + bgp: + cbgp2: true + l2tun: + sessions: true + tunnel_down: true + tunnel_up: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true - ifmib: - internal_cache_max_duration: 4 - inform: - retries: 7 - chassis_id: test2 - packetsize: 490 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1024 - communities: - - name: test2 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm1 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test1 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 1 - logging_threshold_pdu_processing: 1 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - addrpool: - high: true - low: true - bfd: true - bgp: - cbgp2: true - l2tun: - sessions: true - tunnel_down: true - tunnel_up: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true # # Commands Fired: # ------------ @@ -1315,78 +1316,78 @@ EXAMPLES = """ # ---------------- - name: Override Snmp-server configuration with provided configuration cisco.iosxr.iosxr_snmp_server: - config: - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 13 - targets: - - host: 1.1.1.2 - name: test + config: + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 13 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 5 + inform: + retries: 7 + chassis_id: test + packetsize: 491 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1025 + communities: + - name: test1 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm2 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test2 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 2 + logging_threshold_pdu_processing: 2 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true + state: overridden - ifmib: - internal_cache_max_duration: 5 - inform: - retries: 7 - chassis_id: test - packetsize: 491 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1025 - communities: - - name: test1 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm2 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test2 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 2 - logging_threshold_pdu_processing: 2 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true - state: overridden # Commands Fired: # --------------- # "commands": [ @@ -1526,78 +1527,78 @@ EXAMPLES = """ # ---------------- - name: Replace Snmp-server configuration with provided configuration cisco.iosxr.iosxr_snmp_server: - state: replaced - config: - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 13 - targets: - - host: 1.1.1.2 - name: test + state: replaced + config: + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 13 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 5 + inform: + retries: 7 + chassis_id: test + packetsize: 491 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1025 + communities: + - name: test1 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm2 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test2 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 2 + logging_threshold_pdu_processing: 2 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true - ifmib: - internal_cache_max_duration: 5 - inform: - retries: 7 - chassis_id: test - packetsize: 491 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1025 - communities: - - name: test1 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm2 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test2 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 2 - logging_threshold_pdu_processing: 2 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true # # Commands Fired: # --------------- @@ -1890,7 +1891,9 @@ EXAMPLES = """ # Using state: rendered # Rendered play: # -------------- -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_snmp_server: state: rendered config: @@ -1914,7 +1917,6 @@ EXAMPLES = """ targets: - host: 1.1.1.2 name: test - ifmib: internal_cache_max_duration: 4 inform: @@ -1987,6 +1989,7 @@ EXAMPLES = """ vc_up: true msdp_peer_state_change: true register: result + # Module Execution Result: # ------------------------ # "rendered": [ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_static_routes.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_static_routes.py index 665eb0139..3a9fa07b3 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_static_routes.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_static_routes.py @@ -172,57 +172,115 @@ EXAMPLES = """ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_static_routes: config: - - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.16/28 - next_hops: - - forward_router_address: 192.0.2.10 - interface: FastEthernet0/0/0/1 - description: LAB - metric: 120 - tag: 10 - - - interface: FastEthernet0/0/0/5 - track: ip_sla_1 - - - dest: 192.0.2.32/28 - next_hops: - - forward_router_address: 192.0.2.11 - admin_distance: 100 - - - afi: ipv6 - safi: unicast - routes: - - dest: 2001:db8:1000::/36 - next_hops: - - interface: FastEthernet0/0/0/7 - description: DC - - - interface: FastEthernet0/0/0/8 - forward_router_address: 2001:db8:2000:2::1 - - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - description: DEV - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - track: ip_sla_2 - vrflabel: 124 + - address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.16/28 + next_hops: + - forward_router_address: 192.0.2.10 + interface: FastEthernet0/0/0/1 + description: LAB + metric: 120 + tag: 10 + - interface: FastEthernet0/0/0/5 + track: ip_sla_1 + - dest: 192.0.2.32/28 + next_hops: + - forward_router_address: 192.0.2.11 + admin_distance: 100 + - afi: ipv6 + safi: unicast + routes: + - dest: '2001:db8:1000::/36' + next_hops: + - interface: FastEthernet0/0/0/7 + description: DC + - interface: FastEthernet0/0/0/8 + forward_router_address: '2001:db8:2000:2::1' + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + description: DEV + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + track: ip_sla_2 + vrflabel: 124 state: merged + +# Task Output +# ----------- +# before: [] +# commands: +# - router static +# - address-family ipv4 unicast +# - 192.0.2.16/28 192.0.2.10 FastEthernet0/0/0/1 description LAB metric 120 tag 10 +# - 192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1 +# - 192.0.2.32/28 192.0.2.11 100 +# - address-family ipv6 unicast +# - 2001:db8:1000::/36 FastEthernet0/0/0/7 description DC +# - 2001:db8:1000::/36 2001:db8:2000:2::1 FastEthernet0/0/0/8 +# - vrf DEV_SITE +# - address-family ipv4 unicast +# - 192.0.2.48/28 vrf test_1 192.0.2.12 description DEV +# - 192.0.2.80/28 vrf test_1 192.0.2.14 FastEthernet0/0/0/2 track ip_sla_2 vrflabel 124 +# after: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV +# dest_vrf: test_1 +# forward_router_address: 192.0.2.12 +# - dest: 192.0.2.80/28 +# next_hops: +# - dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# vrf: DEV_SITE + + +# # After state # ------------- # RP/0/RP0/CPU0:ios#show running-config router static @@ -272,25 +330,123 @@ EXAMPLES = """ - name: Update existing static routes configuration using merged cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - vrflabel: 2301 - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - description: rt_test_1 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + vrflabel: 2301 + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + description: rt_test_1 state: merged +# Task Output +# ----------- +# before: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV +# dest_vrf: test_1 +# forward_router_address: 192.0.2.12 +# - dest: 192.0.2.80/28 +# next_hops: +# - dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# vrf: DEV_SITE +# commands: +# - router static +# - vrf DEV_SITE +# - address-family ipv4 unicast +# - 192.0.2.48/28 vrf test_1 192.0.2.12 description DEV vrflabel 2301 +# - 192.0.2.80/28 vrf test_1 192.0.2.14 FastEthernet0/0/0/2 description rt_test_1 track ip_sla_2 vrflabel 124 +# after: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV +# dest_vrf: test_1 +# forward_router_address: 192.0.2.12 +# vrflabel: 2301 +# - dest: 192.0.2.80/28 +# next_hops: +# - description: rt_test_1 +# dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# vrf: DEV_SITE + # After state # ------------- # RP/0/RP0/CPU0:ios#show running-config router static @@ -342,19 +498,125 @@ EXAMPLES = """ - name: Replace device configurations of static routes with provided configurations cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.15 - interface: FastEthernet0/0/0/3 - description: DEV_NEW - dest_vrf: dev_test_2 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.15 + interface: FastEthernet0/0/0/3 + description: DEV_NEW + dest_vrf: dev_test_2 state: replaced +# Task Output +# ----------- +# before: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 0.0.0.0/0 +# next_hops: +# - forward_router_address: 10.0.151.254 +# interface: MgmtEth0 +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV +# dest_vrf: test_1 +# forward_router_address: 192.0.2.12 +# - forward_router_address: 192.0.3.24 +# interface: GigabitEthernet0/0/0/1 +# vrflabel: 2302 +# - dest: 192.0.2.80/28 +# next_hops: +# - dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# vrf: DEV_SITE +# commands: +# - router static +# - vrf DEV_SITE +# - address-family ipv4 unicast +# - no 192.0.2.48/28 vrf test_1 192.0.2.12 +# - no 192.0.2.48/28 192.0.3.24 GigabitEthernet0/0/0/1 +# - 192.0.2.48/28 vrf dev_test_2 192.0.2.15 FastEthernet0/0/0/3 description DEV_NEW +# after: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV_NEW +# dest_vrf: dev_test_2 +# forward_router_address: 192.0.2.15 +# interface: FastEthernet0/0/0/3 +# - dest: 192.0.2.80/28 +# next_hops: +# - dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# vrf: DEV_SITE + # After state # ------------ # RP/0/RP0/CPU0:ios#sh running-config router static @@ -405,27 +667,108 @@ EXAMPLES = """ - name: Overridde all static routes configuration with provided configuration cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_NEW - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.15 - interface: FastEthernet0/0/0/3 - description: DEV1 - - afi: ipv6 - safi: unicast - routes: - - dest: 2001:db8:3000::/36 - next_hops: - - interface: FastEthernet0/0/0/4 - forward_router_address: 2001:db8:2000:2::2 - description: PROD1 - track: ip_sla_1 + - vrf: DEV_NEW + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.15 + interface: FastEthernet0/0/0/3 + description: DEV1 + - afi: ipv6 + safi: unicast + routes: + - dest: '2001:db8:3000::/36' + next_hops: + - interface: FastEthernet0/0/0/4 + forward_router_address: '2001:db8:2000:2::2' + description: PROD1 + track: ip_sla_1 state: overridden +# Task Output +# ----------- +# before: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV +# dest_vrf: test_1 +# forward_router_address: 192.0.2.12 +# - forward_router_address: 192.0.3.24 +# interface: GigabitEthernet0/0/0/1 +# vrflabel: 2302 +# - dest: 192.0.2.80/28 +# next_hops: +# - dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# vrf: DEV_SITE +# commands: +# - router static +# - no vrf DEV_SITE +# - no address-family ipv4 unicast +# - no address-family ipv6 unicast +# - vrf DEV_NEW +# - address-family ipv4 unicast +# - 192.0.2.48/28 192.0.2.15 FastEthernet0/0/0/3 description DEV1 +# - address-family ipv6 unicast +# - 2001:db8:3000::/36 2001:db8:2000:2::2 FastEthernet0/0/0/4 description PROD1 +# track ip_sla_1 +# after: +# - vrf: DEV_NEW +# address_families: +# - afi: ipv4 +# safi: unicast +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - forward_router_address: 192.0.2.15 +# interface: FastEthernet0/0/0/3 +# description: DEV1 +# - afi: ipv6 +# safi: unicast +# routes: +# - dest: 2001:db8:3000::/36 +# next_hops: +# - interface: FastEthernet0/0/0/4 +# forward_router_address: 2001:db8:2000:2::2 +# description: PROD1 +# track: ip_sla_1 + # After state # ------------- # RP/0/RP0/CPU0:ios#sh running-config router static @@ -469,12 +812,113 @@ EXAMPLES = """ - name: Delete all destination network entries under a single AFI cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast state: deleted +# Task output +# ----------------------- +# before: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV +# dest_vrf: test_1 +# forward_router_address: 192.0.2.12 +# - forward_router_address: 192.0.3.24 +# interface: GigabitEthernet0/0/0/1 +# vrflabel: 2302 +# - dest: 192.0.2.80/28 +# next_hops: +# - dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# vrf: DEV_SITE +# commands: +# - router static +# - vrf DEV_SITE +# - no address-family ipv4 unicast +# after: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV +# dest_vrf: test_1 +# forward_router_address: 192.0.2.12 +# - forward_router_address: 192.0.3.24 +# interface: GigabitEthernet0/0/0/1 +# vrflabel: 2302 +# - dest: 192.0.2.80/28 +# next_hops: +# - dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# - vrf: DEV_SITE + # After state # ------------ @@ -523,6 +967,58 @@ EXAMPLES = """ cisco.iosxr.iosxr_static_routes: state: deleted +# Task output +# ----------------------- +# before: +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.16/28 +# next_hops: +# - description: LAB +# forward_router_address: 192.0.2.10 +# interface: FastEthernet0/0/0/1 +# metric: 120 +# tag: 10 +# - interface: FastEthernet0/0/0/5 +# track: ip_sla_1 +# - dest: 192.0.2.32/28 +# next_hops: +# - admin_distance: 100 +# forward_router_address: 192.0.2.11 +# safi: unicast +# - afi: ipv6 +# routes: +# - dest: 2001:db8:1000::/36 +# next_hops: +# - description: DC +# interface: FastEthernet0/0/0/7 +# - forward_router_address: 2001:db8:2000:2::1 +# interface: FastEthernet0/0/0/8 +# safi: unicast +# - address_families: +# - afi: ipv4 +# routes: +# - dest: 192.0.2.48/28 +# next_hops: +# - description: DEV +# dest_vrf: test_1 +# forward_router_address: 192.0.2.12 +# - forward_router_address: 192.0.3.24 +# interface: GigabitEthernet0/0/0/1 +# vrflabel: 2302 +# - dest: 192.0.2.80/28 +# next_hops: +# - dest_vrf: test_1 +# forward_router_address: 192.0.2.14 +# interface: FastEthernet0/0/0/2 +# track: ip_sla_2 +# vrflabel: 124 +# safi: unicast +# vrf: DEV_SITE +# commands: +# - no router static +# after: [] # After state # ------------ # RP/0/RP0/CPU0:ios#sh running-config router static @@ -635,26 +1131,25 @@ EXAMPLES = """ # Using rendered - name: Render platform specific commands (without connecting to the device) - cisco.iosxr.iosxr_static_routes: + cisco.iosxr.iosxr_static_routes: null config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - description: DEV - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - track: ip_sla_2 - vrflabel: 124 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + description: DEV + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + track: ip_sla_2 + vrflabel: 124 # Task Output (redacted) # ----------------------- diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_system.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_system.py index 0d0d60adb..d05608b6d 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_system.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_system.py @@ -91,17 +91,17 @@ EXAMPLES = """ hostname: iosxr01 domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com - name: remove configuration cisco.iosxr.iosxr_system: hostname: iosxr01 domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com state: absent - name: configure hostname and domain-name with vrf cisco.iosxr.iosxr_system: @@ -109,9 +109,9 @@ EXAMPLES = """ vrf: nondefault domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com - name: configure DNS lookup sources cisco.iosxr.iosxr_system: lookup_source: MgmtEth0/0/CPU0/0 @@ -119,8 +119,8 @@ EXAMPLES = """ - name: configure name servers cisco.iosxr.iosxr_system: name_servers: - - 8.8.8.8 - - 8.8.4.4 + - 8.8.8.8 + - 8.8.4.4 """ RETURN = """ diff --git a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_user.py b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_user.py index 6aefaa72d..e89d6e9eb 100644 --- a/ansible_collections/cisco/iosxr/plugins/modules/iosxr_user.py +++ b/ansible_collections/cisco/iosxr/plugins/modules/iosxr_user.py @@ -224,18 +224,18 @@ EXAMPLES = """ - name: set multiple users to group sys-admin cisco.iosxr.iosxr_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend group: sysadmin state: present - name: set multiple users to multiple groups cisco.iosxr.iosxr_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend groups: - - sysadmin - - root-system + - sysadmin + - root-system state: present - name: Change Password for User netop cisco.iosxr.iosxr_user: @@ -366,7 +366,6 @@ class PublicKeyManager(object): return out def run(self): - if self._module.params["state"] == "present": if not self._module.check_mode: key = self.convert_key_to_base64() @@ -758,7 +757,6 @@ class NCConfiguration(ConfigBase): self._module.params["update_password"] == "always" and want_item["configured_password"] is not None ): - want_item["configured_password"] = self.generate_md5_hash( want_item["configured_password"], ) diff --git a/ansible_collections/cisco/iosxr/plugins/netconf/iosxr.py b/ansible_collections/cisco/iosxr/plugins/netconf/iosxr.py index e0b1bac8d..0ed5ece03 100644 --- a/ansible_collections/cisco/iosxr/plugins/netconf/iosxr.py +++ b/ansible_collections/cisco/iosxr/plugins/netconf/iosxr.py @@ -207,11 +207,11 @@ class Netconf(NetconfBase): return guessed_os # TODO: change .xml to .data_xml, when ncclient supports data_xml on all platforms - def get(self, filter=None, remove_ns=False): + def get(self, filter=None, with_defaults=None, remove_ns=False): if isinstance(filter, list): filter = tuple(filter) try: - resp = self.m.get(filter=filter) + resp = self.m.get(filter=filter, with_defaults=with_defaults) if remove_ns: response = remove_namespaces(resp) else: diff --git a/ansible_collections/cisco/iosxr/plugins/plugin_utils/__init__.py b/ansible_collections/cisco/iosxr/plugins/plugin_utils/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/plugin_utils/__init__.py diff --git a/ansible_collections/cisco/iosxr/plugins/sub_plugins/grpc/iosxr.py b/ansible_collections/cisco/iosxr/plugins/sub_plugins/grpc/iosxr.py index 0bcfd0e72..40c693982 100644 --- a/ansible_collections/cisco/iosxr/plugins/sub_plugins/grpc/iosxr.py +++ b/ansible_collections/cisco/iosxr/plugins/sub_plugins/grpc/iosxr.py @@ -9,13 +9,14 @@ __metaclass__ = type DOCUMENTATION = """ --- author: Ansible Networking Team -grpc : iosxr -short_description: gRPC Plugin for IOS XR devices +name: grpc +short_description: gRPC plugin for IOS-XR devices description: - This gRPC plugin provides methods to connect and talk to Cisco IOS XR devices over gRPC protocol. -version_added: "" +version_added: "3.3.0" """ + import json import os import sys diff --git a/ansible_collections/cisco/iosxr/plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py b/ansible_collections/cisco/iosxr/plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py index e16c305bf..8d4ab2cac 100644 --- a/ansible_collections/cisco/iosxr/plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py +++ b/ansible_collections/cisco/iosxr/plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py @@ -10,7 +10,6 @@ import sys _b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pb2 # noqa: F401 from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database diff --git a/ansible_collections/cisco/iosxr/plugins/terminal/iosxr.py b/ansible_collections/cisco/iosxr/plugins/terminal/iosxr.py index 5b60dcd90..0c7765b28 100644 --- a/ansible_collections/cisco/iosxr/plugins/terminal/iosxr.py +++ b/ansible_collections/cisco/iosxr/plugins/terminal/iosxr.py @@ -28,7 +28,6 @@ from ansible_collections.ansible.netcommon.plugins.plugin_utils.terminal_base im class TerminalModule(TerminalBase): - terminal_stdout_re = [ re.compile(rb"[\r\n]*[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"), re.compile(rb"]]>]]>[\r\n]?"), diff --git a/ansible_collections/cisco/iosxr/plugins/test/__init__.py b/ansible_collections/cisco/iosxr/plugins/test/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/cisco/iosxr/plugins/test/__init__.py |