1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

nxos: merge nxapi/cli tests - config, bgp_neighbor, command, bgp_af (#28235)

* refactor nxos_bgp_af

* refactor nxos_bgp_neighbor

* refactor nxos_command

* refactor nxos_config

* removed accidental file
This commit is contained in:
David Newswanger 2017-08-21 11:15:25 -04:00 committed by Trishna Guha
parent d4e7b045b7
commit 5df02dc288
27 changed files with 169 additions and 678 deletions

View file

@ -1,15 +1,25 @@
--- ---
- name: collect all cli test cases - name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect cli test cases
find: find:
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,9 +1,19 @@
--- ---
- name: collect all nxapi test cases - name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find: find:
paths: "{{ role_path }}/tests/nxapi" paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}" provider: "{{ cli }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,28 +1,28 @@
--- ---
- debug: msg="START TRANSPORT:CLI nxos_bgp_af sanity test" - debug: msg="START TRANSPORT:{{ connection.transport }} nxos_bgp_af sanity test"
- set_fact: advertise_l2vpn_evpn="true" - set_fact: advertise_l2vpn_evpn="true"
when: platform | search('N9K') when: platform | search('N9K')
- name: "Enable feature BGP" - name: "Enable feature BGP"
nxos_feature: nxos_feature:
feature: bgp feature: bgp
state: enabled state: enabled
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- name: "Enable feature nv overlay" - name: "Enable feature nv overlay"
nxos_feature: nxos_feature:
feature: nv overlay feature: nv overlay
state: enabled state: enabled
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- name: "Setup" - name: "Setup"
nxos_bgp: &remove nxos_bgp: &remove
asn: 65535 asn: 65535
state: absent state: absent
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- block: - block:
@ -30,7 +30,7 @@
nxos_config: nxos_config:
lines: lines:
- nv overlay evpn - nv overlay evpn
provider: "{{ cli }}" provider: "{{ connection }}"
when: platform | search('N9K') when: platform | search('N9K')
- name: "Configure BGP_AF defaults" - name: "Configure BGP_AF defaults"
@ -41,7 +41,7 @@
safi: unicast safi: unicast
advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}" advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}"
state: present state: present
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: &true - assert: &true
@ -67,7 +67,7 @@
register: result register: result
- assert: *false - assert: *false
- name: "Configure BGP_AF non defaults" - name: "Configure BGP_AF non defaults"
nxos_bgp_af: &configure_non_default nxos_bgp_af: &configure_non_default
asn: 65535 asn: 65535
@ -97,9 +97,9 @@
table_map: RouteMap table_map: RouteMap
table_map_filter: true table_map_filter: true
state: present state: present
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
- name: "Check Idempotence" - name: "Check Idempotence"
@ -113,13 +113,13 @@
register: result register: result
- assert: *true - assert: *true
- name: "Check Idempotence" - name: "Check Idempotence"
nxos_bgp: *remove nxos_bgp: *remove
register: result register: result
- assert: *false - assert: *false
rescue: rescue:
- name: "Cleanup BGP" - name: "Cleanup BGP"
nxos_bgp: *remove nxos_bgp: *remove
@ -130,20 +130,20 @@
nxos_feature: &disable_bgp nxos_feature: &disable_bgp
feature: bgp feature: bgp
state: disabled state: disabled
provider: "{{ cli }}" provider: "{{ connection }}"
- name: "Disable feature nv overlay" - name: "Disable feature nv overlay"
nxos_feature: &disable_nvoverlay nxos_feature: &disable_nvoverlay
feature: nv overlay feature: nv overlay
state: disabled state: disabled
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- name: "Remove nv overlay evpn" - name: "Remove nv overlay evpn"
nxos_config: nxos_config:
lines: lines:
- no nv overlay evpn - no nv overlay evpn
provider: "{{ cli }}" provider: "{{ connection }}"
when: platform | search('N9K') when: platform | search('N9K')
- debug: msg="END TRANSPORT:CLI nxos_bgp_af sanity test" - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_bgp_af sanity test"

View file

