mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
fixes issue with config parents on eos modules (#21923)
eos_config module wasn't respecting config block path (parents). This patch fixes that problem. Also fixes a number of integration tests cases fixes #21903
This commit is contained in:
parent
14c05d9e2b
commit
1f9b503e89
11 changed files with 58 additions and 25 deletions
|
@ -226,6 +226,12 @@ def get_candidate(module):
|
|||
candidate.add(module.params['lines'], parents=parents)
|
||||
return candidate
|
||||
|
||||
def get_running_config(module):
|
||||
flags = []
|
||||
if module.params['defaults'] is True:
|
||||
flags.append('all')
|
||||
return get_config(module, flags)
|
||||
|
||||
def run(module, result):
|
||||
match = module.params['match']
|
||||
replace = module.params['replace']
|
||||
|
@ -233,9 +239,10 @@ def run(module, result):
|
|||
candidate = get_candidate(module)
|
||||
|
||||
if match != 'none' and replace != 'config':
|
||||
config_text = get_config(module)
|
||||
config_text = get_running_config(module)
|
||||
config = NetworkConfig(indent=3, contents=config_text)
|
||||
configobjs = candidate.difference(config, match=match, replace=replace)
|
||||
path = module.params['parents']
|
||||
configobjs = candidate.difference(config, match=match, replace=replace, path=path)
|
||||
else:
|
||||
configobjs = candidate.items
|
||||
|
||||
|
@ -256,8 +263,10 @@ def run(module, result):
|
|||
commit = not module.check_mode
|
||||
|
||||
response = load_config(module, commands, replace=replace, commit=commit)
|
||||
|
||||
if 'diff' in response:
|
||||
result['diff'] = {'prepared': response['diff']}
|
||||
|
||||
if 'session' in response:
|
||||
result['session'] = response['session']
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue