2017-11-17 15:19:13 +00:00
|
|
|
# Test code for the ACI modules
|
|
|
|
# Copyright 2017, Jacob McGill <jmcgill298
|
|
|
|
|
|
|
|
# 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: ensure tenant exists for tests to kick off
|
|
|
|
aci_tenant: &aci_tenant_present
|
|
|
|
host: "{{ aci_hostname }}"
|
|
|
|
username: "{{ aci_username }}"
|
|
|
|
password: "{{ aci_password }}"
|
2018-01-20 23:38:20 +00:00
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-02-02 23:41:56 +00:00
|
|
|
output_level: debug
|
2017-11-17 15:19:13 +00:00
|
|
|
state: present
|
|
|
|
tenant: anstest
|
|
|
|
register: tenant_present
|
|
|
|
|
|
|
|
- name: create ap - check mode works
|
|
|
|
aci_ap: &aci_ap_present
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
ap: anstest
|
|
|
|
description: Ansible Test
|
|
|
|
check_mode: yes
|
|
|
|
register: ap_present_check_mode
|
|
|
|
|
|
|
|
- name: create ap - creation works
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_present
|
|
|
|
register: ap_present
|
|
|
|
|
|
|
|
- name: create ap - extra for query
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
ap: anstest2
|
|
|
|
|
|
|
|
- name: create ap - idempotency works
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_present
|
|
|
|
register: ap_present_idempotent
|
|
|
|
|
|
|
|
- name: update ap - update works
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_present
|
|
|
|
description: Ansible Test Update
|
|
|
|
register: ap_present_update
|
|
|
|
|
|
|
|
- name: create ap - creation works
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
ignore_errors: yes
|
|
|
|
register: ap_present_missing_param
|
|
|
|
|
|
|
|
- name: present asserts
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- ap_present_check_mode.changed == true
|
|
|
|
- ap_present.changed == true
|
2018-02-02 23:41:56 +00:00
|
|
|
- ap_present.previous == []
|
|
|
|
- ap_present.sent == ap_present_check_mode.sent
|
|
|
|
- 'ap_present.sent == {"fvAp": {"attributes": {"descr": "Ansible Test", "name": "anstest"}}}'
|
2017-11-17 15:19:13 +00:00
|
|
|
- ap_present_idempotent.changed == false
|
2018-02-02 23:41:56 +00:00
|
|
|
- ap_present_idempotent.previous != []
|
|
|
|
- ap_present_idempotent.sent == {}
|
2017-11-17 15:19:13 +00:00
|
|
|
- ap_present_update.changed == true
|
2018-02-02 23:41:56 +00:00
|
|
|
- 'ap_present_update.sent.fvAp.attributes == {"descr": "Ansible Test Update"}'
|
2017-11-17 15:19:13 +00:00
|
|
|
- ap_present_missing_param.failed == true
|
2018-01-20 20:40:55 +00:00
|
|
|
- 'ap_present_missing_param.msg == "state is present but all of the following are missing: ap"'
|
2017-11-17 15:19:13 +00:00
|
|
|
|
|
|
|
- name: get ap - query specific ap
|
|
|
|
aci_ap: &aci_ap_query
|
|
|
|
<<: *aci_ap_present
|
|
|
|
state: query
|
|
|
|
register: query_ap
|
|
|
|
|
|
|
|
- name: get all ap for tenant - query tenant aps
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_query
|
|
|
|
ap: "{{ fakevar | default(omit) }}"
|
|
|
|
register: query_ap_tenant
|
|
|
|
|
|
|
|
- name: get all ap by name - query ap name
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_query
|
|
|
|
tenant: "{{ fakevar | default(omit) }}"
|
|
|
|
register: query_ap_ap
|
|
|
|
|
|
|
|
- name: get all aps - query general
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_query
|
|
|
|
tenant: "{{ fakevar | default(omit) }}"
|
|
|
|
ap: "{{ fakevar | default(omit) }}"
|
|
|
|
register: query_all
|
|
|
|
|
|
|
|
- name: query assertions
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- query_ap.changed == false
|
2018-02-14 22:07:07 +00:00
|
|
|
- query_ap.current | length == 1
|
|
|
|
- 'query_ap.current.0.fvAp.attributes.name == "anstest"'
|
2017-11-17 15:19:13 +00:00
|
|
|
- '"tn-anstest/ap-anstest.json" in query_ap.url'
|
|
|
|
- query_ap_tenant.changed == false
|
2018-02-14 22:07:07 +00:00
|
|
|
- query_ap_tenant.current | length == 1
|
|
|
|
- query_ap_tenant.current.0.fvTenant.children | length == 2
|
2017-11-17 15:19:13 +00:00
|
|
|
- '"rsp-subtree-class=fvAp" in query_ap_tenant.filter_string'
|
|
|
|
- '"tn-anstest.json" in query_ap_tenant.url'
|
|
|
|
- query_ap_ap.changed == false
|
2018-02-14 22:07:07 +00:00
|
|
|
- query_ap_ap.current != []
|
|
|
|
- query_ap_ap.current.0.fvAp is defined
|
2017-11-17 15:19:13 +00:00
|
|
|
- '"query-target-filter=eq(fvAp.name, \"anstest\")" in query_ap_ap.filter_string'
|
|
|
|
- '"class/fvAp.json" in query_ap_ap.url'
|
|
|
|
- query_all.changed == false
|
2018-02-14 22:07:07 +00:00
|
|
|
- query_all.current | length > 1
|
2017-11-17 15:19:13 +00:00
|
|
|
- '"class/fvAp.json" in query_all.url'
|
|
|
|
|
|
|
|
- name: delete ap - check_mode works
|
|
|
|
aci_ap: &aci_ap_absent
|
|
|
|
<<: *aci_ap_present
|
|
|
|
state: absent
|
|
|
|
check_mode: yes
|
|
|
|
register: ap_delete_check_mode
|
|
|
|
|
|
|
|
- name: delete ap - delete works
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_absent
|
|
|
|
register: ap_delete
|
|
|
|
|
|
|
|
- name: delete ap - delete idempotency works
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_absent
|
|
|
|
register: ap_delete_idempotent
|
|
|
|
|
|
|
|
- name: delete ap - missing param error
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_absent
|
|
|
|
tenant: "{{ fakevar | default(omit) }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
register: ap_delete_missing_param
|
|
|
|
|
|
|
|
- name: delete ap remove ap used for query
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_absent
|
|
|
|
ap: anstest2
|
|
|
|
|
|
|
|
- name: absent assertions
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- ap_delete_check_mode.changed == true
|
2018-02-02 23:41:56 +00:00
|
|
|
- ap_delete_check_mode.previous != []
|
2017-11-17 15:19:13 +00:00
|
|
|
- '"tn-anstest/ap-anstest.json" in ap_delete_check_mode.url'
|
|
|
|
- ap_delete.changed == true
|
2018-02-02 23:41:56 +00:00
|
|
|
- ap_delete.previous == ap_delete_check_mode.previous
|
2017-11-17 15:19:13 +00:00
|
|
|
- ap_delete_idempotent.changed == false
|
2018-02-02 23:41:56 +00:00
|
|
|
- ap_delete_idempotent.previous == []
|
2017-11-17 15:19:13 +00:00
|
|
|
- ap_delete_missing_param.failed == true
|
2018-01-20 20:40:55 +00:00
|
|
|
- 'ap_delete_missing_param.msg == "state is absent but all of the following are missing: tenant"'
|
2017-11-17 15:19:13 +00:00
|
|
|
|
|
|
|
- name: delete tenant - cleanup before ending tests
|
|
|
|
aci_tenant:
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
state: absent
|
|
|
|
when: tenant_present.changed == true
|