mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
5.0 KiB
YAML
142 lines
5.0 KiB
YAML
# Test code for the ACI modules
|
|
# Copyright 2017, Dag Wieers <dag@wieers.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
- name: Test that we have an ACI APIC host, ACI username and ACI password
|
|
fail:
|
|
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
|
|
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
|
|
|
|
- name: create a snapshot - creation works
|
|
aci_config_snapshot: &create_snapshot
|
|
host: "{{ aci_hostname }}"
|
|
username: "{{ aci_username }}"
|
|
password: "{{ aci_password }}"
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
|
export_policy: anstest
|
|
max_count: 10
|
|
include_secure: no
|
|
format: json
|
|
description: ansible test
|
|
register: create
|
|
|
|
- name: update snapshot to include secure and use xml - update works
|
|
aci_config_snapshot:
|
|
<<: *create_snapshot
|
|
include_secure: "yes"
|
|
format: xml
|
|
register: create_update
|
|
|
|
- name: create a snapshot invalid max_count - error message
|
|
aci_config_snapshot:
|
|
<<: *create_snapshot
|
|
max_count: 11
|
|
ignore_errors: yes
|
|
register: invalid_max_count
|
|
|
|
- name: create a snapshot invalid max_count - error message
|
|
aci_config_snapshot:
|
|
<<: *create_snapshot
|
|
export_policy: "{{ fake_var | default(omit) }}"
|
|
ignore_errors: yes
|
|
register: missing_param
|
|
|
|
- name: present assertion tests
|
|
assert:
|
|
that:
|
|
- create.failed == false
|
|
- create.changed == true
|
|
- 'create.config.configExportP.attributes.adminSt == "triggered"'
|
|
- create_update.failed == false
|
|
- create_update.changed == true
|
|
- 'create_update.config == {"configExportP": {"attributes": {"adminSt": "triggered", "format": "xml", "includeSecureFields": "yes"}}}'
|
|
- invalid_max_count.failed == true
|
|
- 'invalid_max_count.msg == "The \"max_count\" must be a number between 1 and 10"'
|
|
- missing_param.failed == true
|
|
- 'missing_param.msg == "state is present but all of the following are missing: export_policy"'
|
|
|
|
- name: query with export_policy
|
|
aci_config_snapshot: &query_snapshot
|
|
<<: *create_snapshot
|
|
state: query
|
|
register: query_export
|
|
|
|
- name: generate snapshot name
|
|
set_fact:
|
|
test_snapshot: "{{ query_export.existing.0.configSnapshotCont.children.0.configSnapshot.attributes.rn.strip('snapshot-') }}"
|
|
|
|
- name: query with export_policy and snapshot
|
|
aci_config_snapshot: &query_both
|
|
<<: *query_snapshot
|
|
snapshot: "{{ test_snapshot }}"
|
|
register: query_export_snapshot
|
|
|
|
- name: query with snapshot - module add run- to snapshot
|
|
aci_config_snapshot:
|
|
<<: *query_snapshot
|
|
export_policy: "{{ fake_var | default(omit) }}"
|
|
snapshot: "{{ test_snapshot.strip('run-') }}"
|
|
register: query_snapshot
|
|
|
|
- name: query no params
|
|
aci_config_snapshot:
|
|
<<: *query_snapshot
|
|
export_policy: "{{ fake_var | default(omit) }}"
|
|
register: query_all
|
|
|
|
- name: query assertion tests
|
|
assert:
|
|
that:
|
|
- query_export.failed == false
|
|
- query_export.changed == false
|
|
- '"snapshots-[uni/fabric/configexp-anstest].json" in query_export.url'
|
|
- 'query_export.existing.0.configSnapshotCont.attributes.name == "anstest"'
|
|
- query_export.existing.0.configSnapshotCont.children | length > 1
|
|
- query_export_snapshot.failed == false
|
|
- query_export_snapshot.changed == false
|
|
- '"snapshots-[uni/fabric/configexp-anstest]/snapshot-{{ test_snapshot }}.json" in query_export_snapshot.url'
|
|
- query_export_snapshot.existing | length == 1
|
|
- query_snapshot.failed == false
|
|
- query_snapshot.changed == false
|
|
- '"class/configSnapshot.json" in query_snapshot.url'
|
|
- '"configSnapshot.name, \"{{ test_snapshot }}\"" in query_snapshot.filter_string'
|
|
- query_all.failed == false
|
|
- query_all.changed == false
|
|
- '"class/configSnapshot.json" in query_all.url'
|
|
- query_all.existing | length > 1
|
|
|
|
- name: delete works
|
|
aci_config_snapshot: &delete
|
|
<<: *query_both
|
|
state: absent
|
|
register: delete_snapshot
|
|
|
|
- name: delete works - idempotency
|
|
aci_config_snapshot:
|
|
<<: *delete
|
|
register: delete_idempotent
|
|
|
|
- name: delete missing param
|
|
aci_config_snapshot:
|
|
<<: *delete
|
|
snapshot: "{{ fake_var | default(omit) }}"
|
|
ignore_errors: yes
|
|
register: delete_missing_param
|
|
|
|
- name: absent assertion tests
|
|
assert:
|
|
that:
|
|
- delete_snapshot.failed == false
|
|
- delete_snapshot.changed == true
|
|
- 'delete_snapshot.config == {"configSnapshot": {"attributes": {"retire": "yes"}}}'
|
|
- delete_snapshot.existing != []
|
|
- delete_snapshot.existing.0.configSnapshot.attributes.name == test_snapshot
|
|
- delete_idempotent.failed == false
|
|
- delete_idempotent.changed == false
|
|
- delete_idempotent.existing == []
|
|
- delete_missing_param.failed == true
|
|
- 'delete_missing_param.msg == "state is absent but all of the following are missing: snapshot"'
|