mirror of https://github.com/ansible/ansible.git
* Fixes for #27170, #27172 * Add nxos_ip_interface IT tests * For ipv6 check if ip address configured before doing a no ip addresspull/23717/merge
parent
a01c38756d
commit
b9c3329950
@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- prepare_nxos_tests
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
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
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
# Use block to ensure that both cli and nxapi tests
|
||||
# will run even if there are failures or errors.
|
||||
- block:
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
always:
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: collect all nxapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/nxapi"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: enable nxapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- feature nxapi
|
||||
- nxapi http port 80
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: disable nxapi
|
||||
nxos_config:
|
||||
lines:
|
||||
- no feature nxapi
|
||||
provider: "{{ cli }}"
|
@ -0,0 +1,99 @@
|
||||
---
|
||||
- debug: msg="START TRANSPORT:CLI nxos_ip_interface sanity test"
|
||||
|
||||
- set_fact: testint1="{{ nxos_int1 }}"
|
||||
- set_fact: testint2="{{ nxos_int2 }}"
|
||||
|
||||
- name: "Put interface {{testint1}} into default state"
|
||||
nxos_config: &intdefault1
|
||||
lines:
|
||||
- "default interface {{ testint1 }}"
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Put interface {{testint2}} into default state"
|
||||
nxos_config: &intdefault2
|
||||
lines:
|
||||
- "default interface {{ testint2 }}"
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Make {{testint1}} a layer3 interface"
|
||||
nxos_interface: &l3int1
|
||||
interface: "{{ testint1 }}"
|
||||
mode: layer3
|
||||
description: 'Configured by Ansible - Layer3'
|
||||
admin_state: 'up'
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: "Make {{testint2}} a layer3 interface"
|
||||
nxos_interface: &l3int2
|
||||
interface: "{{ testint2 }}"
|
||||
mode: layer3
|
||||
description: 'Configured by Ansible - Layer3'
|
||||
admin_state: 'up'
|
||||
state: present
|
||||
provider: "{{ cli }}"
|
||||
|
||||
# For titanium
|
||||
- name: Clear interface v4
|
||||
nxos_ip_interface:
|
||||
interface: "{{ testint1 }}"
|
||||
version: v4
|
||||
state: absent
|
||||
addr: 20.20.20.20
|
||||
mask: 24
|
||||
provider: "{{ cli }}"
|
||||
|
||||
# For titanium
|
||||
- name: Clear interface v6
|
||||
nxos_ip_interface:
|
||||
interface: "{{ testint2 }}"
|
||||
version: v6
|
||||
state: absent
|
||||
addr: 'fd56:31f7:e4ad:5585::1'
|
||||
mask: 64
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: Ensure ipv4 address is configured
|
||||
nxos_ip_interface: &ipv4
|
||||
interface: "{{ testint1 }}"
|
||||
version: v4
|
||||
state: present
|
||||
addr: 20.20.20.20
|
||||
mask: 24
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: "Check Idempotence"
|
||||
nxos_ip_interface: *ipv4
|
||||
register: result
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Ensure ipv6 address is configured
|
||||
nxos_ip_interface: &ipv6
|
||||
interface: "{{ testint2 }}"
|
||||
version: v6
|
||||
state: present
|
||||
addr: 'fd56:31f7:e4ad:5585::1'
|
||||
mask: 64
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence"
|
||||
nxos_ip_interface: *ipv6
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- debug: msg="END TRANSPORT:CLI nxos_ip_interface sanity test"
|
@ -0,0 +1,99 @@
|
||||
---
|
||||
- debug: msg="START TRANSPORT:NXAPI nxos_ip_interface sanity test"
|
||||
|
||||
- set_fact: testint1="{{ nxos_int1 }}"
|
||||
- set_fact: testint2="{{ nxos_int2 }}"
|
||||
|
||||
- name: "Put interface {{testint1}} into default state"
|
||||
nxos_config: &intdefault1
|
||||
lines:
|
||||
- "default interface {{ testint1 }}"
|
||||
provider: "{{ nxapi }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Put interface {{testint2}} into default state"
|
||||
nxos_config: &intdefault2
|
||||
lines:
|
||||
- "default interface {{ testint2 }}"
|
||||
provider: "{{ nxapi }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Make {{testint1}} a layer3 interface"
|
||||
nxos_interface: &l3int1
|
||||
interface: "{{ testint1 }}"
|
||||
mode: layer3
|
||||
description: 'Configured by Ansible - Layer3'
|
||||
admin_state: 'up'
|
||||
state: present
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: "Make {{testint2}} a layer3 interface"
|
||||
nxos_interface: &l3int2
|
||||
interface: "{{ testint2 }}"
|
||||
mode: layer3
|
||||
description: 'Configured by Ansible - Layer3'
|
||||
admin_state: 'up'
|
||||
state: present
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
# For titanium
|
||||
- name: Clear interface v4
|
||||
nxos_ip_interface:
|
||||
interface: "{{ testint1 }}"
|
||||
version: v4
|
||||
state: absent
|
||||
addr: 20.20.20.20
|
||||
mask: 24
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
# For titanium
|
||||
- name: Clear interface v6
|
||||
nxos_ip_interface:
|
||||
interface: "{{ testint2 }}"
|
||||
version: v6
|
||||
state: absent
|
||||
addr: 'fd56:31f7:e4ad:5585::1'
|
||||
mask: 64
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: Ensure ipv4 address is configured
|
||||
nxos_ip_interface: &ipv4
|
||||
interface: "{{ testint1 }}"
|
||||
version: v4
|
||||
state: present
|
||||
addr: 20.20.20.20
|
||||
mask: 24
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: "Check Idempotence"
|
||||
nxos_ip_interface: *ipv4
|
||||
register: result
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Ensure ipv6 address is configured
|
||||
nxos_ip_interface: &ipv6
|
||||
interface: "{{ testint2 }}"
|
||||
version: v6
|
||||
state: present
|
||||
addr: 'fd56:31f7:e4ad:5585::1'
|
||||
mask: 64
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence"
|
||||
nxos_ip_interface: *ipv6
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- debug: msg="END TRANSPORT:NXAPI nxos_ip_interface sanity test"
|
Loading…
Reference in New Issue