@ -1,149 +0,0 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_bgp_af sanity test"
- set_fact: advertise_l2vpn_evpn="true"
when: platform | search('N9K')
- name: "Enable feature BGP"
nxos_feature:
feature: bgp
state: enabled
provider: "{{ nxapi }}"
ignore_errors: yes
- name: "Enable feature nv overlay"
nxos_feature:
feature: nv overlay
state: enabled
provider: "{{ nxapi }}"
ignore_errors: yes
- name: "Setup"
nxos_bgp: &remove
asn: 65535
state: absent
provider: "{{ nxapi }}"
ignore_errors: yes
- block:
- name: "Enable nv overlay evpn"
nxos_config:
lines:
- nv overlay evpn
provider: "{{ nxapi }}"
when: platform | search('N9K')
- name: "Configure BGP_AF defaults"
nxos_bgp_af: &configure_default
asn: 65535
vrf: TESTING
afi: ipv4
safi: unicast
advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}"
state: present
provider: "{{ nxapi }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_bgp_af: *configure_default
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp: *remove
register: result
- assert: *false
- name: "Configure BGP_AF non defaults"
nxos_bgp_af: &configure_non_default
asn: 65535
vrf: TESTING
afi: ipv4
safi: unicast
additional_paths_install: true
additional_paths_receive: true
additional_paths_selection: RouteMap
additional_paths_send: true
advertise_l2vpn_evpn: "{{advertise_l2vpn_evpn|default(omit)}}"
client_to_client: false
dampen_igp_metric: 200
dampening_half_time: 1
dampening_max_suppress_time: 4
dampening_reuse_time: 2
dampening_suppress_time: 3
default_information_originate: true
default_metric: 50
distance_ebgp: 30
distance_ibgp: 60
distance_local: 90
maximum_paths: 9
maximum_paths_ibgp: 9
next_hop_route_map: RouteMap
suppress_inactive: true
table_map: RouteMap
table_map_filter: true
state: present
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp_af: *configure_non_default
register: result
- assert: *false
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp: *remove
register: result
- assert: *false
rescue:
- name: "Cleanup BGP"
nxos_bgp: *remove
ignore_errors: yes
always:
- name: "Disable feature bgp"
nxos_feature: &disable_bgp
feature: bgp
state: disabled
provider: "{{ nxapi }}"
- name: "Disable feature nv overlay"
nxos_feature: &disable_nvoverlay
feature: nv overlay
state: disabled
provider: "{{ nxapi }}"
ignore_errors: yes
- name: "Remove nv overlay evpn"
nxos_config:
lines:
- no nv overlay evpn
provider: "{{ cli }}"
when: platform | search('N9K')
- debug: msg="END TRANSPORT:NXAPI nxos_bgp_af sanity test"

View file

