collection 교체

This commit is contained in:
정훈 변
2024-02-23 16:37:40 +09:00
parent b494779b5b
commit 3fd554eee9
38862 changed files with 220204 additions and 6600073 deletions

View File

@@ -1,12 +1,12 @@
---
- name: "{{ parser }} Run command and parse with native"
- name: "Run command and parse with {{ parser }}"
ansible.utils.cli_parse:
command: "ps -ef"
parser:
name: ansible.netcommon.native
set_fact: myfact
- name: "{{ parser }} Run command which output nothing and parse with native"
- name: "Run command which output nothing and parse with {{ parser }}"
ansible.utils.cli_parse:
command: "touch test_output"
parser:
@@ -14,7 +14,8 @@
set_fact: myfact
register: result
- assert:
- name: "Check output"
ansible.builtin.assert:
that:
- result.ansible_facts.myfact == {}
- result.changed == false

View File

@@ -1,20 +1,20 @@
---
- name: "{{ parser }} Run command and parse with native"
- name: "Run command and parse with {{ parser }}"
ansible.utils.cli_parse:
command: "ps -ef"
parser:
name: ansible.netcommon.native
register: ps_out
- name: "{{ parser }} Check parser output"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ item }}"
with_items:
- "{{ ps_out['stdout'] is defined }}"
- "{{ ps_out['stdout_lines'] is defined }}"
- "{{ ps_out['parsed'] is defined }}"
- name: "{{ parser }} Run command and parse with native"
- name: "Run command and parse with {{ parser }}"
ansible.utils.cli_parse:
command: "iptables --list"
parser:
@@ -22,8 +22,8 @@
become: true
register: ipt_out
- name: "{{ parser }}Check parser output"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ item }}"
with_items:
- "{{ ipt_out['stdout'] is defined }}"

View File

@@ -1,57 +1,63 @@
---
- name: Gather facts for non-network to get ansible_distribution
gather_facts:
ansible.builtin.gather_facts:
when: ansible_network_os is not defined
- name: Set a short name
set_fact:
os: "{{ ansible_distribution|d or (ansible_network_os|d('')).split('.')[-1] }}"
ansible.builtin.set_fact:
os: "{{ ansible_distribution | d or (ansible_network_os | d('')).split('.')[-1] }}"
- include_tasks: "{{ os|lower }}_native.yaml"
- name: Run native parser tests
ansible.builtin.include_tasks: "{{ os | lower }}_native.yaml"
vars:
parser: "({{ os }}/native)"
tags:
- native
- include_tasks: "{{ os|lower }}_json.yaml"
- name: Run JSON parser tests
ansible.builtin.include_tasks: "{{ os | lower }}_json.yaml"
vars:
parser: "({{ os }}/json)"
when: "os in ['nxos']"
tags:
- json
- include_tasks: "{{ os|lower }}_ntc_templates.yaml"
- name: Run ntc_templates parser tests
ansible.builtin.include_tasks: "{{ os | lower }}_ntc_templates.yaml"
vars:
parser: "({{ os }}/ntc_templates)"
when: "os in ['nxos']"
tags:
- ntc_templates
- include_tasks: "{{ os|lower }}_pyats.yaml"
- name: Run pyats parser tests
ansible.builtin.include_tasks: "{{ os | lower }}_pyats.yaml"
vars:
parser: "({{ os }}/pyats)"
when: "os in ['nxos']"
tags:
- pyats
- include_tasks: "{{ os|lower }}_textfsm.yaml"
- name: Run textfsm parser tests
ansible.builtin.include_tasks: "{{ os | lower }}_textfsm.yaml"
vars:
parser: "({{ os }}/textfsm)"
when: "os in ['nxos']"
tags:
- textfsm
- include_tasks: "{{ os|lower }}_ttp.yaml"
- name: Run ttp parser tests
ansible.builtin.include_tasks: "{{ os | lower }}_ttp.yaml"
vars:
parser: "({{ os }}/ttp)"
when: "os in ['nxos']"
tags:
- ttp
- include_tasks: "{{ os|lower }}_xml.yaml"
- name: Run XML parser tests
ansible.builtin.include_tasks: "{{ os | lower }}_xml.yaml"
vars:
parser: "({{ os }}/textfsm)"
parser: "({{ os }}/xml)"
when: "os in ['nxos']"
tags:
- xml

View File

@@ -1,29 +0,0 @@
---
- name: "{{ parser }} Run command and parse with json"
ansible.utils.cli_parse:
command: "show version | json"
parser:
name: ansible.utils.json
register: nxos_json_command
# TODO: This testcase test the redirection of cli_parse plugin
# from ansible.netcommon to ansible.utils
# remove this test case after ansible.netcommon.cli_parse deprecation is
# due as this scenario is already covered in ansible.utils collection testing
- name: "{{ parser }} Run command and parse with json"
ansible.netcommon.cli_parse:
# the leading space here is critical so it's not converted on the way in
text: " {{ nxos_json_command['stdout'] }}"
parser:
name: ansible.netcommon.json
register: nxos_json_text
- name: "{{ parser }} Confirm response"
assert:
that: "{{ item }}"
with_items:
- "{{ nxos_json_command['stdout'] is defined }}"
- "{{ nxos_json_command['stdout_lines'] is defined }}"
- "{{ nxos_json_command['parsed'] is defined }}"
- "{{ nxos_json_command['parsed']['header_str'] is defined }}"
- "{{ nxos_json_command['parsed'] == nxos_json_text['parsed'] }}"

View File

