diff --git a/lib/ansible/modules/network/junos/junos_rpc.py b/lib/ansible/modules/network/junos/junos_rpc.py
index 46f6d3dabe..7cfde47500 100644
--- a/lib/ansible/modules/network/junos/junos_rpc.py
+++ b/lib/ansible/modules/network/junos/junos_rpc.py
@@ -62,7 +62,7 @@ EXAMPLES = """
junos_rpc:
rpc: get-interface-information
args:
- interface: em0
+ interface-name: em0
media: True
- name: get system information
diff --git a/test/integration/junos.yaml b/test/integration/junos.yaml
index b0e02b5736..f2b1e80489 100644
--- a/test/integration/junos.yaml
+++ b/test/integration/junos.yaml
@@ -10,5 +10,7 @@
roles:
- { role: junos_command, when: "limit_to in ['*', 'junos_command']" }
- { role: junos_config, when: "limit_to in ['*', 'junos_config']" }
+ - { role: junos_facts, when: "limit_to in ['*', 'junos_facts']" }
- { role: junos_netconf, when: "limit_to in ['*', 'junos_netconf']" }
+ - { role: junos_rpc, when: "limit_to in ['*', 'junos_rpc']" }
- { role: junos_template, when: "limit_to in ['*', 'junos_template']" }
diff --git a/test/integration/targets/junos_command/tasks/main.yaml b/test/integration/targets/junos_command/tasks/main.yaml
index 63e60969d9..4fe6a8c37c 100644
--- a/test/integration/targets/junos_command/tasks/main.yaml
+++ b/test/integration/targets/junos_command/tasks/main.yaml
@@ -1,3 +1,4 @@
---
- { include: netconf_xml.yaml, tags: ['netconf', 'xml'] }
- { include: netconf_text.yaml, tags: ['netconf', 'text'] }
+- { include: netconf_json.yaml, tags: ['netconf', 'json'] }
diff --git a/test/integration/targets/junos_command/tasks/netconf_json.yaml b/test/integration/targets/junos_command/tasks/netconf_json.yaml
new file mode 100644
index 0000000000..2384bf669e
--- /dev/null
+++ b/test/integration/targets/junos_command/tasks/netconf_json.yaml
@@ -0,0 +1,15 @@
+---
+- name: collect netconf_json test cases with json encoding
+ find:
+ paths: "{{ role_path }}/tests/netconf_json"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/junos_command/tasks/netconf_text.yaml b/test/integration/targets/junos_command/tasks/netconf_text.yaml
index 1495e35912..d830ac064f 100644
--- a/test/integration/targets/junos_command/tasks/netconf_text.yaml
+++ b/test/integration/targets/junos_command/tasks/netconf_text.yaml
@@ -1,5 +1,5 @@
---
-- name: collect netconf_text test cases with xml encoding
+- name: collect netconf_text test cases with text encoding
find:
paths: "{{ role_path }}/tests/netconf_text"
patterns: "{{ testcase }}.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/bad_operator.yaml b/test/integration/targets/junos_command/tests/netconf_json/bad_operator.yaml
new file mode 100644
index 0000000000..03ada82d34
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/bad_operator.yaml
@@ -0,0 +1,21 @@
+---
+- debug: msg="START netconf_json/bad_operator.yaml"
+
+- name: test bad operator with json encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ wait_for:
+ - "result[0]['software-information'][0]['host-name'][0]['data'] foo fxp0"
+ format: json
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg is defined"
+
+- debug: msg="END netconf_json/bad_operator.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/contains.yaml b/test/integration/targets/junos_command/tests/netconf_json/contains.yaml
new file mode 100644
index 0000000000..51210f7b8d
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/contains.yaml
@@ -0,0 +1,22 @@
+---
+- debug: msg="START netconf_json/contains.yaml"
+
+- name: test contains operator with json encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[0]['software-information'][0]['host-name'][0]['data'] contains {{ inventory_hostname_short }}"
+ - "result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] contains fxp0"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_json/contains.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/equal.yaml b/test/integration/targets/junos_command/tests/netconf_json/equal.yaml
new file mode 100644
index 0000000000..2184880426
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/equal.yaml
@@ -0,0 +1,40 @@
+---
+- debug: msg="START netconf_json/equal.yaml"
+
+- name: test == operator with xml encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ wait_for:
+ - "result[0]['software-information'][0]['host-name'][0]['data'] == {{ inventory_hostname_short }}"
+ - "result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] == fxp0"
+ format: json
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test eq operator with json encoding
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ wait_for:
+ - "result[0]['software-information'][0]['host-name'][0]['data'] eq {{ inventory_hostname_short }}"
+ - "result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] eq fxp0"
+ format: json
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_json/equal.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/greaterthan.yaml b/test/integration/targets/junos_command/tests/netconf_json/greaterthan.yaml
new file mode 100644
index 0000000000..923152c33d
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/greaterthan.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_json/greaterthan.yaml"
+
+- name: test gt operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] gt 1500"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test > operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] > 1500"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_json/greaterthan.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/greaterthanorequal.yaml b/test/integration/targets/junos_command/tests/netconf_json/greaterthanorequal.yaml
new file mode 100644
index 0000000000..9f52587144
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/greaterthanorequal.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_json/greaterthanorequal.yaml"
+
+- name: test ge operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] ge 1514"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test >= operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] >= 1514"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_json/greaterthanorequal.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/lessthan.yaml b/test/integration/targets/junos_command/tests/netconf_json/lessthan.yaml
new file mode 100644
index 0000000000..68e634d063
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/lessthan.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_json/lessthan.yaml"
+
+- name: test lt operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] lt 9000"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test < operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] lt 9000"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_json/lessthan.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/lessthanorequal.yaml b/test/integration/targets/junos_command/tests/netconf_json/lessthanorequal.yaml
new file mode 100644
index 0000000000..1242bbf1f2
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/lessthanorequal.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_json/lessthanorequal.yaml"
+
+- name: test le operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] le 1514"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test <= operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[1]['interface-information'][0]['physical-interface'][0]['mtu'][0]['data'] <= 1514"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_json/lessthanorequal.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/notequal.yaml b/test/integration/targets/junos_command/tests/netconf_json/notequal.yaml
new file mode 100644
index 0000000000..b737b597c1
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/notequal.yaml
@@ -0,0 +1,38 @@
+---
+- debug: msg="START netconf_json/notequal.yaml"
+
+- name: test neq operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[0]['software-information'][0]['host-name'][0]['data'] neq localhost"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: test != operator
+ junos_command:
+ commands:
+ - show version
+ - show interfaces fxp0
+ format: json
+ wait_for:
+ - "result[0]['software-information'][0]['host-name'][0]['data'] != localhost"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_json/notequal.yaml"
diff --git a/test/integration/targets/junos_command/tests/netconf_json/output.yaml b/test/integration/targets/junos_command/tests/netconf_json/output.yaml
new file mode 100644
index 0000000000..324e2252b4
--- /dev/null
+++ b/test/integration/targets/junos_command/tests/netconf_json/output.yaml
@@ -0,0 +1,32 @@
+---
+- debug: msg="START netconf_json/output.yaml"
+
+- name: get output for single command
+ junos_command:
+ commands: ['show version']
+ format: json
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- name: get output for multiple commands
+ junos_command:
+ commands:
+ - show version
+ - show route
+ format: json
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.stdout is defined"
+ - "result.stdout_lines is defined"
+
+- debug: msg="END netconf_json/output.yaml"
diff --git a/test/integration/targets/junos_config/templates/basic/config.set b/test/integration/targets/junos_config/templates/basic/config.set
new file mode 100644
index 0000000000..1a34192d76
--- /dev/null
+++ b/test/integration/targets/junos_config/templates/basic/config.set
@@ -0,0 +1 @@
+set interfaces lo0 unit 0 family inet address 1.1.1.1/32
diff --git a/test/integration/targets/junos_config/templates/basic/config.xml b/test/integration/targets/junos_config/templates/basic/config.xml
new file mode 100644
index 0000000000..9feb97ceaf
--- /dev/null
+++ b/test/integration/targets/junos_config/templates/basic/config.xml
@@ -0,0 +1,15 @@
+
+
+ lo0
+
+ 0
+
+
+
+ 1.1.1.1/32
+
+
+
+
+
+
diff --git a/test/integration/targets/junos_config/tests/netconf/src_basic.yaml b/test/integration/targets/junos_config/tests/netconf/src_basic.yaml
index c4bfbfd667..7c9f87eb0a 100644
--- a/test/integration/targets/junos_config/tests/netconf/src_basic.yaml
+++ b/test/integration/targets/junos_config/tests/netconf/src_basic.yaml
@@ -8,7 +8,7 @@
- delete interfaces lo0
provider: "{{ netconf }}"
-- name: configure device with config
+- name: configure device with text config
junos_config:
src: basic/config.j2
provider: "{{ netconf }}"
@@ -28,4 +28,77 @@
that:
- "result.changed == false"
+- name: teardown
+ junos_config:
+ lines:
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: configure device with set config
+ junos_config:
+ src: basic/config.set
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'address 1.1.1.1/32' in result.diff.prepared"
+
+- name: check device with config
+ junos_config:
+ src: basic/config.set
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ junos_config:
+ lines:
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+ register: result
+- assert:
+ that:
+ - "result.changed == true"
+
+- name: configure device with xml config
+ junos_config:
+ src: basic/config.xml
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'address 1.1.1.1/32' in result.diff.prepared"
+
+- name: check device with config
+ junos_config:
+ src: basic/config.xml
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: teardown
+ junos_config:
+ lines:
+ - delete interfaces lo0
+ provider: "{{ netconf }}"
+ register: result
+- assert:
+ that:
+ - "result.changed == true"
+
- debug: msg="END netconf/src_basic.yaml"
diff --git a/test/integration/targets/junos_facts/defaults/main.yaml b/test/integration/targets/junos_facts/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/junos_facts/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/junos_facts/tasks/main.yaml b/test/integration/targets/junos_facts/tasks/main.yaml
new file mode 100644
index 0000000000..cc27f174fd
--- /dev/null
+++ b/test/integration/targets/junos_facts/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: netconf.yaml, tags: ['netconf'] }
diff --git a/test/integration/targets/junos_facts/tasks/netconf.yaml b/test/integration/targets/junos_facts/tasks/netconf.yaml
new file mode 100644
index 0000000000..c6a07db9a6
--- /dev/null
+++ b/test/integration/targets/junos_facts/tasks/netconf.yaml
@@ -0,0 +1,14 @@
+- name: collect netconf test cases
+ find:
+ paths: "{{ role_path }}/tests/netconf"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/junos_facts/tests/netconf/facts.yaml b/test/integration/targets/junos_facts/tests/netconf/facts.yaml
new file mode 100644
index 0000000000..a6e22c42e1
--- /dev/null
+++ b/test/integration/targets/junos_facts/tests/netconf/facts.yaml
@@ -0,0 +1,103 @@
+---
+- debug: msg="START netconf/facts.yaml"
+
+
+- name: Collect default facts from device
+ junos_facts:
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'ansible_net_hostname' in result['ansible_facts']"
+ - "'ansible_net_interfaces' in result['ansible_facts']"
+ - "'ansible_net_memfree_mb' in result['ansible_facts']"
+
+- name: Collect config facts from device
+ junos_facts:
+ gather_subset: config
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'ansible_net_config' in result['ansible_facts']"
+ - "'ansible_net_interfaces' not in result['ansible_facts']"
+ - "'ansible_net_memfree_mb' not in result['ansible_facts']"
+
+- name: Collect all facts from device except hardware
+ junos_facts:
+ gather_subset: "!hardware"
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'ansible_net_config' in result['ansible_facts']"
+ - "'ansible_net_interfaces' in result['ansible_facts']"
+ - "'ansible_net_memfree_mb' not in result['ansible_facts']"
+
+- name: Invalid facts subset value
+ junos_facts:
+ gather_subset: test
+ provider: "{{ netconf }}"
+ ignore_errors: yes
+ register: result
+
+- assert:
+ that:
+ - "result.failed == true"
+ - "result.msg == 'Subset must be one of [hardware, default, interfaces, config], got test'"
+
+- name: Collect config facts from device in set format
+ junos_facts:
+ gather_subset: config
+ config_format: set
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'set system host-name {{ inventory_hostname_short }}' in result['ansible_facts']['ansible_net_config']"
+
+- name: Collect config facts from device in xml format
+ junos_facts:
+ gather_subset: config
+ config_format: xml
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'{{ inventory_hostname_short }}' in result['ansible_facts']['ansible_net_config']"
+
+- name: Collect config facts from device in json format
+ junos_facts:
+ gather_subset: config
+ config_format: json
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'\"data\" : \"{{ inventory_hostname_short }}\"' in result['ansible_facts']['ansible_net_config']"
+
+- name: Collect config facts from device in text format
+ junos_facts:
+ gather_subset: config
+ config_format: text
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'system {\n host-name {{ inventory_hostname_short }};' in result['ansible_facts']['ansible_net_config']"
+
+- debug: msg="END netconf/facts.yaml"
diff --git a/test/integration/targets/junos_rpc/defaults/main.yaml b/test/integration/targets/junos_rpc/defaults/main.yaml
new file mode 100644
index 0000000000..9ef5ba5165
--- /dev/null
+++ b/test/integration/targets/junos_rpc/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/test/integration/targets/junos_rpc/tasks/main.yaml b/test/integration/targets/junos_rpc/tasks/main.yaml
new file mode 100644
index 0000000000..cc27f174fd
--- /dev/null
+++ b/test/integration/targets/junos_rpc/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: netconf.yaml, tags: ['netconf'] }
diff --git a/test/integration/targets/junos_rpc/tasks/netconf.yaml b/test/integration/targets/junos_rpc/tasks/netconf.yaml
new file mode 100644
index 0000000000..c6a07db9a6
--- /dev/null
+++ b/test/integration/targets/junos_rpc/tasks/netconf.yaml
@@ -0,0 +1,14 @@
+- name: collect netconf test cases
+ find:
+ paths: "{{ role_path }}/tests/netconf"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+ include: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/test/integration/targets/junos_rpc/tests/netconf/rpc.yaml b/test/integration/targets/junos_rpc/tests/netconf/rpc.yaml
new file mode 100644
index 0000000000..81434cdba4
--- /dev/null
+++ b/test/integration/targets/junos_rpc/tests/netconf/rpc.yaml
@@ -0,0 +1,72 @@
+---
+- debug: msg="START netconf/rpc.yaml"
+
+- name: Execute RPC on device
+ junos_rpc:
+ rpc: get-interface-information
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'\nem0\n' in result['xml']"
+ - "result.output is defined"
+
+- name: Execute RPC with args on device
+ junos_rpc:
+ rpc: get-interface-information
+ args:
+ interface-name: em0
+ media: True
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "'\nem0\n' in result['xml']"
+ - "'\nlo0\n' not in result['xml']"
+
+- name: Execute RPC on device and get output in text format
+ junos_rpc:
+ rpc: get-interface-information
+ output: text
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.output is defined"
+ - "result.output_lines is defined"
+ - "'Physical interface: em0' in result['output']"
+
+- name: Execute RPC on device and get output in json format
+ junos_rpc:
+ rpc: get-interface-information
+ output: json
+ args:
+ interface-name: em0
+ media: True
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+ - "result.output is defined"
+ - "result['output']['interface-information'][0]['physical-interface'][0]['name'][0]['data'] == \"em0\""
+
+- name: Execute invalid RPC
+ junos_rpc:
+ rpc: show-interface-information
+ provider: "{{ netconf }}"
+ register: result
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "result.failed == true"
+
+- debug: msg="END netconf/rpc.yaml"