diff --git a/changelogs/fragments/fix_iosxr_config.yaml b/changelogs/fragments/fix_iosxr_config.yaml new file mode 100644 index 000000000..1001232fc --- /dev/null +++ b/changelogs/fragments/fix_iosxr_config.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - iosxr_config Add updates option in return value(https://github.com/ansible-collections/cisco.iosxr/issues/438). diff --git a/docs/cisco.iosxr.iosxr_config_module.rst b/docs/cisco.iosxr.iosxr_config_module.rst index 44adc4352..a358ac0ec 100644 --- a/docs/cisco.iosxr.iosxr_config_module.rst +++ b/docs/cisco.iosxr.iosxr_config_module.rst @@ -517,6 +517,23 @@ Common return values are documented `here 22:28:34 + + +
+ updates + +
+ list +
+ + If there are commands to run against the host + +
The set of commands that will be pushed to the remote device
+
+
Sample:
+
['hostname foo', 'router ospf 1', 'router-id 1.1.1.1']
+ +

diff --git a/plugins/modules/iosxr_config.py b/plugins/modules/iosxr_config.py index a2eeb8f14..bef0477fd 100644 --- a/plugins/modules/iosxr_config.py +++ b/plugins/modules/iosxr_config.py @@ -228,6 +228,11 @@ 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 @@ -392,6 +397,7 @@ def run(module, result): commands.extend(module.params["after"]) result["commands"] = commands + result["updates"] = commands commit = not check_mode diff = load_config( diff --git a/tests/unit/modules/network/iosxr/test_iosxr_config.py b/tests/unit/modules/network/iosxr/test_iosxr_config.py index 8a2dacf42..9ac6866af 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_config.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_config.py @@ -345,3 +345,17 @@ def test_iosxr_config_replace_config_requires_src(self): args = dict(replace="config") set_module_args(args) self.execute_module(failed=True) + + def test_iosxr_config_updates(self): + src = load_fixture("iosxr_config_src.cfg") + set_module_args(dict(src=src)) + self.conn.get_diff = MagicMock( + return_value=self.cliconf_obj.get_diff(src, self.running_config), + ) + commands = [ + "hostname foo", + "interface GigabitEthernet0/0", + "no ip address", + ] + result = self.execute_module(changed=True, commands=commands) + self.assertEqual(sorted(result["updates"]), sorted(commands))