@ -1,15 +1,25 @@
--- ---
- name: collect all cli test cases - name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect cli test cases
find: find:
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,9 +1,19 @@
--- ---
- name: collect all nxapi test cases - name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find: find:
paths: "{{ role_path }}/tests/nxapi" paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}" provider: "{{ cli }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,5 +1,5 @@
--- ---
- debug: msg="START TRANSPORT:CLI nxos_bgp_neighbor sanity test" - debug: msg="START TRANSPORT:{{ connection.transport}} nxos_bgp_neighbor sanity test"
- set_fact: intname="{{ nxos_int1 }}" - set_fact: intname="{{ nxos_int1 }}"
@ -13,19 +13,19 @@
nxos_feature: nxos_feature:
feature: bgp feature: bgp
state: enabled state: enabled
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- name: "Setup" - name: "Setup"
nxos_bgp: &remove nxos_bgp: &remove
asn: 65535 asn: 65535
state: absent state: absent
provider: "{{ cli }}" provider: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
- block: - block:
- name: "Configure BGP neighbor defaults" - name: "Configure BGP neighbor defaults"
nxos_bgp_neighbor: &configure_default nxos_bgp_neighbor: &configure_default
asn: 65535 asn: 65535
neighbor: 3.3.3.3 neighbor: 3.3.3.3
local_as: 20 local_as: 20
@ -33,7 +33,7 @@
description: "just a description" description: "just a description"
update_source: "{{ intname.capitalize() }}" update_source: "{{ intname.capitalize() }}"
state: present state: present
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: &true - assert: &true
@ -79,7 +79,7 @@
timers_holdtime: 270 timers_holdtime: 270
update_source: loopback151 update_source: loopback151
state: present state: present
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
@ -103,7 +103,7 @@
remote_as: 30 remote_as: 30
pwd: '386c0565965f89de' pwd: '386c0565965f89de'
pwd_type: 3des pwd_type: 3des
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
@ -127,7 +127,7 @@
remote_as: 30 remote_as: 30
pwd: '386c0565965f89de' pwd: '386c0565965f89de'
pwd_type: cisco_type_7 pwd_type: cisco_type_7
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
@ -150,7 +150,7 @@
neighbor: 3.3.3.3 neighbor: 3.3.3.3
remote_as: 30 remote_as: 30
transport_passive_only: true transport_passive_only: true
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
@ -172,7 +172,7 @@
neighbor: 3.3.3.3 neighbor: 3.3.3.3
remote_as: 30 remote_as: 30
transport_passive_only: false transport_passive_only: false
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: *true - assert: *true
@ -198,6 +198,6 @@
nxos_feature: &disable_bgp nxos_feature: &disable_bgp
feature: bgp feature: bgp
state: disabled state: disabled
provider: "{{ cli }}" provider: "{{ connection }}"
- debug: msg="END TRANSPORT:CLI nxos_bgp_neighbor sanity test" - debug: msg="END TRANSPORT:{{ connection.transport}} nxos_bgp_neighbor sanity test"

View file

@ -1,203 +0,0 @@
---
- debug: msg="START TRANSPORT:NXAPI nxos_bgp_neighbor sanity test"
- set_fact: intname="{{ nxos_int1 }}"
- set_fact: log_neighbor_changes="enable"
when: (titanium is defined) and not ((titanium | search('true')))
- set_fact: remove_private_as="all"
when: (titanium is defined) and not ((titanium | search('true')))
- name: "Enable feature BGP"
nxos_feature:
feature: bgp
state: enabled
provider: "{{ nxapi }}"
ignore_errors: yes
- name: "Setup"
nxos_bgp: &remove
asn: 65535
state: absent
provider: "{{ nxapi }}"
ignore_errors: yes
- block:
- name: "Configure BGP neighbor defaults"
nxos_bgp_neighbor: &configure_default
asn: 65535
neighbor: 3.3.3.3
local_as: 20
remote_as: 30
description: "just a description"
update_source: "{{ intname.capitalize() }}"
state: present
provider: "{{ nxapi }}"
register: result
- assert: &true
that:
- "result.changed == true"
- name: "Check Idempotence"
nxos_bgp_neighbor: *configure_default
register: result
- assert: &false
that:
- "result.changed == false"
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp: *remove
register: result
- assert: *false
- name: "Configure BGP neighbor non-defaults"
nxos_bgp_neighbor: &configure_non_default
asn: 65535
neighbor: 3.3.3.3
description: "tested by ansible"
connected_check: true
capability_negotiation: true
dynamic_capability: true
ebgp_multihop: 2
log_neighbor_changes: "{{log_neighbor_changes|default(omit)}}"
low_memory_exempt: true
remote_as: 12.1
remove_private_as: "{{remove_private_as|default(omit)}}"
shutdown: true
suppress_4_byte_as: true
timers_keepalive: 90
timers_holdtime: 270
update_source: loopback151
state: present
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp_neighbor: *configure_non_default
register: result
- assert: *false
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Configure BGP neighbor 3des password"
nxos_bgp_neighbor: &configure_3des_password
asn: 65535
neighbor: 3.3.3.3
remote_as: 30
pwd: '386c0565965f89de'
pwd_type: 3des
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp_neighbor: *configure_3des_password
register: result
- assert: *false
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Configure BGP neighbor type 7 password"
nxos_bgp_neighbor: &configure_type7_password
asn: 65535
neighbor: 3.3.3.3
remote_as: 30
pwd: '386c0565965f89de'
pwd_type: cisco_type_7
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp_neighbor: *configure_type7_password
register: result
- assert: *false
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Configure BGP neighbor transport type passive"
nxos_bgp_neighbor: &configure_transport_passive
asn: 65535
neighbor: 3.3.3.3
remote_as: 30
transport_passive_only: true
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp_neighbor: *configure_transport_passive
register: result
- assert: *false
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
- name: "Configure BGP neighbor transport type default"
nxos_bgp_neighbor: &configure_transport_default
asn: 65535
neighbor: 3.3.3.3
remote_as: 30
transport_passive_only: false
provider: "{{ nxapi }}"
register: result
- assert: *true
- name: "Check Idempotence"
nxos_bgp_neighbor: *configure_transport_default
register: result
- assert: *false
- name: "Remove BGP"
nxos_bgp: *remove
register: result
- assert: *true
rescue:
- name: "Cleanup BGP"
nxos_bgp: *remove
ignore_errors: yes
always:
- name: "Disable feature bgp"
nxos_feature: &disable_bgp
feature: bgp
state: disabled
provider: "{{ nxapi }}"
- debug: msg="END TRANSPORT:NXAPI nxos_bgp_neighbor sanity test"

View file

@ -1,15 +1,25 @@
--- ---
- name: collect all cli test cases - name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect cli test cases
find: find:
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,9 +1,19 @@
--- ---
- name: collect all nxapi test cases - name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find: find:
paths: "{{ role_path }}/tests/nxapi" paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}" provider: "{{ cli }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,5 +1,5 @@
--- ---
- debug: msg="START cli/negative.yaml" - debug: msg="START {{ connection.transport }}/negative.yaml"
- name: run 11 commands - name: run 11 commands
nxos_command: nxos_command:
@ -15,7 +15,7 @@
- show version - show version
- show version - show version
- show version - show version
provier: "{{ cli }}" provier: "{{ connection }}"
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -24,4 +24,4 @@
- result.failed - result.failed
- debug: msg="END cli/negative.yaml" - debug: msg="END {{ connection.transport }}/negative.yaml"

View file

@ -1,27 +0,0 @@
---
- debug: msg="START nxapi/negative.yaml"
- name: run 11 commands
nxos_command:
commands:
- show version
- show version
- show version
- show version
- show version
- show version
- show version
- show version
- show version
- show version
- show version
provier: "{{ nxapi }}"
ignore_errors: yes
register: result
- assert:
that:
- result.failed
- debug: msg="END nxapi/negative.yaml"

View file

@ -1,15 +1,25 @@
--- ---
- name: collect all cli test cases - name: collect common cli test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect cli test cases
find: find:
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: cli_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ cli }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,9 +1,19 @@
--- ---
- name: collect all nxapi test cases - name: collect common nxapi test cases
find:
paths: "{{ role_path }}/tests/common"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: collect nxapi test cases
find: find:
paths: "{{ role_path }}/tests/nxapi" paths: "{{ role_path }}/tests/nxapi"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: nxapi_cases
- set_fact:
test_cases:
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@ -16,7 +26,7 @@
provider: "{{ cli }}" provider: "{{ cli }}"
- name: run test case - name: run test case
include: "{{ test_case_to_run }}" include: "{{ test_case_to_run }} connection={{ nxapi }}"
with_items: "{{ test_items }}" with_items: "{{ test_items }}"
loop_control: loop_control:
loop_var: test_case_to_run loop_var: test_case_to_run

