parent
d24e9ab4bb
commit
81f0b70f11
3 changed files with 64 additions and 8 deletions
|
@ -149,18 +149,11 @@ def map_params_to_obj(module):
|
|||
def load_config(module, config, commit=False):
|
||||
conn = get_connection(module)
|
||||
try:
|
||||
resp = conn.edit_config(to_list(config) + ['top'])
|
||||
resp = conn.edit_config(to_list(config) + ['top'], commit)
|
||||
except ConnectionError as exc:
|
||||
module.fail_json(msg=to_text(exc, errors='surrogate_then_replace'))
|
||||
|
||||
diff = resp.get('diff', '')
|
||||
if diff:
|
||||
if commit:
|
||||
commit_configuration(module)
|
||||
|
||||
else:
|
||||
discard_changes(module)
|
||||
|
||||
return to_text(diff, errors='surrogate_then_replace').strip()
|
||||
|
||||
|
||||
|
|
|
@ -59,4 +59,29 @@
|
|||
- name: Ensure we can communicate over netconf
|
||||
include: "{{ role_path }}/tests/utils/junos_command.yaml ansible_connection=netconf ansible_port=830 is_ignore_errors=false"
|
||||
|
||||
- name: Change port (check mode)
|
||||
junos_netconf:
|
||||
state: present
|
||||
netconf_port: 12345
|
||||
register: result
|
||||
check_mode: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: wait for netconf server to come up
|
||||
pause:
|
||||
seconds: 10
|
||||
|
||||
- name: Ensure we can NOT communicate over non-default port
|
||||
include: "{{ role_path }}/tests/utils/junos_command.yaml ansible_connection=netconf ansible_port=12345 is_ignore_errors=true"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- name: Ensure we can communicate over default port
|
||||
include: "{{ role_path }}/tests/utils/junos_command.yaml ansible_connection=netconf ansible_port=830 is_ignore_errors=false"
|
||||
|
||||
- debug: msg="END netconf/changeport.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -25,6 +25,23 @@
|
|||
- name: Ensure we can communicate over netconf
|
||||
include: "{{ role_path }}/tests/utils/junos_command.yaml ansible_connection=netconf ansible_port=830 is_ignore_errors=false"
|
||||
|
||||
- name: Disable netconf (check mode)
|
||||
junos_netconf:
|
||||
state: absent
|
||||
register: result
|
||||
check_mode: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: wait for persistent socket to timeout
|
||||
pause:
|
||||
seconds: 120
|
||||
|
||||
- name: Ensure we can communicate over netconf
|
||||
include: "{{ role_path }}/tests/utils/junos_command.yaml ansible_connection=netconf ansible_port=830 is_ignore_errors=false"
|
||||
|
||||
# Disable netconf
|
||||
- name: Disable netconf
|
||||
junos_netconf:
|
||||
|
@ -55,6 +72,27 @@
|
|||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- name: Enable netconf (check mode)
|
||||
junos_netconf:
|
||||
state: present
|
||||
register: result
|
||||
check_mode: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: wait for netconf server to come up
|
||||
pause:
|
||||
seconds: 10
|
||||
|
||||
- name: Ensure we can NOT talk via netconf
|
||||
include: "{{ role_path }}/tests/utils/junos_command.yaml ansible_connection=netconf ansible_port=830 is_ignore_errors=true"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
|
||||
- name: re-enable netconf
|
||||
junos_netconf:
|
||||
state: present
|
||||
|
|
Loading…
Reference in a new issue