mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
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:
3
test/integration/targets/asa_acl/defaults/main.yaml
Normal file
3
test/integration/targets/asa_acl/defaults/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
||||
16
test/integration/targets/asa_acl/tasks/cli.yaml
Normal file
16
test/integration/targets/asa_acl/tasks/cli.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
- 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
|
||||
3
test/integration/targets/asa_acl/tasks/main.yaml
Normal file
3
test/integration/targets/asa_acl/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
41
test/integration/targets/asa_acl/tests/cli/basic.yaml
Normal file
41
test/integration/targets/asa_acl/tests/cli/basic.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
- debug: msg="START cli/basic.yaml"
|
||||
|
||||
- name: setup
|
||||
asa_config:
|
||||
commands:
|
||||
- clear configure access-list ACL-BASIC
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Basic ACL
|
||||
asa_acl:
|
||||
provider: "{{ cli }}"
|
||||
lines:
|
||||
- access-list ACL-BASIC extended permit tcp any any eq www
|
||||
- access-list ACL-BASIC extended permit tcp any any eq https
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Basic ACL idempotency
|
||||
asa_acl:
|
||||
provider: "{{ cli }}"
|
||||
lines:
|
||||
- access-list ACL-BASIC extended permit tcp any any eq www
|
||||
- access-list ACL-BASIC extended permit tcp any any eq https
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
asa_config:
|
||||
commands:
|
||||
- clear configure access-list ACL-BASIC
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/basic.yaml"
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
- debug: msg="START cli/full_name_match.yaml"
|
||||
|
||||
- name: setup
|
||||
asa_config:
|
||||
commands:
|
||||
- clear configure access-list ACL-BASIC
|
||||
- clear configure access-list ACL-BASIC2
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Basic ACL
|
||||
asa_acl:
|
||||
provider: "{{ cli }}"
|
||||
lines:
|
||||
- access-list ACL-BASIC2 extended permit tcp any any eq www
|
||||
- access-list ACL-BASIC2 extended permit tcp any any eq https
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Should not match for ACL-BASIC2
|
||||
asa_acl:
|
||||
provider: "{{ cli }}"
|
||||
lines:
|
||||
- access-list ACL-BASIC extended permit tcp any any eq www
|
||||
- access-list ACL-BASIC extended permit tcp any any eq https
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: teardown
|
||||
asa_config:
|
||||
commands:
|
||||
- clear configure access-list ACL-BASIC
|
||||
- clear configure access-list ACL-BASIC2
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/full_name_match.yaml"
|
||||
51
test/integration/targets/asa_acl/tests/cli/insert.yaml
Normal file
51
test/integration/targets/asa_acl/tests/cli/insert.yaml
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
- debug: msg="START cli/insert.yaml"
|
||||
|
||||
- name: setup
|
||||
asa_config:
|
||||
commands:
|
||||
- clear configure access-list ACL-INSERT
|
||||
provider: "{{ cli }}"
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Create ACL
|
||||
asa_acl:
|
||||
provider: "{{ cli }}"
|
||||
lines:
|
||||
- access-list ACL-INSERT extended permit tcp any any eq www
|
||||
- access-list ACL-INSERT extended permit tcp any any eq https
|
||||
register: result
|
||||
|
||||
- name: Insert on first line
|
||||
asa_acl:
|
||||
provider: "{{ cli }}"
|
||||
lines:
|
||||
- access-list ACL-INSERT extended permit tcp any any eq www
|
||||
- access-list ACL-INSERT extended permit tcp any any eq https
|
||||
- access-list ACL-INSERT line 1 extended permit tcp any any eq ssh
|
||||
register: result
|
||||
|
||||
- name: Show ACL
|
||||
asa_command:
|
||||
provider: "{{ cli }}"
|
||||
commands: "show run access-list ACL-INSERT"
|
||||
register: result
|
||||
|
||||
- name: Show me
|
||||
debug:
|
||||
var: result
|
||||
|
||||
- name:
|
||||
assert:
|
||||
that:
|
||||
- result.stdout_lines[0][0].rstrip() == 'access-list ACL-INSERT extended permit tcp any any eq ssh'
|
||||
|
||||
|
||||
|
||||
- name: teardown
|
||||
asa_config:
|
||||
commands:
|
||||
- clear configure access-list ACL-INSERT
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/insert.yaml"
|
||||
3
test/integration/targets/asa_command/defaults/main.yaml
Normal file
3
test/integration/targets/asa_command/defaults/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
||||
17
test/integration/targets/asa_command/tasks/cli.yaml
Normal file
17
test/integration/targets/asa_command/tasks/cli.yaml
Normal 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
|
||||
|
||||
|
||||
3
test/integration/targets/asa_command/tasks/main.yaml
Normal file
3
test/integration/targets/asa_command/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- debug: msg="START cli/bad_operator.yaml"
|
||||
|
||||
- name: test bad operator
|
||||
asa_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces GigabitEthernet 0/0
|
||||
wait_for:
|
||||
- result[0] contains 'Description: Foo'
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END cli/bad_operator.yaml"
|
||||
20
test/integration/targets/asa_command/tests/cli/contains.yaml
Normal file
20
test/integration/targets/asa_command/tests/cli/contains.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- debug: msg="START cli/contains.yaml"
|
||||
|
||||
- name: test contains operator
|
||||
asa_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interface
|
||||
wait_for:
|
||||
- "result[0] contains 'Cisco Adaptive Security Appliance Software Version'"
|
||||
- "result[1] contains 'Hardware'"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- debug: msg="END cli/contains.yaml"
|
||||
30
test/integration/targets/asa_command/tests/cli/invalid.yaml
Normal file
30
test/integration/targets/asa_command/tests/cli/invalid.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
- debug: msg="START cli/invalid.yaml"
|
||||
|
||||
- name: run invalid command
|
||||
asa_command:
|
||||
commands: ['show foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed"
|
||||
|
||||
- name: run commands that include invalid command
|
||||
asa_command:
|
||||
commands:
|
||||
- show version
|
||||
- show foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed"
|
||||
# FIXME bug https://github.com/ansible/ansible-modules-extras/issues/3048
|
||||
ignore_errors: true
|
||||
|
||||
- debug: msg="END cli/invalid.yaml"
|
||||
29
test/integration/targets/asa_command/tests/cli/output.yaml
Normal file
29
test/integration/targets/asa_command/tests/cli/output.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- debug: msg="START cli/output.yaml"
|
||||
|
||||
- name: get output for single command
|
||||
asa_command:
|
||||
commands: ['show version']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- name: get output for multiple commands
|
||||
asa_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interface
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout | length == 2"
|
||||
|
||||
- debug: msg="END cli/output.yaml"
|
||||
19
test/integration/targets/asa_command/tests/cli/timeout.yaml
Normal file
19
test/integration/targets/asa_command/tests/cli/timeout.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
- debug: msg="START cli/timeout.yaml"
|
||||
|
||||
- name: test bad condition
|
||||
asa_command:
|
||||
commands:
|
||||
- show version
|
||||
wait_for:
|
||||
- "result[0] contains bad_value_string"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END cli/timeout.yaml"
|
||||
3
test/integration/targets/asa_config/defaults/main.yaml
Normal file
3
test/integration/targets/asa_config/defaults/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
||||
17
test/integration/targets/asa_config/tasks/cli.yaml
Normal file
17
test/integration/targets/asa_config/tasks/cli.yaml
Normal 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
|
||||
|
||||
|
||||
3
test/integration/targets/asa_config/tasks/main.yaml
Normal file
3
test/integration/targets/asa_config/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
object-group network OG-ANSIBLE-TEMPLATE
|
||||
description this is a test
|
||||
network-object host 192.168.99.12
|
||||
@@ -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
|
||||
53
test/integration/targets/asa_config/tests/cli/backup.yaml
Normal file
53
test/integration/targets/asa_config/tests/cli/backup.yaml
Normal 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"
|
||||
39
test/integration/targets/asa_config/tests/cli/basic.yaml
Normal file
39
test/integration/targets/asa_config/tests/cli/basic.yaml
Normal 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"
|
||||
45
test/integration/targets/asa_config/tests/cli/defaults.yaml
Normal file
45
test/integration/targets/asa_config/tests/cli/defaults.yaml
Normal 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"
|
||||
41
test/integration/targets/asa_config/tests/cli/force.yaml
Normal file
41
test/integration/targets/asa_config/tests/cli/force.yaml
Normal 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"
|
||||
@@ -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"
|
||||
40
test/integration/targets/asa_config/tests/cli/sublevel.yaml
Normal file
40
test/integration/targets/asa_config/tests/cli/sublevel.yaml
Normal 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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
35
test/integration/targets/asa_config/tests/cli/toplevel.yaml
Normal file
35
test/integration/targets/asa_config/tests/cli/toplevel.yaml
Normal 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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
18
test/integration/targets/dellos10_command/tasks/cli.yaml
Normal file
18
test/integration/targets/dellos10_command/tasks/cli.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- 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
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- debug: msg="START cli/bad_operator.yaml"
|
||||
|
||||
- name: test bad operator
|
||||
dellos10_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interface ethernet 1/1/1
|
||||
wait_for:
|
||||
- "result[0] contains 'Description : blah'"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END cli/bad_operator.yaml"
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- debug: msg="START cli/contains.yaml"
|
||||
|
||||
- name: test contains operator
|
||||
dellos10_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interface ethernet 1/1/1
|
||||
wait_for:
|
||||
- "result[0] contains OS10-Premium"
|
||||
- "result[1] contains Ethernet "
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- debug: msg="END cli/contains.yaml"
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- debug: msg="START cli/invalid.yaml"
|
||||
|
||||
- name: run invalid command
|
||||
dellos10_command:
|
||||
commands: ['show foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'Error: Unrecognized command' in result.stdout"
|
||||
|
||||
- name: run commands that include invalid command
|
||||
dellos10_command:
|
||||
commands:
|
||||
- show version
|
||||
- show foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'Error: Unrecognized command' in result.stdout"
|
||||
|
||||
- debug: msg="END cli/invalid.yaml"
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- debug: msg="START cli/output.yaml"
|
||||
|
||||
- name: get output for single command
|
||||
dellos10_command:
|
||||
commands: ['show version']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- name: get output for multiple commands
|
||||
dellos10_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interface Eth 1/1/1
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout | length == 2"
|
||||
|
||||
- debug: msg="END cli/output.yaml"
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
- debug: msg="START cli/timeout.yaml"
|
||||
|
||||
- name: test bad condition
|
||||
dellos10_command:
|
||||
commands:
|
||||
- show version
|
||||
wait_for:
|
||||
- "result[0] contains bad_value_string"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END cli/timeout.yaml"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
17
test/integration/targets/dellos10_config/tasks/cli.yaml
Normal file
17
test/integration/targets/dellos10_config/tasks/cli.yaml
Normal 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
|
||||
|
||||
|
||||
3
test/integration/targets/dellos10_config/tasks/main.yaml
Normal file
3
test/integration/targets/dellos10_config/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel.yaml"
|
||||
|
||||
- name: setup test
|
||||
dellos10_config:
|
||||
lines:
|
||||
- 'no ip access-list test'
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command
|
||||
dellos10_config:
|
||||
lines: ['seq 5 permit ip any any count byte']
|
||||
parents: ['ip access-list test']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list test' in result.updates"
|
||||
- "'seq 5 permit ip any any count byte' in result.updates"
|
||||
|
||||
- name: configure sub level command idempotent check
|
||||
dellos10_config:
|
||||
lines: ['seq 5 permit ip any any count byte']
|
||||
parents: ['ip access-list test']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos10_config:
|
||||
lines:
|
||||
- 'no ip access-list test'
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel.yaml"
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_block.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
parents: ['ip access-list test']
|
||||
before: ['no ip access-list test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using block resplace
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
- seq 20 permit ip host 4.4.4.4 any count byte
|
||||
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"
|
||||
- "'seq 5 permit ip host 1.1.1.1 any count byte' in result.updates"
|
||||
- "'seq 10 permit ip host 2.2.2.2 any count byte' in result.updates"
|
||||
- "'seq 15 permit ip host 3.3.3.3 any count byte' in result.updates"
|
||||
- "'seq 20 permit ip host 4.4.4.4 any count byte' in result.updates"
|
||||
|
||||
- name: check sub level command using block replace
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
- seq 20 permit ip host 4.4.4.4 any count byte
|
||||
parents: ['ip access-list test']
|
||||
replace: block
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos10_config:
|
||||
lines:
|
||||
- no ip access-list test
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/sublevel_block.yaml"
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_exact.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
- seq 20 permit ip host 4.4.4.4 any count byte
|
||||
- seq 25 permit ip host 5.5.5.5 any count byte
|
||||
parents: ['ip access-list test']
|
||||
before: ['no ip access-list test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using exact match
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
- seq 20 permit ip host 4.4.4.4 any count byte
|
||||
parents: ['ip access-list test']
|
||||
after: ['exit']
|
||||
match: exact
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list test' in result.updates"
|
||||
- "'seq 5 permit ip host 1.1.1.1 any count byte' in result.updates"
|
||||
- "'seq 10 permit ip host 2.2.2.2 any count byte' in result.updates"
|
||||
- "'seq 15 permit ip host 3.3.3.3 any count byte' in result.updates"
|
||||
- "'seq 20 permit ip host 4.4.4.4 any count byte' in result.updates"
|
||||
- "'seq 25 permit ip host 5.5.5.5 any count byte' not in result.updates"
|
||||
|
||||
- name: check sub level command using exact match
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
- seq 20 permit ip host 4.4.4.4 any count byte
|
||||
- seq 25 permit ip host 5.5.5.5 any count byte
|
||||
parents: ['ip access-list test']
|
||||
after: ['exit']
|
||||
match: exact
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos10_config:
|
||||
lines:
|
||||
- no ip access-list test
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel_exact.yaml"
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_strict.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
- seq 20 permit ip host 4.4.4.4 any count byte
|
||||
- seq 25 permit ip host 5.5.5.5 any count byte
|
||||
parents: ['ip access-list test']
|
||||
before: ['no ip access-list test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using strict match
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
- seq 20 permit ip host 4.4.4.4 any count byte
|
||||
parents: ['ip access-list test']
|
||||
match: strict
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: check sub level command using strict match
|
||||
dellos10_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any count byte
|
||||
- seq 15 permit ip host 3.3.3.3 any count byte
|
||||
- seq 10 permit ip host 2.2.2.2 any count byte
|
||||
parents: ['ip access-list test']
|
||||
after: ['exit']
|
||||
match: strict
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list test' in result.updates"
|
||||
- "'seq 5 permit ip host 1.1.1.1 any count byte' not in result.updates"
|
||||
- "'seq 10 permit ip host 2.2.2.2 any count byte' in result.updates"
|
||||
- "'seq 15 permit ip host 3.3.3.3 any count byte' in result.updates"
|
||||
- "'seq 20 permit ip host 4.4.4.4 any count byte' not in result.updates"
|
||||
- "'seq 25 permit ip host 5.5.5.5 any count byte' not in result.updates"
|
||||
|
||||
- name: teardown
|
||||
dellos10_config:
|
||||
lines:
|
||||
- no ip access-list test
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel_strict.yaml"
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos10_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command
|
||||
dellos10_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
|
||||
dellos10_config:
|
||||
lines: ['hostname foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos10_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel.yaml"
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_after.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos10_config:
|
||||
lines:
|
||||
- "snmp-server contact ansible"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command with before
|
||||
dellos10_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
|
||||
dellos10_config:
|
||||
lines: ['hostname foo']
|
||||
after: ['snmp-server contact foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos10_config:
|
||||
lines:
|
||||
- "no snmp-server contact"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_after.yaml"
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_before.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos10_config:
|
||||
lines:
|
||||
- "snmp-server contact ansible"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command with before
|
||||
dellos10_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
|
||||
dellos10_config:
|
||||
lines: ['hostname foo']
|
||||
before: ['snmp-server contact foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos10_config:
|
||||
lines:
|
||||
- "no snmp-server contact"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_before.yaml"
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_nonidempotent.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos10_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command
|
||||
dellos10_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
|
||||
dellos10_config:
|
||||
lines: ['hostname foo']
|
||||
provider: "{{ cli }}"
|
||||
match: strict
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: teardown
|
||||
dellos10_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_nonidempotent.yaml"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
18
test/integration/targets/dellos10_facts/tasks/cli.yaml
Normal file
18
test/integration/targets/dellos10_facts/tasks/cli.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- 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
|
||||
|
||||
|
||||
3
test/integration/targets/dellos10_facts/tasks/main.yaml
Normal file
3
test/integration/targets/dellos10_facts/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
48
test/integration/targets/dellos10_facts/tests/cli/facts.yaml
Normal file
48
test/integration/targets/dellos10_facts/tests/cli/facts.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
- debug: msg="START cli/facts.yaml"
|
||||
|
||||
- name: test all facts
|
||||
dellos10_facts:
|
||||
gather_subset:
|
||||
- all
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.ansible_facts is defined"
|
||||
- "result.ansible_facts.ansible_net_interfaces is defined"
|
||||
- "result.ansible_facts.ansible_net_memfree_mb is defined"
|
||||
- "result.ansible_facts.ansible_net_model is defined"
|
||||
- "result.ansible_facts.ansible_net_servicetag is defined"
|
||||
- "result.ansible_facts.ansible_net_version is defined"
|
||||
|
||||
- name: test all facts except hardware
|
||||
dellos10_facts:
|
||||
gather_subset:
|
||||
- "!hardware"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.ansible_facts.ansible_net_interfaces is defined"
|
||||
- "result.ansible_facts.ansible_net_memfree_mb is not defined"
|
||||
|
||||
- name: test interface facts
|
||||
dellos10_facts:
|
||||
gather_subset:
|
||||
- interfaces
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.ansible_facts.ansible_net_interfaces is defined"
|
||||
- "result.ansible_facts.ansible_net_memfree_mb is not defined"
|
||||
|
||||
|
||||
- debug: msg="END cli/facts.yaml"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
17
test/integration/targets/dellos6_command/tasks/cli.yaml
Normal file
17
test/integration/targets/dellos6_command/tasks/cli.yaml
Normal 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
|
||||
|
||||
|
||||
3
test/integration/targets/dellos6_command/tasks/main.yaml
Normal file
3
test/integration/targets/dellos6_command/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- debug: msg="START cli/bad_operator.yaml"
|
||||
|
||||
- name: test bad operator
|
||||
dellos6_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces GigabitEthernet 1/0/1
|
||||
wait_for:
|
||||
- "result[0] contains 'Description: Foo'"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END cli/bad_operator.yaml"
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- debug: msg="START cli/contains.yaml"
|
||||
|
||||
- name: test contains operator
|
||||
dellos6_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces GigabitEthernet 1/0/1
|
||||
wait_for:
|
||||
- "result[0] contains 5"
|
||||
- "result[1] contains Access"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- debug: msg="END cli/contains.yaml"
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- debug: msg="START cli/invalid.yaml"
|
||||
|
||||
- name: run invalid command
|
||||
dellos6_command:
|
||||
commands: ['show foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed"
|
||||
|
||||
- name: run commands that include invalid command
|
||||
dellos6_command:
|
||||
commands:
|
||||
- show version
|
||||
- show foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed"
|
||||
|
||||
- debug: msg="END cli/invalid.yaml"
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- debug: msg="START cli/output.yaml"
|
||||
|
||||
- name: get output for single command
|
||||
dellos6_command:
|
||||
commands: ['show version']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- name: get output for multiple commands
|
||||
dellos6_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout | length == 2"
|
||||
|
||||
- debug: msg="END cli/output.yaml"
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
- debug: msg="START cli/timeout.yaml"
|
||||
|
||||
- name: test bad condition
|
||||
dellos6_command:
|
||||
commands:
|
||||
- show version
|
||||
wait_for:
|
||||
- "result[0] contains bad_value_string"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END cli/timeout.yaml"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
17
test/integration/targets/dellos6_config/tasks/cli.yaml
Normal file
17
test/integration/targets/dellos6_config/tasks/cli.yaml
Normal 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
|
||||
|
||||
|
||||
3
test/integration/targets/dellos6_config/tasks/main.yaml
Normal file
3
test/integration/targets/dellos6_config/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel.yaml"
|
||||
|
||||
- name: setup test
|
||||
dellos6_config:
|
||||
lines:
|
||||
- 'no ip access-list test'
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command
|
||||
dellos6_config:
|
||||
lines: ['1000 permit every log']
|
||||
parents: ['ip access-list test']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list test' in result.updates"
|
||||
- "'1000 permit every log' in result.updates"
|
||||
|
||||
- name: configure sub level command idempotent check
|
||||
dellos6_config:
|
||||
lines: ['1000 permit every log']
|
||||
parents: ['ip access-list test']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos6_config:
|
||||
lines:
|
||||
- 'no ip access-list test'
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel.yaml"
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_block.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos6_config:
|
||||
lines:
|
||||
- permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- permit ip 2.2.2.2 0.0.0.0 any log
|
||||
- permit ip 3.3.3.3 0.0.0.0 any log
|
||||
parents: ['ip access-list test']
|
||||
before: ['no ip access-list test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using block resplace
|
||||
dellos6_config:
|
||||
lines:
|
||||
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
|
||||
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
|
||||
- 1030 permit ip 4.4.4.4 0.0.0.0 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"
|
||||
- "'1000 permit ip 1.1.1.1 0.0.0.0 any log' in result.updates"
|
||||
- "'1010 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
|
||||
- "'1020 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
|
||||
- "'1030 permit ip 4.4.4.4 0.0.0.0 any log' in result.updates"
|
||||
|
||||
- name: check sub level command using block replace
|
||||
dellos6_config:
|
||||
lines:
|
||||
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
|
||||
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
|
||||
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
|
||||
parents: ['ip access-list test']
|
||||
replace: block
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos6_config:
|
||||
lines:
|
||||
- no ip access-list test
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/sublevel_block.yaml"
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_exact.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos6_config:
|
||||
lines:
|
||||
- permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- permit ip 2.2.2.2 0.0.0.0 any log
|
||||
- permit ip 3.3.3.3 0.0.0.0 any log
|
||||
- permit ip 4.4.4.4 0.0.0.0 any log
|
||||
- permit ip 5.5.5.5 0.0.0.0 any log
|
||||
parents: ['ip access-list test']
|
||||
before: ['no ip access-list test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using exact match
|
||||
dellos6_config:
|
||||
lines:
|
||||
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
|
||||
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
|
||||
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
|
||||
parents: ['ip access-list test']
|
||||
after: ['exit']
|
||||
match: exact
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list test' in result.updates"
|
||||
- "'1000 permit ip 1.1.1.1 0.0.0.0 any log' in result.updates"
|
||||
- "'1010 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
|
||||
- "'1020 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
|
||||
- "'1030 permit ip 4.4.4.4 0.0.0.0 any log' in result.updates"
|
||||
- "'1040 permit ip 5.5.5.5 0.0.0.0 any log' not in result.updates"
|
||||
|
||||
- name: check sub level command using exact match
|
||||
dellos6_config:
|
||||
lines:
|
||||
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
|
||||
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
|
||||
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
|
||||
- 1040 permit ip 5.5.5.5 0.0.0.0 any log
|
||||
parents: ['ip access-list test']
|
||||
after: ['exit']
|
||||
match: exact
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos6_config:
|
||||
lines:
|
||||
- no ip access-list test
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel_exact.yaml"
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_strict.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos6_config:
|
||||
lines:
|
||||
- permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- permit ip 2.2.2.2 0.0.0.0 any log
|
||||
- permit ip 3.3.3.3 0.0.0.0 any log
|
||||
- permit ip 4.4.4.4 0.0.0.0 any log
|
||||
- permit ip 5.5.5.5 0.0.0.0 any log
|
||||
parents: ['ip access-list test']
|
||||
before: ['no ip access-list test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using strict match
|
||||
dellos6_config:
|
||||
lines:
|
||||
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- 1010 permit ip 2.2.2.2 0.0.0.0 any log
|
||||
- 1020 permit ip 3.3.3.3 0.0.0.0 any log
|
||||
- 1030 permit ip 4.4.4.4 0.0.0.0 any log
|
||||
parents: ['ip access-list test']
|
||||
match: strict
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: check sub level command using strict match
|
||||
dellos6_config:
|
||||
lines:
|
||||
- 1000 permit ip 1.1.1.1 0.0.0.0 any log
|
||||
- 1010 permit ip 3.3.3.3 0.0.0.0 any log
|
||||
- 1020 permit ip 2.2.2.2 0.0.0.0 any log
|
||||
parents: ['ip access-list test']
|
||||
after: ['exit']
|
||||
match: strict
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list test' in result.updates"
|
||||
- "'1000 permit ip 1.1.1.1 0.0.0.0 any log' not in result.updates"
|
||||
- "'1020 permit ip 2.2.2.2 0.0.0.0 any log' in result.updates"
|
||||
- "'1010 permit ip 3.3.3.3 0.0.0.0 any log' in result.updates"
|
||||
- "'1030 permit ip 4.4.4.4 0.0.0.0 any log' not in result.updates"
|
||||
- "'1040 permit ip 5.5.5.5 0.0.0.0 any log' not in result.updates"
|
||||
|
||||
- name: teardown
|
||||
dellos6_config:
|
||||
lines:
|
||||
- no ip access-list test
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel_strict.yaml"
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos6_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command
|
||||
dellos6_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
|
||||
dellos6_config:
|
||||
lines: ['hostname "foo"']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos6_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel.yaml"
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_after.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos6_config:
|
||||
lines:
|
||||
- "snmp-server contact ansible"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command with before
|
||||
dellos6_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
|
||||
dellos6_config:
|
||||
lines: ['hostname "foo"']
|
||||
after: ['snmp-server contact foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos6_config:
|
||||
lines:
|
||||
- "no snmp-server contact"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_after.yaml"
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_before.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos6_config:
|
||||
lines:
|
||||
- "snmp-server contact ansible"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command with before
|
||||
dellos6_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
|
||||
dellos6_config:
|
||||
lines: ['hostname "foo"']
|
||||
before: ['snmp-server contact foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos6_config:
|
||||
lines:
|
||||
- "no snmp-server contact"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_before.yaml"
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_nonidempotent.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos6_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command
|
||||
dellos6_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
|
||||
dellos6_config:
|
||||
lines: ['hostname foo']
|
||||
provider: "{{ cli }}"
|
||||
match: strict
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: teardown
|
||||
dellos6_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_nonidempotent.yaml"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
18
test/integration/targets/dellos6_facts/tasks/cli.yaml
Normal file
18
test/integration/targets/dellos6_facts/tasks/cli.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- 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
|
||||
|
||||
|
||||
3
test/integration/targets/dellos6_facts/tasks/main.yaml
Normal file
3
test/integration/targets/dellos6_facts/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
42
test/integration/targets/dellos6_facts/tests/cli/facts.yaml
Normal file
42
test/integration/targets/dellos6_facts/tests/cli/facts.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
---
|
||||
- debug: msg="START cli/facts.yaml"
|
||||
|
||||
- name: test all facts
|
||||
dellos6_facts:
|
||||
gather_subset:
|
||||
- all
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.ansible_facts is defined"
|
||||
|
||||
- name: test all facts except hardware
|
||||
dellos6_facts:
|
||||
gather_subset:
|
||||
- "!hardware"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.ansible_facts.ansible_net_memfree_mb is not defined"
|
||||
|
||||
- name: test interface facts
|
||||
dellos6_facts:
|
||||
gather_subset:
|
||||
- interfaces
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.ansible_facts.ansible_net_interfaces is defined"
|
||||
- "result.ansible_facts.ansible_net_memfree_mb is not defined"
|
||||
|
||||
|
||||
- debug: msg="END cli/facts.yaml"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
18
test/integration/targets/dellos9_command/tasks/cli.yaml
Normal file
18
test/integration/targets/dellos9_command/tasks/cli.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- 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
|
||||
|
||||
|
||||
3
test/integration/targets/dellos9_command/tasks/main.yaml
Normal file
3
test/integration/targets/dellos9_command/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- debug: msg="START cli/bad_operator.yaml"
|
||||
|
||||
- name: test bad operator
|
||||
dellos9_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces TenGigabitEthernet 0/0
|
||||
wait_for:
|
||||
- "result[0] contains 'Description : blah'"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END cli/bad_operator.yaml"
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- debug: msg="START cli/contains.yaml"
|
||||
|
||||
- name: test contains operator
|
||||
dellos9_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interface TenGigabitEthernet 0/0
|
||||
wait_for:
|
||||
- "result[0] contains 2.0"
|
||||
- "result[1] contains TenGigabitEthernet "
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- debug: msg="END cli/contains.yaml"
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- debug: msg="START cli/invalid.yaml"
|
||||
|
||||
- name: run invalid command
|
||||
dellos9_command:
|
||||
commands: ['show foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed"
|
||||
|
||||
- name: run commands that include invalid command
|
||||
dellos9_command:
|
||||
commands:
|
||||
- show version
|
||||
- show foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed"
|
||||
|
||||
- debug: msg="END cli/invalid.yaml"
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- debug: msg="START cli/output.yaml"
|
||||
|
||||
- name: get output for single command
|
||||
dellos9_command:
|
||||
commands: ['show version']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- name: get output for multiple commands
|
||||
dellos9_command:
|
||||
commands:
|
||||
- show version
|
||||
- show interfaces
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
- "result.stdout | length == 2"
|
||||
|
||||
- debug: msg="END cli/output.yaml"
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
- debug: msg="START cli/timeout.yaml"
|
||||
|
||||
- name: test bad condition
|
||||
dellos9_command:
|
||||
commands:
|
||||
- show version
|
||||
wait_for:
|
||||
- "result[0] contains bad_value_string"
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg is defined"
|
||||
|
||||
- debug: msg="END cli/timeout.yaml"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
17
test/integration/targets/dellos9_config/tasks/cli.yaml
Normal file
17
test/integration/targets/dellos9_config/tasks/cli.yaml
Normal 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
|
||||
|
||||
|
||||
3
test/integration/targets/dellos9_config/tasks/main.yaml
Normal file
3
test/integration/targets/dellos9_config/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel.yaml"
|
||||
|
||||
- name: setup test
|
||||
dellos9_config:
|
||||
lines:
|
||||
- 'no ip access-list extended test'
|
||||
- 'no ip access-list standard test'
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command
|
||||
dellos9_config:
|
||||
lines: ['seq 5 permit ip any any log threshold-in-msgs 10 interval 5']
|
||||
parents: ['ip access-list extended test']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list extended test' in result.updates"
|
||||
- "'seq 5 permit ip any any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
|
||||
- name: configure sub level command idempotent check
|
||||
dellos9_config:
|
||||
lines: ['seq 5 permit ip any any log threshold-in-msgs 10 interval 5']
|
||||
parents: ['ip access-list extended test']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos9_config:
|
||||
lines:
|
||||
- 'no ip access-list extended test'
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel.yaml"
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_block.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
before: ['no ip access-list extended test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using block replace
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
- seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
replace: block
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list extended test' in result.updates"
|
||||
- "'seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
|
||||
- name: check sub level command using block replace
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
- seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
replace: block
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos9_config:
|
||||
lines:
|
||||
- no ip access-list extended test
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- debug: msg="END cli/sublevel_block.yaml"
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_exact.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
- seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
|
||||
- seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
before: ['no ip access-list extended test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using exact match
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
- seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
after: ['exit']
|
||||
match: exact
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list extended test' in result.updates"
|
||||
- "'seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5' not in result.updates"
|
||||
|
||||
- name: check sub level command using exact match
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
- seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
|
||||
- seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
after: ['exit']
|
||||
match: exact
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos9_config:
|
||||
lines:
|
||||
- no ip access-list extended test
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel_exact.yaml"
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- debug: msg="START cli/sublevel_strict.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
- seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
|
||||
- seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
before: ['no ip access-list extended test']
|
||||
after: ['exit']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure sub level command using strict match
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
- seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
match: strict
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: check sub level command using strict match
|
||||
dellos9_config:
|
||||
lines:
|
||||
- seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5
|
||||
- seq 10 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5
|
||||
- seq 15 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5
|
||||
parents: ['ip access-list extended test']
|
||||
after: ['exit']
|
||||
match: strict
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'ip access-list extended test' in result.updates"
|
||||
- "'seq 5 permit ip host 1.1.1.1 any log threshold-in-msgs 10 interval 5' not in result.updates"
|
||||
- "'seq 15 permit ip host 2.2.2.2 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 10 permit ip host 3.3.3.3 any log threshold-in-msgs 10 interval 5' in result.updates"
|
||||
- "'seq 20 permit ip host 4.4.4.4 any log threshold-in-msgs 10 interval 5' not in result.updates"
|
||||
- "'seq 25 permit ip host 5.5.5.5 any log threshold-in-msgs 10 interval 5' not in result.updates"
|
||||
|
||||
- name: teardown
|
||||
dellos9_config:
|
||||
lines:
|
||||
- no ip access-list extended test
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/sublevel_strict.yaml"
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos9_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command
|
||||
dellos9_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
|
||||
dellos9_config:
|
||||
lines: ['hostname foo']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos9_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel.yaml"
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_after.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos9_config:
|
||||
lines:
|
||||
- "snmp-server contact ansible"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command with after
|
||||
dellos9_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 after idempotent check
|
||||
dellos9_config:
|
||||
lines: ['hostname foo']
|
||||
after: ['snmp-server contact bar']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos9_config:
|
||||
lines:
|
||||
- "no snmp-server contact"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_after.yaml"
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_before.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos9_config:
|
||||
lines:
|
||||
- "snmp-server contact ansible"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command with before
|
||||
dellos9_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
|
||||
dellos9_config:
|
||||
lines: ['hostname foo']
|
||||
before: ['snmp-server contact bar']
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
dellos9_config:
|
||||
lines:
|
||||
- "no snmp-server contact"
|
||||
- "hostname {{ inventory_hostname }}"
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_before.yaml"
|
||||
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- debug: msg="START cli/toplevel_nonidempotent.yaml"
|
||||
|
||||
- name: setup
|
||||
dellos9_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command
|
||||
dellos9_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
|
||||
dellos9_config:
|
||||
lines: ['hostname foo']
|
||||
provider: "{{ cli }}"
|
||||
match: strict
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: teardown
|
||||
dellos9_config:
|
||||
lines: ['hostname {{ inventory_hostname }}']
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/toplevel_nonidempotent.yaml"
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
testcase: "*"
|
||||
18
test/integration/targets/dellos9_facts/tasks/cli.yaml
Normal file
18
test/integration/targets/dellos9_facts/tasks/cli.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- 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
|
||||
|
||||
|
||||
3
test/integration/targets/dellos9_facts/tasks/main.yaml
Normal file
3
test/integration/targets/dellos9_facts/tasks/main.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user