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
commit e0cc7b3415
489 changed files with 13144 additions and 2 deletions

View file

@ -0,0 +1,3 @@
---
testcase: "*"
test_items: []

View file

@ -0,0 +1,17 @@
---
- 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

View file

@ -0,0 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }

View file

@ -0,0 +1,3 @@
object-group network OG-ANSIBLE-TEMPLATE
description this is a test
network-object host 192.168.99.12

View file

@ -0,0 +1,4 @@
object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
description this is a test
network-object 10.0.0.0 255.255.255.0
network-object 10.1.0.0 255.255.255.0

View file

@ -0,0 +1,53 @@
---
- debug: msg="START cli/backup.yaml"
- name: setup
asa_config:
commands:
- no object-group network OG-ANSIBLE-TEMPLATE
provider: "{{ cli }}"
ignore_errors: yes
- 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
asa_config:
src: basic/config.j2
backup: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "result.updates is 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"
- name: teardown
asa_config:
commands:
- no object-group network OG-ANSIBLE-TEMPLATE
provider: "{{ cli }}"
- debug: msg="END cli/backup.yaml"

View file

@ -0,0 +1,39 @@
---
- debug: msg="START cli/basic.yaml"
- name: setup
asa_config:
commands:
- no object-group network OG-ANSIBLE-TEMPLATE
provider: "{{ cli }}"
ignore_errors: yes
- name: configure device with config
asa_config:
src: basic/config.j2
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "result.updates is defined"
- name: check device with config
asa_config:
src: basic/config.j2
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- "result.updates is not defined"
- name: teardown
asa_config:
commands:
- no object-group network OG-ANSIBLE-TEMPLATE
provider: "{{ cli }}"
- debug: msg="END cli/basic.yaml"

View file

@ -0,0 +1,45 @@
---
- debug: msg="START cli/defaults.yaml"
- name: setup
asa_config:
commands:
- no object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
provider: "{{ cli }}"
ignore_errors: yes
- name: configure device with defaults included
asa_config:
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
register: result
- debug: var=result
- assert:
that:
- "result.changed == true"
- "result.updates is defined"
- name: check device with defaults included
asa_config:
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
register: result
- debug: var=result
- assert:
that:
- "result.changed == false"
- "result.updates is not defined"
- name: teardown
asa_config:
commands:
- no object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
provider: "{{ cli }}"
- debug: msg="END cli/defaults.yaml"

View file

@ -0,0 +1,41 @@
---
- debug: msg="START cli/force.yaml"
- name: setup
asa_config:
commands:
- no object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
provider: "{{ cli }}"
ignore_errors: yes
- name: configure device with config
asa_config:
src: basic/config.j2
provider: "{{ cli }}"
match: none
register: result
- assert:
that:
- "result.changed == true"
- "result.updates is defined"
- name: check device with config
asa_config:
src: basic/config.j2
provider: "{{ cli }}"
match: none
register: result
- assert:
that:
- "result.changed == true"
- "result.updates is defined"
- name: teardown
asa_config:
commands:
- no object-group network OG-ANSIBLE-TEMPLATE-DEFAULT
provider: "{{ cli }}"
- debug: msg="END cli/force.yaml"

View file

@ -0,0 +1,47 @@
---
- debug: msg="START cli/more_system.yaml"
- name: setup
asa_config:
lines:
- "clear configure tunnel-group 1.1.1.1"
provider: "{{ cli }}"
ignore_errors: yes
- name: Prepare tunnel-group
asa_config:
before: tunnel-group 1.1.1.1 type ipsec-l2l
lines:
- "tunnel-group 1.1.1.1 ipsec-attributes"
provider: "{{ cli }}"
- name: Setup tunnel-group
asa_config:
parents: tunnel-group 1.1.1.1 ipsec-attributes
lines:
- "ikev1 pre-shared-key abc123"
passwords: yes
provider: "{{ cli }}"
- name: Test idempotency
asa_config:
parents: tunnel-group 1.1.1.1 ipsec-attributes
lines:
- "ikev1 pre-shared-key abc123"
passwords: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
asa_config:
lines:
- "clear configure tunnel-group 1.1.1.1"
provider: "{{ cli }}"
- debug: msg="END cli/more_system.yaml"

