Skip to content

Commit

Permalink
fix *os_config module backward diff (ansible#35332)
Browse files Browse the repository at this point in the history
Signed-off-by: Trishna Guha <[email protected]>
  • Loading branch information
trishnaguha authored Jan 25, 2018
1 parent 2f46f8f commit cff4a2d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lib/ansible/modules/network/eos/eos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion lib/ansible/modules/network/ios/ios_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion lib/ansible/modules/network/nxos/nxos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cff4a2d

Please sign in to comment.