View file

@ -1,42 +0,0 @@
---
- debug: msg="START cli/defaults.yaml"
- name: setup
nxos_config:
commands:
- no description
- shutdown
parents:
- interface Ethernet2/5
match: none
provider: "{{ cli }}"
- name: configure device with defaults included
nxos_config:
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
register: result
- debug: var=result
- assert:
that:
- "result.changed == true"
- "result.updates is defined"
- name: check device with defaults included
nxos_config:
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
register: result
- debug: var=result
- assert:
that:
- "result.changed == false"
- "result.updates is not defined"
- debug: msg="END cli/defaults.yaml"

View file

@ -1,35 +0,0 @@
---
- debug: msg="START cli/save.yaml"
- name: setup
nxos_config:
commands:
- no description
- no shutdown
parents:
- interface Ethernet2/5
match: none
provider: "{{ cli }}"
- name: save config
nxos_config:
save: true
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- name: save should always run
nxos_config:
save: true
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- debug: msg="END cli/save.yaml"

View file

@ -1,19 +0,0 @@
---
- debug: msg="START cli/src_invalid.yaml"
# Defend https://github.com/ansible/ansible-modules-core/issues/4797
- name: configure with invalid src
nxos_config:
src: basic/foobar.j2
provider: "{{ cli }}"
register: result
ignore_errors: yes
- assert:
that:
- "result.changed == false"
- "result.failed == true"
- "result.msg == 'path specified in src not found'"
- debug: msg="END cli/src_invalid.yaml"

View file

@ -1,37 +0,0 @@
---
- debug: msg='START cli/toplevel.yaml'
- name: setup
nxos_config:
lines: hostname {{ inventory_hostname_short }}
provider: "{{ cli }}"
match: none
- name: configure top level command
nxos_config:
lines: hostname foo
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- name: configure top level command idempotent check
nxos_config:
lines: hostname foo
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
nxos_config:
lines: hostname {{ inventory_hostname_short }}
provider: "{{ cli }}"
match: none
- debug: msg='END cli/toplevel.yaml'

View file