@@ -1,5 +1,5 @@
---
- name: "{{ parser }} Run command and parse with native"
- name: "Run command and parse with {{ parser }}"
ansible.utils.cli_parse:
command: "show interface"
parser:
@@ -7,7 +7,7 @@
set_fact: POpqMQoJWTiDpEW
register: nxos_native_command
- name: "{{ parser }} Pass text and template_path"
- name: "Pass text and template_path to {{ parser }}"
ansible.utils.cli_parse:
text: "{{ nxos_native_command['stdout'] }}"
parser:
@@ -15,8 +15,8 @@
template_path: "{{ role_path }}/templates/nxos_show_interface.yaml"
register: nxos_native_text
- name: "{{ parser }} Confirm response"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ item }}"
with_items:
- "{{ POpqMQoJWTiDpEW is defined }}"
@@ -25,7 +25,7 @@
- "{{ nxos_native_command['stdout_lines'] is defined }}"
- "{{ nxos_native_command['parsed'] == nxos_native_text['parsed'] }}"
- name: "{{ parser }} Pass text and command"
- name: "Pass text and command to {{ parser }}"
ansible.utils.cli_parse:
text: "{{ nxos_native_command['stdout'] }}"
parser:
@@ -33,13 +33,13 @@
command: show interface
register: output
- name: "{{ parser }} Confirm response"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ item }}"
with_items:
- "{{ output['parsed']['mgmt0'] is defined }}"
- name: "{{ parser }} Run command and parse with native"
- name: "Run command and parse with {{ parser }}"
ansible.utils.cli_parse:
command: "sho int"
parser:
@@ -47,8 +47,8 @@
command: show interface
register: output
- name: "{{ parser }} Confirm response"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ item }}"
with_items:
- "{{ output['parsed']['mgmt0'] is defined }}"

View File

@@ -1,12 +1,12 @@
---
- name: "{{ parser }} Run command and parse with ntc_templates"
- name: "Run command and parse with {{ parser }}"
ansible.utils.cli_parse:
command: "show interface"
parser:
name: ansible.netcommon.ntc_templates
register: nxos_ntc_templates_command
- name: "{{ parser }} Pass text and command"
- name: "Pass text and command to {{ parser }}"
ansible.utils.cli_parse:
text: "{{ nxos_ntc_templates_command['stdout'] }}"
parser:
@@ -14,8 +14,8 @@
command: show interface
register: nxos_ntc_templates_text
- name: "{{ parser }} Confirm response"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ item }}"
with_items:
- "{{ nxos_ntc_templates_command['stdout'] is defined }}"

View File

@@ -1,29 +1,29 @@
---
- name: Determine the python version of the control node
command: 'python --version'
ansible.builtin.command: "python --version"
delegate_to: localhost
register: pyver
changed_when: false
- name: Python 2 reports to stderr, Python 3 to stdout
set_fact:
ansible.builtin.set_fact:
pyver_found: "{{ ((pyver['stderr'] or pyver['stdout']).split())[1][0] }}"
- name: Ensure a valid python major version was found
assert:
that: "{{ pyver_found in ['2','3'] }}"
ansible.builtin.assert:
that: "{{ pyver_found in ['2', '3'] }}"
- name: Only run pyats tests when control node is Python3
when: pyver_found == '3'
block:
- name: "{{ parser }} Run command and parse with pyats"
- name: "Run command and parse with {{ parser }}"
ansible.utils.cli_parse:
command: "show interface"
parser:
name: ansible.netcommon.pyats
register: nxos_pyats_command
- name: "{{ parser }} Pass text and command"
- name: "Pass text and command to {{ parser }}"
ansible.utils.cli_parse:
text: "{{ nxos_pyats_command['stdout'] }}"
parser:
@@ -31,8 +31,8 @@
command: show interface
register: nxos_pyats_text
- name: "{{ parser }} Check results"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ item }}"
with_items:
- "{{ nxos_pyats_command['stdout'] is defined }}"
@@ -49,8 +49,8 @@
os: nxos
register: nxos_pyats_text
- name: "{{ parser }} Check results"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ item }}"
with_items:
- "{{ nxos_pyats_command['stdout'] is defined }}"
@@ -58,7 +58,7 @@
- "{{ nxos_pyats_command['parsed'] == nxos_pyats_text['parsed'] }}"
- "{{ nxos_pyats_command['parsed']['mgmt0'] is defined }}"
- name: "{{ parser }} Confirm parser found message"
- name: "Confirm parser found message"
ansible.utils.cli_parse:
text: "{{ nxos_pyats_command['stdout'] }}"
parser:
@@ -68,6 +68,6 @@
register: nxos_pyats_invalid_parser_name
ignore_errors: true
- name: "{{ parser }} Check results"
assert:
- name: "Check output"
ansible.builtin.assert:
that: "{{ 'Could not find parser' in nxos_pyats_invalid_parser_name['msg'] }}"

View File

@@ -1,28 +0,0 @@
---
- name: "{{ parser }} Run command and parse with textfsm"
ansible.utils.cli_parse:
command: "show version"
parser:
name: ansible.utils.textfsm
register: nxos_textfsm_command
# TODO: This testcase test the redirection of cli_parse plugin
# from ansible.netcommon to ansible.utils
# remove this test case after ansible.netcommon.cli_parse deprecation is
# due as this scenario is already covered in ansible.utils collection testing
- name: "{{ parser }} Pass text and command"
ansible.netcommon.cli_parse:
text: "{{ nxos_textfsm_command['stdout'] }}"
parser:
name: ansible.netcommon.textfsm
command: show version
register: nxos_textfsm_text
- name: "{{ parser }} Confirm response"
assert:
that: "{{ item }}"
with_items:
- "{{ nxos_textfsm_command['stdout'] is defined }}"
- "{{ nxos_textfsm_command['stdout_lines'] is defined }}"
- "{{ nxos_textfsm_command['parsed'] == nxos_textfsm_text['parsed'] }}"
- "{{ nxos_textfsm_command['parsed'][0]['BOOT_IMAGE'] is defined }}"

