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: