From 647ed207afaa662cb700eee95f50f1a3a016b550 Mon Sep 17 00:00:00 2001 From: wjohnston888 Date: Mon, 6 May 2019 17:30:49 -0400 Subject: [PATCH] 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 --- lib/ansible/module_utils/network/netconf/netconf.py | 2 +- .../modules/network/netconf/netconf_config.py | 2 +- .../targets/netconf_config/tests/iosxr/basic.yaml | 13 +++++++++++++ .../targets/netconf_config/tests/junos/basic.yaml | 9 +++++++++ 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 f612142b60f..bd37f14931a 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 9671cd4738c..6117b8342bb 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 e69de29bb2d..92a3ff6111d 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 1e662804091..63e972d2e1c 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 }}"