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

Fetch ios default config is defaults is enabled (#39741)

If default option is eanbled fetch the current
running configuration by adding `all` or `full`
flag
This commit is contained in:
Ganesh Nalawade 2018-05-08 09:38:08 +05:30 committed by GitHub
parent eb430b2e57
commit 09e3b5c92b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -351,13 +351,13 @@ def load_banners(module, banners):
run_commands(module, ['\n']) run_commands(module, ['\n'])
def get_running_config(module, current_config=None): def get_running_config(module, current_config=None, flags=None):
contents = module.params['running_config'] contents = module.params['running_config']
if not contents: if not contents:
if not module.params['defaults'] and current_config: if not module.params['defaults'] and current_config:
contents, banners = extract_banners(current_config.config_text) contents, banners = extract_banners(current_config.config_text)
else: else:
flags = get_defaults_flag(module) if module.params['defaults'] else []
contents = get_config(module, flags=flags) contents = get_config(module, flags=flags)
contents, banners = extract_banners(contents) contents, banners = extract_banners(contents)
return NetworkConfig(indent=1, contents=contents), banners return NetworkConfig(indent=1, contents=contents), banners
@ -445,9 +445,10 @@ def main():
result['warnings'] = warnings result['warnings'] = warnings
config = None config = None
flags = get_defaults_flag(module) if module.params['defaults'] else []
if module.params['backup'] or (module._diff and module.params['diff_against'] == 'running'): if module.params['backup'] or (module._diff and module.params['diff_against'] == 'running'):
contents = get_config(module) contents = get_config(module, flags=flags)
config = NetworkConfig(indent=1, contents=contents) config = NetworkConfig(indent=1, contents=contents)
if module.params['backup']: if module.params['backup']:
result['__backup__'] = contents result['__backup__'] = contents
@ -460,7 +461,7 @@ def main():
candidate, want_banners = get_candidate(module) candidate, want_banners = get_candidate(module)
if match != 'none': if match != 'none':
config, have_banners = get_running_config(module, config) config, have_banners = get_running_config(module, config, flags=flags)
path = module.params['parents'] path = module.params['parents']
configobjs = candidate.difference(config, path=path, match=match, replace=replace) configobjs = candidate.difference(config, path=path, match=match, replace=replace)
else: else: