Migrate Network Tests into ansible/ansible (#18233)

* Docs Networking tests

* Copy networking tests from test-network-modules

* Networking transport settings - group_vars

* Network playbooks

* Debug should be off by default

* Update nxos.yaml

* Remove items from top level

* Use dependencies, not pre-tasks

* Remove trailing blank lines

* Remove backup files

* newlines
This commit is contained in:
John R Barker
2016-10-28 19:50:29 +01:00
committed by GitHub
parent 4a067c3f50
commit e0cc7b3415
489 changed files with 13144 additions and 2 deletions

View File

@@ -0,0 +1,50 @@
---
- debug: msg="START cli/backup.yaml"
- name: setup
eos_config:
commands:
- no description
- no shutdown
parents:
- interface Ethernet5
match: none
provider: "{{ cli }}"
- name: collect any backup files
find:
paths: "{{ role_path }}/backup"
pattern: "{{ inventory_hostname }}_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
eos_config:
src: basic/config.j2
backup: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "result.updates is not defined"
- name: collect any backup files
find:
paths: "{{ role_path }}/backup"
pattern: "{{ inventory_hostname }}_config*"
register: backup_files
delegate_to: localhost
- assert:
that:
- "backup_files.files is defined"
- debug: msg="END cli/backup.yaml"

View File

@@ -0,0 +1,46 @@
---
- debug: msg="START cli/config.yaml"
- name: setup
eos_config:
lines: hostname {{ inventory_hostname }}
match: none
provider: "{{ cli }}"
- name: get current running-config
eos_command:
commands: show running-config
provider: "{{ cli }}"
register: config
- name: configure hostname
eos_config:
lines: hostname foo
config: "{{ config.stdout[0] }}"
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- name: configure hostname again
eos_config:
lines: hostname foo
config: "{{ config.stdout[0] }}"
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- "'hostname foo' in result.updates"
- name: teardown
eos_config:
lines: hostname {{ inventory_hostname }}
match: none
provider: "{{ cli }}"
- debug: msg="END cli/config.yaml"

View File

@@ -0,0 +1,42 @@
---
- debug: msg="START cli/defaults.yaml"
- name: setup
eos_config:
commands:
- no description
- shutdown
parents:
- interface Ethernet5
match: none
provider: "{{ cli }}"
- name: configure device with defaults included
eos_config:
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
register: result
- debug: var=result
- assert:
that:
- "result.changed == true"
- "result.updates is not defined"
- name: check device with defaults included
eos_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

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

View File

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

View File

@@ -0,0 +1,19 @@
---
- debug: msg="START cli/src_invalid.yaml"
# Defend https://github.com/ansible/ansible-modules-core/issues/4797
- name: configure with invalid src
eos_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

@@ -0,0 +1,41 @@
---
- debug: msg="START cli/src_match_none.yaml"
- name: setup
eos_config:
commands:
- no description
- no shutdown
parents:
- interface Ethernet5
match: none
provider: "{{ cli }}"
- name: configure device with config
eos_config:
src: basic/config.j2
provider: "{{ cli }}"
match: none
register: result
- assert:
that:
- "result.changed == true"
# https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is not defined"
- name: check device with config
eos_config:
src: basic/config.j2
provider: "{{ cli }}"
match: none
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 cli/src_match_none.yaml"

View File

@@ -0,0 +1,41 @@
---
- debug: msg="START cli/sublevel.yaml"
- name: setup
eos_config:
lines: no vlan 10
match: none
provider: "{{ cli }}"
- name: configure sub level command
eos_config:
lines: name test
parents: vlan 10
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'vlan 10' in result.updates"
- "'name test' in result.updates"
- name: configure sub level command idempotent check
eos_config:
lines: name test
parents: vlan 10
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
eos_config:
lines: no vlan 10
match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel.yaml"

View File

@@ -0,0 +1,61 @@
---
- debug: msg="START cli/sublevel_block.yaml"
- name: setup
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 2.2.2.2 any log
- 30 permit ip host 3.3.3.3 any log
parents: ip access-list test
before: no ip access-list test
after: exit
match: none
provider: "{{ cli }}"
- name: configure sub level command using block resplace
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 2.2.2.2 any log
- 30 permit ip host 3.3.3.3 any log
- 40 permit ip host 4.4.4.4 any log
parents: ip access-list test
replace: block
after: exit
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'ip access-list test' in result.updates"
- "'10 permit ip host 1.1.1.1 any log' in result.updates"
- "'20 permit ip host 2.2.2.2 any log' in result.updates"
- "'30 permit ip host 3.3.3.3 any log' in result.updates"
- "'40 permit ip host 4.4.4.4 any log' in result.updates"
- name: check sub level command using block replace
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 2.2.2.2 any log
- 30 permit ip host 3.3.3.3 any log
- 40 permit ip host 4.4.4.4 any log
parents: ip access-list test
replace: block
after: exit
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
eos_config:
lines: no ip access-list test
match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_block.yaml"

View File

@@ -0,0 +1,65 @@
---
- debug: msg="START cli/sublevel_exact.yaml"
- name: setup
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 2.2.2.2 any log
- 30 permit ip host 3.3.3.3 any log
- 40 permit ip host 4.4.4.4 any log
- 50 permit ip host 5.5.5.5 any log
parents: ip access-list test
before: no ip access-list test
after: exit
match: none
provider: "{{ cli }}"
- name: configure sub level command using exact match
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 2.2.2.2 any log
- 30 permit ip host 3.3.3.3 any log
- 40 permit ip host 4.4.4.4 any log
parents: ip access-list test
before: no ip access-list test
after: exit
match: exact
replace: block
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'ip access-list test' in result.updates"
- "'10 permit ip host 1.1.1.1 any log' in result.updates"
- "'20 permit ip host 2.2.2.2 any log' in result.updates"
- "'30 permit ip host 3.3.3.3 any log' in result.updates"
- "'40 permit ip host 4.4.4.4 any log' in result.updates"
- "'50 permit ip host 5.5.5.5 any log' not in result.updates"
- name: check sub level command using exact match
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 2.2.2.2 any log
- 30 permit ip host 3.3.3.3 any log
- 40 permit ip host 4.4.4.4 any log
parents: ip access-list test
match: exact
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
eos_config:
lines: no ip access-list test
match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_exact.yaml"

View File

@@ -0,0 +1,65 @@
---
- debug: msg="START cli/sublevel_strict.yaml"
- name: setup
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 2.2.2.2 any log
- 30 permit ip host 3.3.3.3 any log
- 40 permit ip host 4.4.4.4 any log
- 50 permit ip host 5.5.5.5 any log
parents: ip access-list test
before: no ip access-list test
after: exit
match: none
provider: "{{ cli }}"
- name: configure sub level command using strict match
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 3.3.3.3 any log
- 30 permit ip host 2.2.2.2 any log
- 40 permit ip host 4.4.4.4 any log
parents: ip access-list test
before: no ip access-list test
after: exit
match: strict
replace: block
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'ip access-list test' in result.updates"
- "'10 permit ip host 1.1.1.1 any log' in result.updates"
- "'30 permit ip host 2.2.2.2 any log' in result.updates"
- "'20 permit ip host 3.3.3.3 any log' in result.updates"
- "'40 permit ip host 4.4.4.4 any log' in result.updates"
- "'50 permit ip host 5.5.5.5 any log' not in result.updates"
- name: check sub level command using strict match
eos_config:
lines:
- 10 permit ip host 1.1.1.1 any log
- 20 permit ip host 3.3.3.3 any log
- 30 permit ip host 2.2.2.2 any log
- 40 permit ip host 4.4.4.4 any log
parents: ip access-list test
match: strict
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
eos_config:
lines: no ip access-list test
match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_strict.yaml"

View File

@@ -0,0 +1,37 @@
---
- debug: msg="START cli/toplevel.yaml"
- name: setup
eos_config:
lines: hostname veos01
match: none
provider: "{{ cli }}"
- name: configure top level command
eos_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
eos_config:
lines: hostname foo
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
eos_config:
lines: hostname veos01
match: none
provider: "{{ cli }}"
- debug: msg="END cli/toplevel.yaml"

View File

@@ -0,0 +1,44 @@
---
- debug: msg="START cli/toplevel_after.yaml"
- name: setup
eos_config:
lines:
- snmp-server contact ansible
- hostname veos01
match: none
provider: "{{ cli }}"
- name: configure top level command with before
eos_config:
lines: hostname foo
after: snmp-server contact bar
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- "'snmp-server contact bar' in result.updates"
- name: configure top level command with before idempotent check
eos_config:
lines: hostname foo
after: snmp-server contact foo
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
eos_config:
lines:
- no snmp-server contact
- hostname veos01
match: none
provider: "{{ cli }}"
- debug: msg="END cli/toplevel_after.yaml"

View File

@@ -0,0 +1,44 @@
---
- debug: msg="START cli/toplevel_before.yaml"
- name: setup
eos_config:
lines:
- snmp-server contact ansible
- hostname veos01
match: none
provider: "{{ cli }}"
- name: configure top level command with before
eos_config:
lines: hostname foo
before: snmp-server contact bar
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- "'snmp-server contact bar' in result.updates"
- name: configure top level command with before idempotent check
eos_config:
lines: hostname foo
before: snmp-server contact foo
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
eos_config:
lines:
- hostname veos01
- no snmp-server contact
match: none
provider: "{{ cli }}"
- debug: msg="END cli/toplevel_before.yaml"