@ -1,5 +1,5 @@
--- ---
- debug: msg="START cli/backup.yaml" - debug: msg="START {{ connection.transport }}/backup.yaml"
- name: setup - name: setup
nxos_config: nxos_config:
@ -9,7 +9,7 @@
parents: parents:
- interface Ethernet2/5 - interface Ethernet2/5
match: none match: none
provider: "{{ cli }}" provider: "{{ connection }}"
- name: collect any backup files - name: collect any backup files
find: find:
@ -28,7 +28,7 @@
nxos_config: nxos_config:
src: basic/config.j2 src: basic/config.j2
backup: yes backup: yes
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -47,4 +47,4 @@
that: that:
- "backup_files.files is defined" - "backup_files.files is defined"
- debug: msg="END cli/backup.yaml" - debug: msg="END {{ connection.transport }}/backup.yaml"

View file

@ -1,5 +1,5 @@
--- ---
- debug: msg="START nxapi/defaults.yaml" - debug: msg="START {{ connection.transport }}/defaults.yaml"
- name: setup - name: setup
nxos_config: nxos_config:
@ -9,13 +9,13 @@
parents: parents:
- interface Ethernet2/5 - interface Ethernet2/5
match: none match: none
provider: "{{ nxapi }}" provider: "{{ connection }}"
- name: configure device with defaults included - name: configure device with defaults included
nxos_config: nxos_config:
src: defaults/config.j2 src: defaults/config.j2
defaults: yes defaults: yes
provider: "{{ nxapi }}" provider: "{{ connection }}"
register: result register: result
- debug: var=result - debug: var=result
@ -29,7 +29,7 @@
nxos_config: nxos_config:
src: defaults/config.j2 src: defaults/config.j2
defaults: yes defaults: yes
provider: "{{ nxapi }}" provider: "{{ connection }}"
register: result register: result
- debug: var=result - debug: var=result
@ -39,4 +39,4 @@
- "result.changed == false" - "result.changed == false"
- "result.updates is not defined" - "result.updates is not defined"
- debug: msg="END nxapi/defaults.yaml" - debug: msg="END {{ connection.transport }}/defaults.yaml"

View file

@ -1,5 +1,5 @@
--- ---
- debug: msg="START nxapi/save.yaml" - debug: msg="START {{ connection.transport }}/save.yaml"
- name: setup - name: setup
nxos_config: nxos_config:
@ -9,13 +9,13 @@
parents: parents:
- interface Ethernet2/5 - interface Ethernet2/5
match: none match: none
provider: "{{ nxapi }}" provider: "{{ connection }}"
- name: save config - name: save config
nxos_config: nxos_config:
save: true save: true
provider: "{{ nxapi }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -25,11 +25,11 @@
- name: save should always run - name: save should always run
nxos_config: nxos_config:
save: true save: true
provider: "{{ nxapi }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
that: that:
- "result.changed == true" - "result.changed == true"
- debug: msg="END nxapi/save.yaml" - debug: msg="END {{ connection.transport }}/save.yaml"

View file

@ -1,5 +1,5 @@
--- ---
- debug: msg="START cli/src_basic.yaml" - debug: msg="START {{ connection.transport }}/src_basic.yaml"
- name: setup - name: setup
nxos_config: nxos_config:
@ -9,13 +9,13 @@
parents: parents:
- interface Ethernet2/5 - interface Ethernet2/5
match: none match: none
provider: "{{ cli }}" provider: "{{ connection }}"
- name: configure device with config - name: configure device with config
nxos_config: nxos_config:
src: basic/config.j2 src: basic/config.j2
defaults: yes defaults: yes
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -28,7 +28,7 @@
nxos_config: nxos_config:
src: basic/config.j2 src: basic/config.j2
defaults: yes defaults: yes
provider: "{{ cli }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -37,4 +37,4 @@
# https://github.com/ansible/ansible-modules-core/issues/4807 # https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is not defined" - "result.updates is not defined"
- debug: msg="END cli/src_basic.yaml" - debug: msg="END {{ connection.transport }}/src_basic.yaml"

View file

@ -1,12 +1,12 @@
--- ---
- debug: msg="START nxapi/src_invalid.yaml" - debug: msg="START {{ connection.transport }}/src_invalid.yaml"
# Defend https://github.com/ansible/ansible-modules-core/issues/4797 # Defend https://github.com/ansible/ansible-modules-core/issues/4797
- name: configure with invalid src - name: configure with invalid src
nxos_config: nxos_config:
src: basic/foobar.j2 src: basic/foobar.j2
provider: "{{ nxapi }}" provider: "{{ connection }}"
register: result register: result
ignore_errors: yes ignore_errors: yes
@ -16,4 +16,4 @@
- "result.failed == true" - "result.failed == true"
- "result.msg == 'path specified in src not found'" - "result.msg == 'path specified in src not found'"
- debug: msg="END nxapi/src_invalid.yaml" - debug: msg="END {{ connection.transport }}/src_invalid.yaml"

View file

@ -1,16 +1,16 @@
--- ---
- debug: msg="START nxapi/toplevel.yaml" - debug: msg='START {{ connection.transport }}/toplevel.yaml'
- name: setup - name: setup
nxos_config: nxos_config:
lines: hostname {{ inventory_hostname_short }} lines: hostname {{ inventory_hostname_short }}
provider: "{{ nxapi }}" provider: "{{ connection }}"
match: none match: none
- name: configure top level command - name: configure top level command
nxos_config: nxos_config:
lines: hostname foo lines: hostname foo
provider: "{{ nxapi }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -21,7 +21,7 @@
- name: configure top level command idempotent check - name: configure top level command idempotent check
nxos_config: nxos_config:
lines: hostname foo lines: hostname foo
provider: "{{ nxapi }}" provider: "{{ connection }}"
register: result register: result
- assert: - assert:
@ -31,7 +31,7 @@
- name: teardown - name: teardown
nxos_config: nxos_config:
lines: hostname {{ inventory_hostname_short }} lines: hostname {{ inventory_hostname_short }}
provider: "{{ nxapi }}" provider: "{{ connection }}"
match: none match: none
- debug: msg="END nxapi/toplevel.yaml" - debug: msg='END {{ connection.transport }}/toplevel.yaml'

View file

@ -1,16 +1,16 @@
--- ---
- debug: msg="START cli/nonidempotent.yaml" - debug: msg="START {{ connection.transport }}/nonidempotent.yaml"
- name: setup - name: setup
nxos_config: nxos_config:
lines: hostname {{ inventory_hostname_short }} lines: hostname {{ inventory_hostname_short }}
provider: "{{ cli }}" provider: "{{ connection }}"
match: none match: none
- name: configure top level command - name: configure top level command
nxos_config: nxos_config:
lines: hostname foo lines: hostname foo
provider: "{{ cli }}" provider: "{{ connection }}"
match: strict match: strict
register: result register: result
@ -22,7 +22,7 @@
- name: configure top level command idempotent check - name: configure top level command idempotent check
nxos_config: nxos_config:
lines: hostname foo lines: hostname foo
provider: "{{ cli }}" provider: "{{ connection }}"
match: strict match: strict
register: result register: result
@ -33,7 +33,7 @@
- name: teardown - name: teardown
nxos_config: nxos_config:
lines: hostname {{ inventory_hostname_short }} lines: hostname {{ inventory_hostname_short }}
provider: "{{ cli }}" provider: "{{ connection }}"
match: none match: none
- debug: msg="END cli/nonidempotent.yaml" - debug: msg="END {{ connection.transport }}/nonidempotent.yaml"

View file

@ -1,38 +0,0 @@
---
- debug: msg="START nxapi/src_basic.yaml"
- name: setup
nxos_config:
commands:
- no description
- no shutdown
parents:
- interface Ethernet2/5
match: none
provider: "{{ nxapi }}"
- name: configure device with config
nxos_config:
src: basic/config.j2
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == true"
# https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is defined"
- name: check device with config
nxos_config:
src: basic/config.j2
provider: "{{ nxapi }}"
register: result
- assert:
that:
- "result.changed == false"
# https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is not defined"
- debug: msg="END nxapi/src_basic.yaml"

View file

@ -1,39 +0,0 @@
---
- debug: msg="START nxapi/toplevel_nonidempontent"
- name: setup
nxos_config:
lines: hostname {{ inventory_hostname_short }}
provider: "{{ nxapi }}"
match: none
- name: configure top level command
nxos_config:
lines: hostname foo
provider: "{{ nxapi }}"
match: strict
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- name: configure top level command idempotent check
nxos_config:
lines: hostname foo
provider: "{{ nxapi }}"
match: strict
register: result
- assert:
that:
- "result.changed == true"
- name: setup
nxos_config:
lines: hostname {{ inventory_hostname_short }}
provider: "{{ nxapi }}"
match: none
- debug: msg="END nxapi/toplevel_nonidempontent"