diff --git a/lib/ansible/module_utils/network/junos/junos.py b/lib/ansible/module_utils/network/junos/junos.py index 2a1d0854924..c626c466b25 100644 --- a/lib/ansible/module_utils/network/junos/junos.py +++ b/lib/ansible/module_utils/network/junos/junos.py @@ -180,9 +180,9 @@ def locked_config(module): unlock_configuration(module) -def discard_changes(module, exit=False): +def discard_changes(module): conn = get_connection(module) - return conn.discard_changes(exit=exit) + return conn.discard_changes() def get_diff(module, rollback='0'): diff --git a/lib/ansible/plugins/cliconf/junos.py b/lib/ansible/plugins/cliconf/junos.py index 32fd19a14a9..2f0cb92d495 100644 --- a/lib/ansible/plugins/cliconf/junos.py +++ b/lib/ansible/plugins/cliconf/junos.py @@ -84,10 +84,8 @@ class Cliconf(CliconfBase): command += b' and-quit' return self.send_command(command) - def discard_changes(self, rollback_id=None): - command = b'rollback' - if rollback_id is not None: - command += b' %s' % int(rollback_id) + def discard_changes(self): + command = b'rollback 0' for cmd in chain(to_list(command), b'exit'): self.send_command(cmd) diff --git a/test/integration/targets/junos_banner/tests/netconf/basic.yaml b/test/integration/targets/junos_banner/tests/netconf/basic.yaml index f53c54696ac..de1e0ed5239 100644 --- a/test/integration/targets/junos_banner/tests/netconf/basic.yaml +++ b/test/integration/targets/junos_banner/tests/netconf/basic.yaml @@ -78,6 +78,20 @@ - "result.changed == true" - "'this is my login banner' in config.xml" +- name: check mode + junos_banner: + banner: login + text: this is not the login banner you're looking for + state: present + provider: "{{ netconf }}" + register: result + check_mode: yes + +- assert: + that: + - "result.changed == true" + - "result.failed == false" + - name: delete login banner junos_banner: banner: login