mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
fix diff precedence cli_config module (#44295)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
@@ -207,7 +207,25 @@ def run(module, capabilities, connection, candidate, running):
|
|||||||
elif replace in ('no', 'false', 'False'):
|
elif replace in ('no', 'false', 'False'):
|
||||||
replace = 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}
|
kwargs = {'candidate': candidate, 'running': running}
|
||||||
if diff_match:
|
if diff_match:
|
||||||
kwargs.update({'diff_match': diff_match})
|
kwargs.update({'diff_match': diff_match})
|
||||||
@@ -241,24 +259,6 @@ def run(module, capabilities, connection, candidate, running):
|
|||||||
connection.edit_banner(**kwargs)
|
connection.edit_banner(**kwargs)
|
||||||
result['changed'] = True
|
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 module._diff:
|
||||||
if 'diff' in resp:
|
if 'diff' in resp:
|
||||||
result['diff'] = {'prepared': resp['diff']}
|
result['diff'] = {'prepared': resp['diff']}
|
||||||
|
|||||||
Reference in New Issue
Block a user