View File

@@ -1,97 +0,0 @@
---
- name: "{{ parser }} Run command and parse with ttp"
ansible.utils.cli_parse:
command: "show interface"
parser:
name: ansible.utils.ttp
set_fact: POpqMQoJWTiDpEW
register: nxos_ttp_command
# TODO: This testcase test the redirection of cli_parse plugin
# from ansible.netcommon to ansible.utils
# remove this test case after ansible.netcommon.cli_parse deprecation is
# due as this scenario is already covered in ansible.utils collection testing
- name: "{{ parser }} Pass text and template_path"
ansible.netcommon.cli_parse:
text: "{{ nxos_ttp_command['stdout'] }}"
parser:
name: ansible.netcommon.ttp
template_path: "{{ role_path }}/templates/nxos_show_interface.ttp"
register: nxos_ttp_text
- name: "{{ parser }} Confirm response"
assert:
that: "{{ item }}"
with_items:
- "{{ POpqMQoJWTiDpEW is defined }}"
- "{{ nxos_ttp_command['parsed'][0][0] | selectattr('interface', 'search', 'mgmt0') | list | length }}"
- "{{ nxos_ttp_command['stdout'] is defined }}"
- "{{ nxos_ttp_command['stdout_lines'] is defined }}"
- "{{ nxos_ttp_command['parsed'] == nxos_ttp_text['parsed'] }}"
# TODO: This testcase test the redirection of cli_parse plugin
# from ansible.netcommon to ansible.utils
# remove this test case after ansible.netcommon.cli_parse deprecation is
# due as this scenario is already covered in ansible.utils collection testing
- name: "{{ parser }} Pass text and ttp_init"
ansible.netcommon.cli_parse:
text: "{{ nxos_ttp_command['stdout'] }}"
parser:
name: ansible.netcommon.ttp
command: show interface
vars:
ttp_init:
log_level: DEBUG
log_file: /tmp/ttp_parser.log
- name: Remove ttp_parser log file
file:
path: /tmp/ttp_parser.log
state: absent
register: file_deleted
- name: Confirm ttp log file was created and deleted
assert:
that: "{{ file_deleted['changed'] }}"
# TODO: This testcase test the redirection of cli_parse plugin
# from ansible.netcommon to ansible.utils
# remove this test case after ansible.netcommon.cli_parse deprecation is
# due as this scenario is already covered in ansible.utils collection testing
- name: "{{ parser }} Pass text and custom variable"
ansible.netcommon.cli_parse:
text: "{{ nxos_ttp_command['stdout'] }}"
parser:
name: ansible.netcommon.ttp
template_path: "{{ role_path }}/templates/nxos_show_interface.ttp"
vars:
ttp_vars:
extra_var: some_text
register: nxos_ttp_vars
- name: "{{ parser }} Confirm modified results"
assert:
that: "{{ item }}"
with_items:
- "{{ nxos_ttp_vars['parsed'][0][0][0]['var'] == 'some_text' }}"
# TODO: This testcase test the redirection of cli_parse plugin
# from ansible.netcommon to ansible.utils
# remove this test case after ansible.netcommon.cli_parse deprecation is
# due as this scenario is already covered in ansible.utils collection testing
- name: "{{ parser }} Pass text and ttp_results modified"
ansible.netcommon.cli_parse:
text: "{{ nxos_ttp_command['stdout'] }}"
parser:
name: ansible.netcommon.ttp
template_path: "{{ role_path }}/templates/nxos_show_interface.ttp"
vars:
ttp_results:
format: yaml
register: nxos_ttp_results
- name: "{{ parser }} Confirm modified results"
assert:
that: "{{ item }}"
with_items:
- "{{ (nxos_ttp_results['parsed'][0]|from_yaml)[0] | selectattr('interface', 'search', 'mgmt0') | list | length }}"

View File

@@ -1,27 +0,0 @@
---
- name: "{{ parser }} Run command and parse with xml"
ansible.utils.cli_parse:
command: "show interface | xml"
parser:
name: ansible.utils.xml
register: nxos_xml_command
# TODO: This testcase test the redirection of cli_parse plugin
# from ansible.netcommon to ansible.utils
# remove this test case after ansible.netcommon.cli_parse deprecation is
# due as this scenario is already covered in ansible.utils collection testing
- name: "{{ parser }} Pass text and parse with xml"
ansible.netcommon.cli_parse:
text: "{{ nxos_xml_command['stdout'] }}"
parser:
name: ansible.netcommon.xml
register: nxos_xml_text
- name: "{{ parser }} Confirm response"
assert:
that: "{{ item }}"
with_items:
- "{{ nxos_xml_command['stdout'] is defined }}"
- "{{ nxos_xml_command['stdout_lines'] is defined }}"
- "{{ nxos_xml_command['parsed'] == nxos_xml_text['parsed'] }}"
- "{{ nxos_xml_command['parsed']['nf:rpc-reply'] is defined }}"

View File

@@ -1,9 +1,9 @@
---
- example: 'UID PID PPID C STIME TTY TIME CMD'
getval: '^UID.*'
- example: "UID PID PPID C STIME TTY TIME CMD"
getval: "^UID.*"
result: {}
- example: 'root 2 0 0 Jul28 ? 00:00:00 [kthreadd]'
- example: "root 2 0 0 Jul28 ? 00:00:00 [kthreadd]"
getval: '(?P<uid>\S+)\s+(?P<pid>\S+)\s+(?P<ppid>\S+)\s+(?P<c>\S+)\s+(?P<stime>\S+)\s+(?P<tty>\S+)\s+(?P<time>\S+)\s+(?P<cmd>\S+)'
result:
proccesses:

View File

@@ -9,7 +9,7 @@
shared: true
- example: "target prot opt source destination"
getval: '^target.*'
getval: "^target.*"
result: {}
- example: "ACCEPT all -- anywhere 192.168.122.0/24 ctstate RELATED,ESTABLISHED"

View File

@@ -1,9 +1,9 @@
---
- example: 'UID PID PPID C STIME TTY TIME CMD'
getval: '^UID.*'
- example: "UID PID PPID C STIME TTY TIME CMD"
getval: "^UID.*"
result: {}
- example: 'root 2 0 0 Jul28 ? 00:00:00 [kthreadd]'
- example: "root 2 0 0 Jul28 ? 00:00:00 [kthreadd]"
getval: '(?P<uid>\S+)\s+(?P<pid>\S+)\s+(?P<ppid>\S+)\s+(?P<c>\S+)\s+(?P<stime>\S+)\s+(?P<tty>\S+)\s+(?P<time>\S+)\s+(?P<cmd>\S+)'
result:
proccesses:

View File

@@ -0,0 +1,2 @@
---
testcase: "*"

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: prepare_iosxr_tests
when: ansible_network_os == 'cisco.iosxr.iosxr'

View File

@@ -0,0 +1,17 @@
---
- name: Collect all grpc test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/iosxr"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: Run test case (connection=ansible.netcommon.grpc)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View File

@@ -0,0 +1,17 @@
---
- name: Collect all grpc test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/junos"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: Run test case (connection=ansible.netcommon.grpc)
ansible.builtin.include_tasks: "{{ test_case_to_run }} ansible_connection=ansible.netcommon.grpc"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View File

@@ -0,0 +1,18 @@
---
- name: Run junos gRPC tests
ansible.builtin.include_tasks: junos.yaml
when: ansible_network_os == 'junipernetworks.junos.junos'
tags:
- grpc
- name: Run iosxr gRPC tests
ansible.builtin.include_tasks: iosxr.yaml
when: ansible_network_os == 'cisco.iosxr.iosxr'
tags:
- grpc
- name: Run nxos gRPC tests
ansible.builtin.include_tasks: nxos.yaml
when: ansible_network_os == 'cisco.nxos.nxos'
tags:
- grpc

View File

@@ -0,0 +1,17 @@
---
- name: Collect all grpc test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/nxos"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: Run test case (connection=ansible.netcommon.grpc)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View File

@@ -0,0 +1,144 @@
---
- debug: msg="START grpc_config iosxr/basic.yaml on connection=ansible.netcommon.grpc"
- name: setup
connection: ansible.netcommon.network_cli
cisco.iosxr.iosxr_config:
commands:
- no router bgp
- no router static address-family ipv4 unicast 1.2.3.6/32 10.0.2.2
- name: Sleep for 30 seconds and continue with play
wait_for:
timeout: 30
connection: local
- name: save config test
register: result
connection: ansible.netcommon.grpc
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_config:
backup: true
- assert:
that:
- "'backup_path' in result"
- name: Merge static route config
register: result
connection: ansible.netcommon.grpc
diff: true
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_config:
config:
Cisco-IOS-XR-ip-static-cfg:router-static:
default-vrf:
address-family:
vrfipv4:
vrf-unicast:
vrf-prefixes:
vrf-prefix:
- prefix: "1.2.3.6"
prefix-length: 32
vrf-route:
vrf-next-hop-table:
vrf-next-hop-next-hop-address:
- next-hop-address: "10.0.2.2"
state: merged
- assert:
that:
- result.changed == true
- name: Assert that diff dicts are correctly generated
assert:
that:
- result.diff['before'] == before
- result.diff['after'] == after
- name: get running interface confiugration
register: result
connection: ansible.netcommon.grpc
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_get:
command: "show running-config"
display: "text"
- assert:
that:
- "'router static' in result.stdout"
- "'1.2.3.6/32 10.0.2.2' in result.stdout"
- name: Replace bgp config
register: result
connection: ansible.netcommon.grpc
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_config:
config: "{{ lookup('file', './fixtures/bgp_start.yml') }}"
state: replaced
- assert:
that:
- result.changed == true
- name: get running interface confiugration
register: result
connection: ansible.netcommon.grpc
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_get:
command: "show running-config router bgp"
display: "text"
- assert:
that:
- "'router bgp 65400' in result.stdout"
- name: Delete bgp config
register: result
connection: ansible.netcommon.grpc
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_config:
config: "{{ lookup('file', './fixtures/bgp_delete.yml') }}"
state: deleted
- assert:
that:
- result.changed == true
- name: get running interface confiugration
register: result
connection: ansible.netcommon.grpc
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_get:
command: "show running-config router bgp"
display: "text"
- assert:
that:
- "'router bgp 65400' not in result.stdout"
- name: setup - teardown
connection: ansible.netcommon.network_cli
cisco.iosxr.iosxr_config:
commands:
- no address-family ipv4 unicast 1.2.3.6/32 10.0.2.2
parents:
- router static
match: none
- debug: msg="END grpc_config iosxr/basic.yaml on connection=ansible.netcommon.grpc"

View File

@@ -0,0 +1,8 @@
---
Cisco-IOS-XR-ipv4-bgp-cfg:bgp:
instance:
- instance-name: default
instance-as:
- as: 0
four-byte-as:
- as: 65400

View File

@@ -0,0 +1,35 @@
---
Cisco-IOS-XR-ipv4-bgp-cfg:bgp:
instance:
- instance-name: default
instance-as:
- as: 0
four-byte-as:
- as: 65400
bgp-running:
-
default-vrf:
global:
router-id: 12.1.1.10
global-afs:
global-af:
- af-name: ipv4-unicast
enable:
-
sourced-networks:
sourced-network:
- network-addr: 11.1.1.0
network-prefix: 24
bgp-entity:
neighbors:
neighbor:
- neighbor-address: 11.1.1.20
remote-as:
as-xx: 0
as-yy: 65450
neighbor-afs:
neighbor-af:
- af-name: ipv4-unicast
activate:
-
next-hop-self: true

View File

@@ -0,0 +1,37 @@
---
before:
Cisco-IOS-XR-ip-static-cfg:router-static:
default-vrf:
address-family:
vrfipv4:
vrf-unicast:
vrf-prefixes:
vrf-prefix:
- prefix: "0.0.0.0"
prefix-length: 0
vrf-route:
vrf-next-hop-table:
vrf-next-hop-interface-name-next-hop-address:
- interface-name: "MgmtEth0/RP0/CPU0/0"
next-hop-address: "10.0.151.254"
after:
Cisco-IOS-XR-ip-static-cfg:router-static:
default-vrf:
address-family:
vrfipv4:
vrf-unicast:
vrf-prefixes:
vrf-prefix:
- prefix: "0.0.0.0"
prefix-length: 0
vrf-route:
vrf-next-hop-table:
vrf-next-hop-interface-name-next-hop-address:
- interface-name: "MgmtEth0/RP0/CPU0/0"
next-hop-address: "10.0.151.254"
- prefix: "1.2.3.6"
prefix-length: 32
vrf-route:
vrf-next-hop-table:
vrf-next-hop-next-hop-address:
- next-hop-address: "10.0.2.2"

View File

@@ -0,0 +1,2 @@
---
testcase: "*"

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: prepare_iosxr_tests
when: ansible_network_os == 'cisco.iosxr.iosxr'

View File

@@ -0,0 +1,17 @@
---
- name: Collect all grpc test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/iosxr"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: Run test case (connection=ansible.netcommon.grpc)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View File

@@ -0,0 +1,6 @@
---
- name: Run iosxr gRPC tests
ansible.builtin.include_tasks: iosxr.yaml
when: ansible_network_os == 'cisco.iosxr.iosxr'
tags:
- grpc

View File

@@ -0,0 +1,57 @@
---
- debug: msg="START grpc_get iosxr/basic.yaml on connection=ansible.netcommon.grpc"
- name: setup interface
connection: ansible.netcommon.network_cli
cisco.iosxr.iosxr_config:
commands:
- description this is test interface Loopback999
- no shutdown
parents:
- interface Loopback999
match: none
- name: get running interface confiugration
register: result
connection: ansible.netcommon.grpc
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_get:
command: "show running-config"
display: "text"
- assert:
that:
- "'description this is test interface Loopback999' in result.stdout"
- name: get interface details using section
register: result
connection: ansible.netcommon.grpc
vars:
ansible_grpc_connection_type: cisco.iosxr.grpc
ansible_port: 57777
ansible.netcommon.grpc_get:
section:
Cisco-IOS-XR-ifmgr-cfg:interface-configurations:
- null
- name: Assert interface config
assert:
that:
- "item['description'] == 'this is test interface Loopback999'"
loop: "{{ result.output[0]['Cisco-IOS-XR-ifmgr-cfg:interface-configurations']['interface-configuration'] }}"
when: item['interface-name'] == "Loopback999"
- name: setup - teardown
connection: ansible.netcommon.network_cli
cisco.iosxr.iosxr_config:
commands:
- no description
- shutdown
parents:
- interface Loopback999
match: none
- debug: msg="END grpc_get iosxr/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -1,2 +1,2 @@
---
testcase: '*'
testcase: "*"

View File

@@ -1,16 +1,19 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/iosxr'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/iosxr"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }}'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
vars:
ansible_connection: ansible.netcommon.netconf
loop_control:
loop_var: test_case_to_run

View File

@@ -1,16 +1,19 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/junos'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/junos"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.netconf'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
vars:
ansible_connection: ansible.netcommon.netconf
loop_control:
loop_var: test_case_to_run

View File

@@ -1,15 +1,18 @@
---
- include: junos.yaml
- name: Run junos netconf_config tests
ansible.builtin.include_tasks: junos.yaml
when: ansible_network_os == 'junipernetworks.junos.junos'
tags:
- netconf
- include: iosxr.yaml
- name: Run iosxr netconf_config tests
ansible.builtin.include_tasks: iosxr.yaml
when: ansible_network_os == 'cisco.iosxr.iosxr'
tags:
- netconf
- include: nxos.yaml
- name: Run nxos netconf_config tests
ansible.builtin.include_tasks: nxos.yaml
when: ansible_network_os == 'cisco.nxos.nxos'
tags:
- netconf

View File

@@ -1,16 +1,19 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/nxos'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/nxos"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }}'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
vars:
ansible_connection: ansible.netcommon.netconf
loop_control:
loop_var: test_case_to_run

View File