View file

@ -0,0 +1,40 @@
---
- debug: msg="START cli/sublevel.yaml"
- name: setup test
asa_config:
lines:
- 'no object-group network OG-ANSIBLE-SUBLEVEL'
provider: "{{ cli }}"
- name: configure sub level command
asa_config:
lines: ['network-object host 192.168.10.1']
parents: ['object-group network OG-ANSIBLE-SUBLEVEL']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'object-group network OG-ANSIBLE-SUBLEVEL' in result.updates"
- "'network-object host 192.168.10.1' in result.updates"
- name: configure sub level command idempotent check
asa_config:
lines: ['network-object host 192.168.10.1']
parents: ['object-group network OG-ANSIBLE-SUBLEVEL']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
asa_config:
lines:
- 'no object-group network OG-ANSIBLE-SUBLEVEL'
provider: "{{ cli }}"
- debug: msg="END cli/sublevel.yaml"

View file

@ -0,0 +1,64 @@
---
- debug: msg="START cli/sublevel_block.yaml"
- name: setup
asa_command:
commands:
- show run object-group
provider: "{{ cli }}"
register: object_group
- name: setup
asa_config:
lines:
- no object-group network OG-ANSIBLE
match: none
provider: "{{ cli }}"
#when: "'object-group network OG-ANSIBLE\n' in {{ object_group.stdout }}"
- name: configure sub level command using block replace
asa_config:
lines:
- network-object 192.168.10.0 255.255.255.0
- network-object 192.168.20.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
- network-object 192.168.40.0 255.255.255.0
parents: ['object-group network OG-ANSIBLE']
replace: block
after: ['exit']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'object-group network OG-ANSIBLE' in result.updates"
- "'network-object 192.168.10.0 255.255.255.0' in result.updates"
- "'network-object 192.168.20.0 255.255.255.0' in result.updates"
- "'network-object 192.168.30.0 255.255.255.0' in result.updates"
- "'network-object 192.168.40.0 255.255.255.0' in result.updates"
- name: check sub level command using block replace
asa_config:
lines:
- network-object 192.168.10.0 255.255.255.0
- network-object 192.168.20.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
- network-object 192.168.40.0 255.255.255.0
parents: ['object-group network OG-ANSIBLE']
replace: block
after: ['exit']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
asa_config:
lines:
- no object-group network OG-ANSIBLE
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_block.yaml"

View file

@ -0,0 +1,64 @@
---
- debug: msg="START cli/sublevel_exact.yaml"
- name: setup
asa_config:
lines:
- network-object 192.168.10.0 255.255.255.0
- network-object 192.168.20.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
- network-object 192.168.40.0 255.255.255.0
- network-object 192.168.50.0 255.255.255.0
parents: ['object-group network OG-ANSIBLE-EXACT']
before: ['no object-group network OG-ANSIBLE-EXACT']
after: ['exit']
provider: "{{ cli }}"
- name: configure sub level command using exact match
asa_config:
lines:
- network-object 192.168.10.0 255.255.255.0
- network-object 192.168.20.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
- network-object 192.168.40.0 255.255.255.0
parents: ['object-group network OG-ANSIBLE-EXACT']
after: ['exit']
match: exact
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'object-group network OG-ANSIBLE-EXACT' in result.updates"
- "'network-object 192.168.10.0 255.255.255.0' in result.updates"
- "'network-object 192.168.20.0 255.255.255.0' in result.updates"
- "'network-object 192.168.30.0 255.255.255.0' in result.updates"
- "'network-object 192.168.40.0 255.255.255.0' in result.updates"
- "'network-object 192.168.50.0 255.255.255.0' not in result.updates"
- name: check sub level command using exact match
asa_config:
lines:
- network-object 192.168.10.0 255.255.255.0
- network-object 192.168.20.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
- network-object 192.168.40.0 255.255.255.0
- network-object 192.168.50.0 255.255.255.0
parents: ['object-group network OG-ANSIBLE-EXACT']
after: ['exit']
match: exact
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
asa_config:
lines:
- no object-group network OG-ANSIBLE-EXACT
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_exact.yaml"

