From 398f4b82335580fd4e0f804f559bff3ac2f432fb Mon Sep 17 00:00:00 2001 From: Martin Ouimet Date: Mon, 27 May 2019 08:00:14 -0400 Subject: [PATCH] Added the 'show commit config diff' output available from the IOSXR device (#54875) --- lib/ansible/module_utils/network/iosxr/iosxr.py | 5 +++++ lib/ansible/plugins/cliconf/iosxr.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/ansible/module_utils/network/iosxr/iosxr.py b/lib/ansible/module_utils/network/iosxr/iosxr.py index 8825ca0cea3..a89f4f7cc03 100644 --- a/lib/ansible/module_utils/network/iosxr/iosxr.py +++ b/lib/ansible/module_utils/network/iosxr/iosxr.py @@ -471,6 +471,11 @@ def load_config(module, command_filter, commit=False, replace=False, response = conn.edit_config(candidate=command_filter, commit=commit, admin=admin, replace=replace, comment=comment, label=label) if module._diff: diff = response.get('diff') + + # Overwrite the default diff by the IOS XR commit diff. + # See plugins/cliconf/iosxr.py for this key set: show_commit_config_diff + diff = response.get('show_commit_config_diff') + except ConnectionError as exc: module.fail_json(msg=to_text(exc, errors='surrogate_then_replace')) diff --git a/lib/ansible/plugins/cliconf/iosxr.py b/lib/ansible/plugins/cliconf/iosxr.py index b63aa83e6e5..bf78a9e03f9 100644 --- a/lib/ansible/plugins/cliconf/iosxr.py +++ b/lib/ansible/plugins/cliconf/iosxr.py @@ -116,6 +116,11 @@ class Cliconf(CliconfBase): results.append(self.send_command(**line)) requests.append(cmd) + # Before any commit happend, we can get a real configuration + # diff from the device and make it available by the iosxr_config module. + # This information can be usefull either in check mode or normal mode. + resp['show_commit_config_diff'] = self.get('show commit changes diff') + if commit: self.commit(comment=comment, label=label, replace=replace) else: