mirror of https://github.com/ansible/ansible.git
Add nxos_config IT (#28853)
* recalibrate tests and add new ones * add new cli tests * add new nxapi tests * Add new tests for cli and nxapipull/28925/head
parent
e513ec10da
commit
50d148a7d6
@ -0,0 +1,41 @@
|
||||
---
|
||||
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_config sanity test"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines: ip access-list test
|
||||
provider: "{{ connection }}"
|
||||
match: none
|
||||
|
||||
- name: "TRANSPORT:CLI nxos_config sanity test"
|
||||
nxos_config:
|
||||
lines:
|
||||
- 10 permit ip 1.1.1.1/32 any log
|
||||
- 20 permit ip 2.2.2.2/32 any log
|
||||
- 30 permit ip 3.3.3.3/32 any log
|
||||
- 40 permit ip 4.4.4.4/32 any log
|
||||
- 50 permit ip 5.5.5.5/32 any log
|
||||
parents: ip access-list test
|
||||
before: no ip access-list test
|
||||
match: exact
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: "TRANSPORT:CLI nxos_config sanity test - replace block"
|
||||
nxos_config:
|
||||
lines:
|
||||
- 10 permit ip 1.1.1.1/32 any log
|
||||
- 20 permit ip 2.2.2.2/32 any log
|
||||
- 30 permit ip 3.3.3.3/32 any log
|
||||
- 40 permit ip 4.4.4.4/32 any log
|
||||
parents: ip access-list test
|
||||
before: no ip access-list test
|
||||
replace: block
|
||||
provider: "{{ connection }}"
|
||||
|
||||
- name: teardown
|
||||
nxos_config:
|
||||
lines: no ip access-list test
|
||||
provider: "{{ connection }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_config sanity test"
|
@ -1,50 +0,0 @@
|
||||
---
|
||||
- debug: msg="START nxapi/backup.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
commands:
|
||||
- no description
|
||||
- no shutdown
|
||||
parents:
|
||||
- interface Ethernet2/5
|
||||
match: none
|
||||
provider: "{{ nxapi }}"
|
||||
|
||||
- name: collect any backup files
|
||||
find:
|
||||
paths: "{{ role_path }}/backup"
|
||||
pattern: "{{ inventory_hostname_short }}_config*"
|
||||
register: backup_files
|
||||
delegate_to: localhost
|
||||
|
||||
- name: delete backup files
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
with_items: "{{backup_files.files|default([])}}"
|
||||
|
||||
- name: configure device with config
|
||||
nxos_config:
|
||||
src: basic/config.j2
|
||||
backup: yes
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "result.updates is defined"
|
||||
|
||||
- name: collect any backup files
|
||||
find:
|
||||
paths: "{{ role_path }}/backup"
|
||||
pattern: "{{ inventory_hostname_short }}_config*"
|
||||
register: backup_files
|
||||
delegate_to: localhost
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "backup_files.files is defined"
|
||||
|
||||
- debug: msg="END nxapi/backup.yaml"
|
@ -1,40 +0,0 @@
|
||||
---
|
||||
- debug: msg="START nxapi/src_match_none.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 }}"
|
||||
match: none
|
||||
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:
|
||||
# Idempotent test
|
||||
# https://github.com/ansible/ansible-modules-core/issues/4807
|
||||
- "result.changed == false"
|
||||
- "result.updates is not defined"
|
||||
|
||||
- debug: msg="END nxapi/src_match_none.yaml"
|
@ -1,59 +0,0 @@
|
||||
---
|
||||
- debug: msg="START nxapi/sublevel_block.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines:
|
||||
- 10 permit ip 1.1.1.1/32 any log
|
||||
- 20 permit ip 2.2.2.2/32 any log
|
||||
- 30 permit ip 3.3.3.3/32 any log
|
||||
parents: ip access-list test
|
||||
before: no ip access-list test
|
||||
provider: "{{ nxapi }}"
|
||||
match: none
|
||||
ignore_errors: yes
|
||||
|
||||
- name: configure sub level command using block resplace
|
||||
nxos_config:
|
||||
lines:
|
||||
- 10 permit ip 1.1.1.1/32 any log
|
||||
- 20 permit ip 2.2.2.2/32 any log
|
||||
- 30 permit ip 3.3.3.3/32 any log
|
||||
- 40 permit ip 4.4.4.4/32 any log
|
||||
parents: ip access-list test
|
||||
replace: block
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list test' in result.updates"
|
||||
- "'10 permit ip 1.1.1.1/32 any log' in result.updates"
|
||||
- "'20 permit ip 2.2.2.2/32 any log' in result.updates"
|
||||
- "'30 permit ip 3.3.3.3/32 any log' in result.updates"
|
||||
- "'40 permit ip 4.4.4.4/32 any log' in result.updates"
|
||||
|
||||
- name: check sub level command using block replace
|
||||
nxos_config:
|
||||
lines:
|
||||
- 10 permit ip 1.1.1.1/32 any log
|
||||
- 20 permit ip 2.2.2.2/32 any log
|
||||
- 30 permit ip 3.3.3.3/32 any log
|
||||
- 40 permit ip 4.4.4.4/32 any log
|
||||
parents: ip access-list test
|
||||
replace: block
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
nxos_config:
|
||||
lines: no ip access-list test
|
||||
provider: "{{ nxapi }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END nxapi/sublevel_block.yaml"
|
Loading…
Reference in New Issue