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 }}"