@@ -51,27 +51,27 @@
connection: ansible.netcommon.netconf
ansible.netcommon.netconf_config:
content: |
{
"config": {
"@xmlns": "urn:ietf:params:xml:ns:netconf:base:1.0",
"@xmlns:nc": "urn:ietf:params:xml:ns:netconf:base:1.0",
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": {
"active": "act",
"description": "test for ansible Loopback999",
"interface-name": "Loopback999",
}
}
}
}
get_filter: |
{
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null
{
"config": {
"@xmlns": "urn:ietf:params:xml:ns:netconf:base:1.0",
"@xmlns:nc": "urn:ietf:params:xml:ns:netconf:base:1.0",
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": {
"active": "act",
"description": "test for ansible Loopback999",
"interface-name": "Loopback999",
}
}
}
}
get_filter: |
{
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null
}
}
register: result
ignore_errors: true
diff: true
@@ -86,27 +86,27 @@
ansible.netcommon.netconf_config:
format: json
content: |
{
"config": {
"@xmlns": "urn:ietf:params:xml:ns:netconf:base:1.0",
"@xmlns:nc": "urn:ietf:params:xml:ns:netconf:base:1.0",
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": {
"active": "act",
"description": "test for ansible Loopback999",
"interface-name": "Loopback999"
}
}
}
}
get_filter: |
{
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null
{
"config": {
"@xmlns": "urn:ietf:params:xml:ns:netconf:base:1.0",
"@xmlns:nc": "urn:ietf:params:xml:ns:netconf:base:1.0",
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": {
"active": "act",
"description": "test for ansible Loopback999",
"interface-name": "Loopback999"
}
}
}
}
get_filter: |
{
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null
}
}
register: result
diff: true
@@ -129,26 +129,32 @@
connection: ansible.netcommon.netconf
ansible.netcommon.netconf_config:
format: json
content: {
"config": {
"@xmlns": "urn:ietf:params:xml:ns:netconf:base:1.0",
"@xmlns:nc": "urn:ietf:params:xml:ns:netconf:base:1.0",
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": {
"active": "act",
"description": "test for ansible Loopback999",
"interface-name": "Loopback999"
}
}
content:
{
"config":
{
"@xmlns": "urn:ietf:params:xml:ns:netconf:base:1.0",
"@xmlns:nc": "urn:ietf:params:xml:ns:netconf:base:1.0",
"interface-configurations":
{
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration":
{
"active": "act",
"description": "test for ansible Loopback999",
"interface-name": "Loopback999",
},
},
},
}
}
get_filter: {
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null
get_filter:
{
"interface-configurations":
{
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null,
},
}
}
register: result
diff: true
@@ -167,5 +173,6 @@
- interface Loopback999
match: none
- debug: msg="END netconf_config iosxr/basic.yaml on connection={{ ansible_connection
- debug:
msg="END netconf_config iosxr/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -1,10 +1,11 @@
---
- debug: msg="START netconf_config junos/basic.yaml on connection={{ ansible_connection
- debug:
msg="START netconf_config junos/basic.yaml on connection={{ ansible_connection
}}"
- include_vars: '{{playbook_dir }}/targets/netconf_config/tests/junos/fixtures/config.yml'
- include_vars: "{{playbook_dir }}/targets/netconf_config/tests/junos/fixtures/config.yml"
- include_vars: '{{playbook_dir }}/targets/netconf_config/tests/junos/fixtures/invalid_config.yml'
- include_vars: "{{playbook_dir }}/targets/netconf_config/tests/junos/fixtures/invalid_config.yml"
- name: syslog file config- setup
junipernetworks.junos.junos_config:
@@ -14,7 +15,7 @@
- name: configure syslog file
register: result
ansible.netcommon.netconf_config:
content: '{{ syslog_config }}'
content: "{{ syslog_config }}"
- assert:
that:
@@ -24,7 +25,7 @@
- name: configure syslog file (idempotent)
register: result
ansible.netcommon.netconf_config:
content: '{{ syslog_config }}'
content: "{{ syslog_config }}"
- assert:
that:
@@ -34,7 +35,7 @@
register: result
ignore_errors: true
ansible.netcommon.netconf_config:
content: '{{ syslog_config_replace }}'
content: "{{ syslog_config_replace }}"
default_operation: replace
- assert:
@@ -45,7 +46,7 @@
- name: replace syslog config with operation key in content
register: result
ansible.netcommon.netconf_config:
content: '{{ syslog_config_replace }}'
content: "{{ syslog_config_replace }}"
- assert:
that:
@@ -55,7 +56,7 @@
register: result
ignore_errors: true
ansible.netcommon.netconf_config:
content: '{{ invalid_syslog_config }}'
content: "{{ invalid_syslog_config }}"
- assert:
that:
@@ -65,7 +66,7 @@
- name: test backup
register: result
ansible.netcommon.netconf_config:
content: '{{ syslog_config }}'
content: "{{ syslog_config }}"
backup: true
- assert:
@@ -86,5 +87,6 @@
that:
- "'backup_path' in result"
- debug: msg="END netconf_config junos/basic.yaml on connection={{ ansible_connection
- debug:
msg="END netconf_config junos/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -1,14 +1,14 @@
---
vlan_config: |
<config>
<System xmlns="http://cisco.com/ns/yang/cisco-nx-os-device">
<bd-items>
<bd-items>
<BD-list>
<fabEncap>vlan-42</fabEncap>
<name>vlan-42</name>
</BD-list>
</bd-items>
</bd-items>
</System>
</config>
<config>
<System xmlns="http://cisco.com/ns/yang/cisco-nx-os-device">
<bd-items>
<bd-items>
<BD-list>
<fabEncap>vlan-42</fabEncap>
<name>vlan-42</name>
</BD-list>
</bd-items>
</bd-items>
</System>
</config>

View File

@@ -1,2 +1,2 @@
---
testcase: '*'
testcase: "*"

View File

@@ -1,16 +1,19 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/iosxr'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/iosxr"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }}'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
vars:
ansible_connection: ansible.netcommon.netconf
loop_control:
loop_var: test_case_to_run

