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

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 nxapi
This commit is contained in:
rahushen 2017-09-01 05:44:24 -04:00 committed by Nathaniel Case
parent e513ec10da
commit 50d148a7d6
10 changed files with 112 additions and 176 deletions

View file

@ -1,13 +1,16 @@
---
- debug: msg="START {{ connection.transport }}/backup.yaml"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- name: setup
nxos_config:
commands:
- no description
- no shutdown
parents:
- interface Ethernet2/5
- "interface {{ intname }}"
match: none
provider: "{{ connection }}"
@ -26,7 +29,11 @@
- name: configure device with config
nxos_config:
src: basic/config.j2
commands:
- description this is a test
- shutdown
parents:
- "interface {{ intname }}"
backup: yes
provider: "{{ connection }}"
register: result

View file

@ -1,19 +1,26 @@
---
- debug: msg="START {{ connection.transport }}/defaults.yaml"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- name: setup
nxos_config:
commands:
- no description
- shutdown
parents:
- interface Ethernet2/5
- "interface {{ intname }}"
match: none
provider: "{{ connection }}"
- name: configure device with defaults included
nxos_config:
src: defaults/config.j2
commands:
- description this is a test
- no shutdown
parents:
- "interface {{ intname }}"
defaults: yes
provider: "{{ connection }}"
register: result
@ -27,7 +34,11 @@
- name: check device with defaults included
nxos_config:
src: defaults/config.j2
commands:
- description this is a test
- no shutdown
parents:
- "interface {{ intname }}"
defaults: yes
provider: "{{ connection }}"
register: result

View file

@ -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"

View file

@ -1,20 +1,23 @@
---
- debug: msg="START {{ connection.transport }}/save.yaml"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- name: setup
nxos_config:
commands:
- no description
- no shutdown
parents:
- interface Ethernet2/5
- "interface {{ intname }}"
match: none
provider: "{{ connection }}"
- name: save config
nxos_config:
save: true
save_when: always
timeout: 300
provider: "{{ connection }}"
register: result
@ -24,7 +27,8 @@
- name: save should always run
nxos_config:
save: true
save_when: always
timeout: 300
provider: "{{ connection }}"
register: result

View file

@ -1,19 +1,26 @@
---
- debug: msg="START {{ connection.transport }}/src_basic.yaml"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- name: setup
nxos_config:
commands:
- no description
- no shutdown
parents:
- interface Ethernet2/5
- "interface {{ intname }}"
match: none
provider: "{{ connection }}"
- name: configure device with config
nxos_config:
src: basic/config.j2
commands:
- description this is a test
- shutdown
parents:
- "interface {{ intname }}"
defaults: yes
provider: "{{ connection }}"
register: result
@ -26,7 +33,11 @@
- name: check device with config
nxos_config:
src: basic/config.j2
commands:
- description this is a test
- shutdown
parents:
- "interface {{ intname }}"
defaults: yes
provider: "{{ connection }}"
register: result

View file

@ -1,5 +1,8 @@
---
- debug: msg="START cli/src_match_none.yaml"
- debug: msg="START {{ connection.transport }}/src_match_none.yaml"
# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
- name: setup
nxos_config:
@ -7,14 +10,18 @@
- no description
- no shutdown
parents:
- interface Ethernet2/5
- "interface {{ intname }}"
match: none
provider: "{{ cli }}"
provider: "{{ connection }}"
- name: configure device with config
nxos_config:
src: basic/config.j2
provider: "{{ cli }}"
commands:
- description this is a test
- shutdown
parents:
- "interface {{ intname }}"
provider: "{{ connection }}"
match: none
defaults: yes
register: result
@ -27,8 +34,12 @@
- name: check device with config
nxos_config:
src: basic/config.j2
provider: "{{ cli }}"
commands:
- description this is a test
- shutdown
parents:
- "interface {{ intname }}"
provider: "{{ connection }}"
defaults: yes
register: result
@ -39,4 +50,4 @@
- "result.changed == false"
- "result.updates is not defined"
- debug: msg="END cli/src_match_none.yaml"
- debug: msg="END {{ connection.transport }}/src_match_none.yaml"

View file

@ -1,5 +1,5 @@
---
- debug: msg='START cli/sublevel_block.yaml'
- debug: msg='START {{ connection.transport }}/sublevel_block.yaml'
- name: setup
nxos_config:
@ -8,10 +8,10 @@
- 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
provider: "{{ cli }}"
provider: "{{ connection }}"
match: none
- name: configure sub level command using block resplace
- name: configure sub level command using block replace
nxos_config:
lines:
- 10 permit ip 1.1.1.1/32 any log
@ -20,7 +20,7 @@
- 40 permit ip 4.4.4.4/32 any log
parents: ip access-list test
replace: block
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -41,7 +41,7 @@
- 40 permit ip 4.4.4.4/32 any log
parents: ip access-list test
replace: block
provider: "{{ cli }}"
provider: "{{ connection }}"
register: result
- assert:
@ -51,7 +51,7 @@
- name: teardown
nxos_config:
lines: no ip access-list test
provider: "{{ cli }}"
provider: "{{ connection }}"
match: none
- debug: msg='END cli/sublevel_block.yaml'
- debug: msg='END {{ connection.transport }}/sublevel_block.yaml'

View file

@ -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"

View file

@ -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"

View file

@ -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"