View file

@ -0,0 +1,61 @@
---
- debug: msg="START cli/sublevel_strict.yaml"
- name: setup
asa_config:
lines:
- network-object 192.168.10.0 255.255.255.0
- network-object 192.168.20.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
- network-object 192.168.40.0 255.255.255.0
- network-object 192.168.50.0 255.255.255.0
parents: ['object-group network OG-ANSIBLE-STRICT']
before: ['no object-group network OG-ANSIBLE-STRICT']
after: ['exit']
provider: "{{ cli }}"
- name: configure sub level command using strict match
asa_config:
lines:
- network-object 192.168.10.0 255.255.255.0
- network-object 192.168.20.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
- network-object 192.168.40.0 255.255.255.0
parents: ['object-group network OG-ANSIBLE-STRICT']
match: strict
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: check sub level command using strict match
asa_config:
lines:
- network-object 192.168.10.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
- network-object 192.168.30.0 255.255.255.0
parents: ['object-group network OG-ANSIBLE-STRICT']
after: ['exit']
match: strict
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == true"
- "'object-group network OG-ANSIBLE-STRICT' in result.updates"
- "'network-object 192.168.10.0 255.255.255.0' not in result.updates"
- "'network-object 192.168.30.0 255.255.255.0' in result.updates"
- "'network-object 192.168.30.0 255.255.255.0' in result.updates"
- "'network-object 192.168.40.0 255.255.255.0' not in result.updates"
- "'network-object 192.168.50.0 255.255.255.0' not in result.updates"
- name: teardown
asa_config:
lines:
- no object-group network OG-ANSIBLE-STRICT
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_strict.yaml"

View file

@ -0,0 +1,35 @@
---
- debug: msg="START cli/toplevel.yaml"
- name: setup
asa_config:
lines: ['hostname firewall']
provider: "{{ cli }}"
- name: configure top level command
asa_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
asa_config:
lines: ['hostname foo']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
asa_config:
lines: ['hostname {{ inventory_hostname }}']
provider: "{{ cli }}"
- debug: msg="END cli/toplevel.yaml"

View file

@ -0,0 +1,42 @@
---
- debug: msg="START cli/toplevel_after.yaml"
- name: setup
asa_config:
lines:
- "snmp-server contact ansible"
- "hostname firewall"
provider: "{{ cli }}"
- name: configure top level command with before
asa_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
asa_config:
lines: ['hostname foo']
after: ['snmp-server contact foo']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
asa_config:
lines:
- "no snmp-server contact"
- "hostname {{ inventory_hostname }}"
provider: "{{ cli }}"
- debug: msg="END cli/toplevel_after.yaml"

View file

@ -0,0 +1,42 @@
---
- debug: msg="START cli/toplevel_before.yaml"
- name: setup
asa_config:
lines:
- "snmp-server contact ansible"
- "hostname firewall"
provider: "{{ cli }}"
- name: configure top level command with before
asa_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
asa_config:
lines: ['hostname foo']
before: ['snmp-server contact foo']
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
- name: teardown
asa_config:
lines:
- "no snmp-server contact"
- "hostname {{ inventory_hostname }}"
provider: "{{ cli }}"
- debug: msg="END cli/toplevel_before.yaml"

View file

@ -0,0 +1,38 @@
---
- debug: msg="START cli/toplevel_nonidempotent.yaml"
- name: setup
asa_config:
backup: true
# lines: ['hostname firewall']
provider: "{{ cli }}"
- name: configure top level command
asa_config:
lines: ['hostname foo']
provider: "{{ cli }}"
match: strict
register: result
- assert:
that:
- "result.changed == true"
- "'hostname foo' in result.updates"
- name: configure top level command idempotent check
asa_config:
lines: ['hostname foo']
provider: "{{ cli }}"
match: strict
register: result
- assert:
that:
- "result.changed == true"
- name: teardown
asa_config:
lines: ['hostname {{ inventory_hostname }}']
provider: "{{ cli }}"
- debug: msg="END cli/toplevel_nonidempotent.yaml"