View File

@@ -1,16 +1,19 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/junos'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/junos"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.netconf'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
vars:
ansible_connection: ansible.netcommon.netconf
loop_control:
loop_var: test_case_to_run

View File

@@ -1,15 +1,18 @@
---
- include: junos.yaml
- name: Run junos netconf_get tests
ansible.builtin.include_tasks: junos.yaml
when: ansible_network_os == 'junipernetworks.junos.junos'
tags:
- netconf
- include: iosxr.yaml
- name: Run iosxr netconf_get tests
ansible.builtin.include_tasks: iosxr.yaml
when: ansible_network_os == 'cisco.iosxr.iosxr'
tags:
- netconf
- include: sros.yaml
- name: Run nxos netconf_get tests
ansible.builtin.include_tasks: sros.yaml
when: ansible_network_os == 'sros'
tags:
- netconf

View File

@@ -1,16 +1,17 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/sros'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/sros"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.netconf'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View File

@@ -1,5 +1,6 @@
---
- debug: msg="START netconf_get iosxr/basic.yaml on connection={{ ansible_connection
- debug:
msg="START netconf_get iosxr/basic.yaml on connection={{ ansible_connection
}}"
- name: setup interface
@@ -135,12 +136,12 @@
connection: ansible.netcommon.netconf
ansible.netcommon.netconf_get:
filter: |
{
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null
}
}
{
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null
}
}
display: native
register: result
@@ -175,12 +176,14 @@
- name: "get configuration with direct native filter type"
connection: ansible.netcommon.netconf
ansible.netcommon.netconf_get:
filter: {
"interface-configurations": {
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null
filter:
{
"interface-configurations":
{
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg",
"interface-configuration": null,
},
}
}
display: native
register: result
@@ -201,5 +204,6 @@
- interface Loopback999
match: none
- debug: msg="END netconf_get iosxr/basic.yaml on connection={{ ansible_connection
- debug:
msg="END netconf_get iosxr/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -1,5 +1,6 @@
---
- debug: msg="START netconf_get junos/basic.yaml on connection={{ ansible_connection
- debug:
msg="START netconf_get junos/basic.yaml on connection={{ ansible_connection
}}"
- name: Configure syslog file - setup
@@ -125,5 +126,6 @@
lines:
- delete system syslog file test1 any any
- debug: msg="END netconf_get junos/basic.yaml on connection={{ ansible_connection
- debug:
msg="END netconf_get junos/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -1,5 +1,6 @@
---
- debug: msg="START netconf_get sros/basic.yaml on connection={{ ansible_connection
- debug:
msg="START netconf_get sros/basic.yaml on connection={{ ansible_connection
}}"
- name: Get complete configuration data (SROS)
@@ -54,5 +55,6 @@
- "'urn:nokia.com:sros:ns:yang:sr:conf' in result.stdout"
- "'urn:nokia.com:sros:ns:yang:sr:state' in result.stdout"
- debug: msg="END netconf_get sros/basic.yaml on connection={{ ansible_connection
- debug:
msg="END netconf_get sros/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -1,2 +1,2 @@
---
testcase: '*'
testcase: "*"

View File

@@ -1,16 +1,19 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/iosxr'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/iosxr"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.netconf'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
vars:
ansible_connection: ansible.netcommon.netconf
loop_control:
loop_var: test_case_to_run

View File

@@ -1,16 +1,19 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/junos'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/junos"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.netconf'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
vars:
ansible_connection: ansible.netcommon.netconf
loop_control:
loop_var: test_case_to_run

View File

@@ -1,15 +1,18 @@
---
- include: junos.yaml
- name: Run junos netconf_rpc tests
ansible.builtin.include_tasks: junos.yaml
when: ansible_network_os == 'junipernetworks.junos.junos'
tags:
- netconf
- include: iosxr.yaml
- name: Run iosxr netconf_rpc tests
ansible.builtin.include_tasks: iosxr.yaml
when: ansible_network_os == 'cisco.iosxr.iosxr'
tags:
- netconf
- include: sros.yaml
- name: Run nxos netconf_rpc tests
ansible.builtin.include_tasks: sros.yaml
when: ansible_network_os == 'sros'
tags:
- netconf

View File

@@ -1,16 +1,17 @@
---
- name: collect all netconf test cases
find:
paths: '{{ role_path }}/tests/sros'
patterns: '{{ testcase }}.yaml'
- name: Collect all netconf test cases
ansible.builtin.find:
paths: "{{ role_path }}/tests/sros"
patterns: "{{ testcase }}.yaml"
register: test_cases
connection: local
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: Set test_items
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case (connection=ansible.netcommon.netconf)
include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.netconf'
with_items: '{{ test_items }}'
- name: Run test case (connection=ansible.netcommon.netconf)
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View File

