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:
parent
e513ec10da
commit
50d148a7d6
10 changed files with 112 additions and 176 deletions
|
@ -1,13 +1,16 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START {{ connection.transport }}/backup.yaml"
|
- debug: msg="START {{ connection.transport }}/backup.yaml"
|
||||||
|
|
||||||
|
# Select interface for test
|
||||||
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
nxos_config:
|
nxos_config:
|
||||||
commands:
|
commands:
|
||||||
- no description
|
- no description
|
||||||
- no shutdown
|
- no shutdown
|
||||||
parents:
|
parents:
|
||||||
- interface Ethernet2/5
|
- "interface {{ intname }}"
|
||||||
match: none
|
match: none
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
@ -26,7 +29,11 @@
|
||||||
|
|
||||||
- name: configure device with config
|
- name: configure device with config
|
||||||
nxos_config:
|
nxos_config:
|
||||||
src: basic/config.j2
|
commands:
|
||||||
|
- description this is a test
|
||||||
|
- shutdown
|
||||||
|
parents:
|
||||||
|
- "interface {{ intname }}"
|
||||||
backup: yes
|
backup: yes
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START {{ connection.transport }}/defaults.yaml"
|
- debug: msg="START {{ connection.transport }}/defaults.yaml"
|
||||||
|
|
||||||
|
# Select interface for test
|
||||||
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
nxos_config:
|
nxos_config:
|
||||||
commands:
|
commands:
|
||||||
- no description
|
- no description
|
||||||
- shutdown
|
- shutdown
|
||||||
parents:
|
parents:
|
||||||
- interface Ethernet2/5
|
- "interface {{ intname }}"
|
||||||
match: none
|
match: none
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
- name: configure device with defaults included
|
- name: configure device with defaults included
|
||||||
nxos_config:
|
nxos_config:
|
||||||
src: defaults/config.j2
|
commands:
|
||||||
|
- description this is a test
|
||||||
|
- no shutdown
|
||||||
|
parents:
|
||||||
|
- "interface {{ intname }}"
|
||||||
defaults: yes
|
defaults: yes
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -27,7 +34,11 @@
|
||||||
|
|
||||||
- name: check device with defaults included
|
- name: check device with defaults included
|
||||||
nxos_config:
|
nxos_config:
|
||||||
src: defaults/config.j2
|
commands:
|
||||||
|
- description this is a test
|
||||||
|
- no shutdown
|
||||||
|
parents:
|
||||||
|
- "interface {{ intname }}"
|
||||||
defaults: yes
|
defaults: yes
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
|
@ -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,20 +1,23 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START {{ connection.transport }}/save.yaml"
|
- debug: msg="START {{ connection.transport }}/save.yaml"
|
||||||
|
|
||||||
|
# Select interface for test
|
||||||
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
nxos_config:
|
nxos_config:
|
||||||
commands:
|
commands:
|
||||||
- no description
|
- no description
|
||||||
- no shutdown
|
- no shutdown
|
||||||
parents:
|
parents:
|
||||||
- interface Ethernet2/5
|
- "interface {{ intname }}"
|
||||||
match: none
|
match: none
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
|
|
||||||
- name: save config
|
- name: save config
|
||||||
nxos_config:
|
nxos_config:
|
||||||
save: true
|
save_when: always
|
||||||
|
timeout: 300
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -24,7 +27,8 @@
|
||||||
|
|
||||||
- name: save should always run
|
- name: save should always run
|
||||||
nxos_config:
|
nxos_config:
|
||||||
save: true
|
save_when: always
|
||||||
|
timeout: 300
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START {{ connection.transport }}/src_basic.yaml"
|
- debug: msg="START {{ connection.transport }}/src_basic.yaml"
|
||||||
|
|
||||||
|
# Select interface for test
|
||||||
|
- set_fact: intname="{{ nxos_int1 }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
nxos_config:
|
nxos_config:
|
||||||
commands:
|
commands:
|
||||||
- no description
|
- no description
|
||||||
- no shutdown
|
- no shutdown
|
||||||
parents:
|
parents:
|
||||||
- interface Ethernet2/5
|
- "interface {{ intname }}"
|
||||||
match: none
|
match: none
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
|
|
||||||
- name: configure device with config
|
- name: configure device with config
|
||||||
nxos_config:
|
nxos_config:
|
||||||
src: basic/config.j2
|
commands:
|
||||||
|
- description this is a test
|
||||||
|
- shutdown
|
||||||
|
parents:
|
||||||
|
- "interface {{ intname }}"
|
||||||
defaults: yes
|
defaults: yes
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -26,7 +33,11 @@
|
||||||
|
|
||||||
- name: check device with config
|
- name: check device with config
|
||||||
nxos_config:
|
nxos_config:
|
||||||
src: basic/config.j2
|
commands:
|
||||||
|
- description this is a test
|
||||||
|
- shutdown
|
||||||
|
parents:
|
||||||
|
- "interface {{ intname }}"
|
||||||
defaults: yes
|
defaults: yes
|
||||||
provider: "{{ connection }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
|
@ -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
|
- name: setup
|
||||||
nxos_config:
|
nxos_config:
|
||||||
|
@ -7,14 +10,18 @@
|
||||||
- no description
|
- no description
|
||||||
- no shutdown
|
- no shutdown
|
||||||
parents:
|
parents:
|
||||||
- interface Ethernet2/5
|
- "interface {{ intname }}"
|
||||||
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
|
commands:
|
||||||
provider: "{{ cli }}"
|
- description this is a test
|
||||||
|
- shutdown
|
||||||
|
parents:
|
||||||
|
- "interface {{ intname }}"
|
||||||
|
provider: "{{ connection }}"
|
||||||
match: none
|
match: none
|
||||||
defaults: yes
|
defaults: yes
|
||||||
register: result
|
register: result
|
||||||
|
@ -27,8 +34,12 @@
|
||||||
|
|
||||||
- name: check device with config
|
- name: check device with config
|
||||||
nxos_config:
|
nxos_config:
|
||||||
src: basic/config.j2
|
commands:
|
||||||
provider: "{{ cli }}"
|
- description this is a test
|
||||||
|
- shutdown
|
||||||
|
parents:
|
||||||
|
- "interface {{ intname }}"
|
||||||
|
provider: "{{ connection }}"
|
||||||
defaults: yes
|
defaults: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -39,4 +50,4 @@
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
- "result.updates is not defined"
|
- "result.updates is not defined"
|
||||||
|
|
||||||
- debug: msg="END cli/src_match_none.yaml"
|
- debug: msg="END {{ connection.transport }}/src_match_none.yaml"
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg='START cli/sublevel_block.yaml'
|
- debug: msg='START {{ connection.transport }}/sublevel_block.yaml'
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
nxos_config:
|
nxos_config:
|
||||||
|
@ -8,10 +8,10 @@
|
||||||
- 20 permit ip 2.2.2.2/32 any log
|
- 20 permit ip 2.2.2.2/32 any log
|
||||||
- 30 permit ip 3.3.3.3/32 any log
|
- 30 permit ip 3.3.3.3/32 any log
|
||||||
parents: ip access-list test
|
parents: ip access-list test
|
||||||
provider: "{{ cli }}"
|
provider: "{{ connection }}"
|
||||||
match: none
|
match: none
|
||||||
|
|
||||||
- name: configure sub level command using block resplace
|
- name: configure sub level command using block replace
|
||||||
nxos_config:
|
nxos_config:
|
||||||
lines:
|
lines:
|
||||||
- 10 permit ip 1.1.1.1/32 any log
|
- 10 permit ip 1.1.1.1/32 any log
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
- 40 permit ip 4.4.4.4/32 any log
|
- 40 permit ip 4.4.4.4/32 any log
|
||||||
parents: ip access-list test
|
parents: ip access-list test
|
||||||
replace: block
|
replace: block
|
||||||
provider: "{{ cli }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
- 40 permit ip 4.4.4.4/32 any log
|
- 40 permit ip 4.4.4.4/32 any log
|
||||||
parents: ip access-list test
|
parents: ip access-list test
|
||||||
replace: block
|
replace: block
|
||||||
provider: "{{ cli }}"
|
provider: "{{ connection }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
- name: teardown
|
- name: teardown
|
||||||
nxos_config:
|
nxos_config:
|
||||||
lines: no ip access-list test
|
lines: no ip access-list test
|
||||||
provider: "{{ cli }}"
|
provider: "{{ connection }}"
|
||||||
match: none
|
match: none
|
||||||
|
|
||||||
- debug: msg='END cli/sublevel_block.yaml'
|
- debug: msg='END {{ connection.transport }}/sublevel_block.yaml'
|
|
@ -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 a new issue