diff options
author | wjohnston888 <wayne.johnston@axia.com> | 2019-05-06 17:30:49 -0400 |
---|---|---|
committer | Ganesh Nalawade <ganesh634@gmail.com> | 2019-05-06 17:30:49 -0400 |
commit | 647ed207afaa662cb700eee95f50f1a3a016b550 (patch) | |
tree | 7925cd14b225536b37bc6567998d3d8e20a8b83b | |
parent | 9db3c8a40b813306cee8e5341ec8a92cf751b8bf (diff) | |
download | ansible-647ed207afaa662cb700eee95f50f1a3a016b550.tar.gz |
Fixes Netconf_config single parameter bug (#56138)
* Fixes Netconf_config single parameter bug
Fixes 56022
fixed get_config to not require multiple parameters to just run a backup
* Add Integration test for netconf_config
Associated with #56022
tests backup through netconf only using one parameter.
* Added debug to the begin and end of file
* Fix formatting of save config. #56022
* removed blank line at end: #56022
4 files changed, 24 insertions, 2 deletions
diff --git a/lib/ansible/module_utils/network/netconf/netconf.py b/lib/ansible/module_utils/network/netconf/netconf.py index f612142b60..bd37f14931 100644 --- a/lib/ansible/module_utils/network/netconf/netconf.py +++ b/lib/ansible/module_utils/network/netconf/netconf.py @@ -76,7 +76,7 @@ def locked_config(module, target=None): unlock_configuration(module, target=target) -def get_config(module, source, filter, lock=False): +def get_config(module, source, filter=None, lock=False): conn = get_connection(module) try: locked = False diff --git a/lib/ansible/modules/network/netconf/netconf_config.py b/lib/ansible/modules/network/netconf/netconf_config.py index 9671cd4738..6117b8342b 100644 --- a/lib/ansible/modules/network/netconf/netconf_config.py +++ b/lib/ansible/modules/network/netconf/netconf_config.py @@ -381,7 +381,7 @@ def main(): if not module.check_mode: conn.commit() result['changed'] = True - else: + elif config: if module.check_mode and not supports_commit: module.warn("check mode not supported as Netconf server doesn't support candidate capability") result['changed'] = True diff --git a/test/integration/targets/netconf_config/tests/iosxr/basic.yaml b/test/integration/targets/netconf_config/tests/iosxr/basic.yaml index e69de29bb2..92a3ff6111 100644 --- a/test/integration/targets/netconf_config/tests/iosxr/basic.yaml +++ b/test/integration/targets/netconf_config/tests/iosxr/basic.yaml @@ -0,0 +1,13 @@ +--- +- debug: msg="START netconf_config iosxr/basic.yaml on connection={{ ansible_connection }}" + +- name: save config test + netconf_config: + backup: yes + register: result + +- assert: + that: + - "'backup_path' in result" + +- debug: msg="END netconf_config iosxr/basic.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/netconf_config/tests/junos/basic.yaml b/test/integration/targets/netconf_config/tests/junos/basic.yaml index 1e66280409..63e972d2e1 100644 --- a/test/integration/targets/netconf_config/tests/junos/basic.yaml +++ b/test/integration/targets/netconf_config/tests/junos/basic.yaml @@ -52,4 +52,13 @@ lines: - delete system syslog file test_netconf_config +- name: save config + netconf_config: + backup: yes + register: result + +- assert: + that: + - "'backup_path' in result" + - debug: msg="END netconf_config junos/basic.yaml on connection={{ ansible_connection }}" |