1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fix diff precedence cli_config module (#44295)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2018-08-17 12:59:24 +05:30 committed by GitHub
parent aed6722fbc
commit 899eddf9e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -207,7 +207,25 @@ def run(module, capabilities, connection, candidate, running):
elif replace in ('no', 'false', 'False'):
replace = False
if capabilities['device_operations']['supports_generate_diff']:
if capabilities['device_operations']['supports_onbox_diff']:
if diff_replace:
module.warn('diff_replace is ignored as the device supports onbox diff')
if diff_match:
module.warn('diff_mattch is ignored as the device supports onbox diff')
if diff_ignore_lines:
module.warn('diff_ignore_lines is ignored as the device supports onbox diff')
if not isinstance(candidate, list):
candidate = candidate.strip('\n').splitlines()
kwargs = {'candidate': candidate, 'commit': commit, 'replace': replace,
'comment': commit_comment}
resp = connection.edit_config(**kwargs)
if 'diff' in resp:
result['changed'] = True
elif capabilities['device_operations']['supports_generate_diff']:
kwargs = {'candidate': candidate, 'running': running}
if diff_match:
kwargs.update({'diff_match': diff_match})
@ -241,24 +259,6 @@ def run(module, capabilities, connection, candidate, running):
connection.edit_banner(**kwargs)
result['changed'] = True
elif capabilities['device_operations']['supports_onbox_diff']:
if diff_replace:
module.warn('diff_replace is ignored as the device supports onbox diff')
if diff_match:
module.warn('diff_mattch is ignored as the device supports onbox diff')
if diff_ignore_lines:
module.warn('diff_ignore_lines is ignored as the device supports onbox diff')
if not isinstance(candidate, list):
candidate = candidate.strip('\n').splitlines()
kwargs = {'candidate': candidate, 'commit': commit, 'replace': replace,
'comment': commit_comment}
resp = connection.edit_config(**kwargs)
if 'diff' in resp:
result['changed'] = True
if module._diff:
if 'diff' in resp:
result['diff'] = {'prepared': resp['diff']}