@@ -1,5 +1,6 @@
---
- debug: msg="START netconf_rpc iosxr/basic.yaml on connection={{ ansible_connection
- debug:
msg="START netconf_rpc iosxr/basic.yaml on connection={{ ansible_connection
}}"
- name: get schema list with xml output
@@ -22,5 +23,6 @@
ansible.netcommon.netconf_rpc:
rpc: discard-changes
- debug: msg="END netconf_rpc iosxr/basic.yaml on connection={{ ansible_connection
- debug:
msg="END netconf_rpc iosxr/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -1,5 +1,6 @@
---
- debug: msg="START netconf_rpc junos/basic.yaml on connection={{ ansible_connection
- debug:
msg="START netconf_rpc junos/basic.yaml on connection={{ ansible_connection
}}"
- name: get schema list with xml output
@@ -20,5 +21,6 @@
ansible.netcommon.netconf_rpc:
rpc: discard-changes
- debug: msg="END netconf_rpc junos/basic.yaml on connection={{ ansible_connection
- debug:
msg="END netconf_rpc junos/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -1,5 +1,6 @@
---
- debug: msg="START netconf_rpc sros/basic.yaml on connection={{ ansible_connection
- debug:
msg="START netconf_rpc sros/basic.yaml on connection={{ ansible_connection
}}"
- name: lock candidate (content is dict)
@@ -61,7 +62,8 @@
connection: ansible.netcommon.netconf
ansible.netcommon.netconf_rpc:
rpc: get
content: "<filter>\n <netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"\
content:
"<filter>\n <netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"\
>\n <schemas/>\n </netconf-state>\n</filter>\n"
display: json
@@ -137,7 +139,7 @@
connection: ansible.netcommon.netconf
ignore_errors: true
ansible.netcommon.netconf_rpc:
rpc: ''
rpc: ""
display: json
- assert:
@@ -149,12 +151,13 @@
connection: ansible.netcommon.netconf
ignore_errors: true
ansible.netcommon.netconf_rpc:
rpc: ' '
rpc: " "
display: json
- assert:
that:
- "'must not be empty' in result.msg"
- debug: msg="END netconf_rpc sros/basic.yaml on connection={{ ansible_connection
- debug:
msg="END netconf_rpc sros/basic.yaml on connection={{ ansible_connection
}}"

View File

@@ -12,5 +12,12 @@
netconf_vrf: default
state: present
- set_fact:
shorter_hostname: '{{ inventory_hostname_short| truncate(10, True, "") }}'
- name: Enable gRPC
connection: ansible.netcommon.network_cli
tags: grpc
cisco.iosxr.iosxr_config:
src: config_grpc.j2
- name: Save truncated hostname
ansible.builtin.set_fact:
shorter_hostname: '{{ inventory_hostname_short | truncate(10, True, "") }}'

View File

@@ -0,0 +1,3 @@
grpc
port 57777
no-tls

View File

@@ -1,5 +1,7 @@
---
- debug: msg="START prepare_junos_tests/main.yaml"
- name: Start tasks
ansible.builtin.debug:
msg: "START prepare_junos_tests/main.yaml"
- name: Ensure netconf is enabled
connection: ansible.netcommon.network_cli
@@ -7,9 +9,9 @@
junipernetworks.junos.junos_netconf:
state: present
- name: wait for netconf server to come up
- name: Wait for netconf server to come up
delegate_to: localhost
wait_for:
host: '{{ hostvars[item].ansible_host }}'
ansible.builtin.wait_for:
host: "{{ hostvars[item].ansible_host }}"
port: 830
with_inventory_hostnames: junos

View File

@@ -1,5 +1,4 @@
---
- name: Setup - Enable feature netconf
cisco.nxos.nxos_feature:
feature: netconf
@@ -10,5 +9,7 @@
register: result
ignore_errors: true
- debug: msg='Netconf feature is not supported on this platform!'
- name: Show failure
ansible.builtin.debug:
msg: "Netconf feature is not supported on this platform!"
when: result.failed

View File

@@ -1,6 +1,8 @@
---
- debug: msg="START prepare_sros_tests/main.yaml"
- name: Start tasks
ansible.builtin.debug:
msg: "START prepare_sros_tests/main.yaml"
- name: wait until everything is ready to go
pause:
- name: Wait until everything is ready to go
ansible.builtin.pause:
seconds: 1

View File

@@ -1,2 +1,2 @@
---
testcase: '*'
testcase: "*"

View File

@@ -1,5 +1,6 @@
---
- include: restconf.yaml
- name: Run restconf_config tests
ansible.builtin.include_tasks: restconf.yaml
when: ansible_network_os == 'ansible.netcommon.restconf'
tags:
- restconf

View File

@@ -1,24 +1,25 @@
---
- name: Collect all cli test cases
find:
paths: '{{ role_path }}/tests/iosxe'
patterns: '{{ testcase }}.yaml'
ansible.builtin.find:
paths: "{{ role_path }}/tests/iosxe"
patterns: "{{ testcase }}.yaml"
use_regex: true
register: test_cases
delegate_to: localhost
- name: Set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
delegate_to: localhost
- name: Run test case (connection=ansible.netcommon.httpapi)
include: '{{ test_case_to_run }}'
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.httpapi
ansible_network_os: ansible.netcommon.restconf
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_httpapi_port: 443
with_items: '{{ test_items }}'
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View File

@@ -1,2 +1,2 @@
---
testcase: '*'
testcase: "*"

View File

@@ -1,5 +1,6 @@
---
- include: restconf.yaml
- name: Run restconf_get tests
ansible.builtin.include_tasks: restconf.yaml
when: ansible_network_os == 'ansible.netcommon.restconf'
tags:
- restconf

View File

@@ -1,24 +1,25 @@
---
- name: Collect all cli test cases
find:
paths: '{{ role_path }}/tests/iosxe'
patterns: '{{ testcase }}.yaml'
ansible.builtin.find:
paths: "{{ role_path }}/tests/iosxe"
patterns: "{{ testcase }}.yaml"
use_regex: true
register: test_cases
delegate_to: localhost
- name: Set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
ansible.builtin.set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
delegate_to: localhost
- name: Run test case (connection=ansible.netcommon.httpapi)
include: '{{ test_case_to_run }}'
ansible.builtin.include_tasks: "{{ test_case_to_run }}"
vars:
ansible_connection: ansible.netcommon.httpapi
ansible_network_os: ansible.netcommon.restconf
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_httpapi_port: 443
with_items: '{{ test_items }}'
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run