diff --git a/lib/ansible/modules/network/eos/eos_config.py b/lib/ansible/modules/network/eos/eos_config.py index 574c89d3137..fbb765fd003 100644 --- a/lib/ansible/modules/network/eos/eos_config.py +++ b/lib/ansible/modules/network/eos/eos_config.py @@ -458,9 +458,16 @@ def main(): base_config = NetworkConfig(indent=1, contents=contents, ignore_lines=diff_ignore_lines) if running_config.sha1 != base_config.sha1: + if module.params['diff_against'] == 'intended': + before = running_config + after = base_config + elif module.params['diff_against'] in ('startup', 'running'): + before = base_config + after = running_config + result.update({ 'changed': True, - 'diff': {'before': str(base_config), 'after': str(running_config)} + 'diff': {'before': str(before), 'after': str(after)} }) module.exit_json(**result) diff --git a/lib/ansible/modules/network/ios/ios_config.py b/lib/ansible/modules/network/ios/ios_config.py index e37e5c88abc..8c367909f0b 100644 --- a/lib/ansible/modules/network/ios/ios_config.py +++ b/lib/ansible/modules/network/ios/ios_config.py @@ -532,9 +532,16 @@ def main(): base_config = NetworkConfig(indent=1, contents=contents, ignore_lines=diff_ignore_lines) if running_config.sha1 != base_config.sha1: + if module.params['diff_against'] == 'intended': + before = running_config + after = base_config + elif module.params['diff_against'] in ('startup', 'running'): + before = base_config + after = running_config + result.update({ 'changed': True, - 'diff': {'before': str(base_config), 'after': str(running_config)} + 'diff': {'before': str(before), 'after': str(after)} }) module.exit_json(**result) diff --git a/lib/ansible/modules/network/nxos/nxos_config.py b/lib/ansible/modules/network/nxos/nxos_config.py index 02374043ca3..d1b7b90046c 100644 --- a/lib/ansible/modules/network/nxos/nxos_config.py +++ b/lib/ansible/modules/network/nxos/nxos_config.py @@ -493,9 +493,16 @@ def main(): base_config = NetworkConfig(indent=1, contents=contents, ignore_lines=diff_ignore_lines) if running_config.sha1 != base_config.sha1: + if module.params['diff_against'] == 'intended': + before = running_config + after = base_config + elif module.params['diff_against'] in ('startup', 'running'): + before = base_config + after = running_config + result.update({ 'changed': True, - 'diff': {'before': str(base_config), 'after': str(running_config)} + 'diff': {'before': str(before), 'after': str(after)} }) module.exit_json(**result)