| 1 |
# Test code for the ACI modules |
| 2 |
# Copyright: (c) 2020, Cindy Zhao (@cizhao) <[email protected]> |
| 3 |
|
| 4 |
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
|
| 6 |
- name: Test that we have an ACI APIC host, ACI username and ACI password |
| 7 |
ansible.builtin.fail: |
| 8 |
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' |
| 9 |
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined |
| 10 |
|
| 11 |
# CLEAN ENVIRONMENT |
| 12 |
- name: Set vars |
| 13 |
ansible.builtin.set_fact: |
| 14 |
aci_info: &aci_info |
| 15 |
host: "{{ aci_hostname }}" |
| 16 |
username: "{{ aci_username }}" |
| 17 |
password: "{{ aci_password }}" |
| 18 |
validate_certs: '{{ aci_validate_certs | default(false) }}' |
| 19 |
use_ssl: '{{ aci_use_ssl | default(true) }}' |
| 20 |
use_proxy: '{{ aci_use_proxy | default(true) }}' |
| 21 |
output_level: '{{ aci_output_level | default("info") }}' |
| 22 |
|
| 23 |
- name: Verify Cloud and Non-Cloud Sites in use. |
| 24 |
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml |
| 25 |
|
| 26 |
- name: Execute tasks only for cloud sites |
| 27 |
when: query_cloud.current | length > 0 # This condition will execute only cloud sites |
| 28 |
block: # block specifies execution of tasks within, based on conditions |
| 29 |
- name: Query all zones under us-west-1 |
| 30 |
cisco.aci.aci_cloud_zone: |
| 31 |
<<: *aci_info |
| 32 |
cloud: "{{ cloud_type }}" |
| 33 |
region: "{{ region_2 }}" |
| 34 |
state: query |
| 35 |
register: query_all |
| 36 |
|
| 37 |
- name: Verify query_all |
| 38 |
ansible.builtin.assert: |
| 39 |
that: |
| 40 |
- query_all is not changed |
| 41 |
- query_all.current.0.cloudRegion.attributes.name == "{{region_2}}" |
| 42 |
- query_all.current.0.cloudRegion.children | length >= 1 |
| 43 |
|
| 44 |
- name: Query a specific zone under region us-west-1 |
| 45 |
cisco.aci.aci_cloud_zone: |
| 46 |
<<: *aci_info |
| 47 |
cloud: "{{ cloud_type }}" |
| 48 |
region: "{{ region_2 }}" |
| 49 |
zone: "{{ availability_zone | default(omit) }}" |
| 50 |
state: query |
| 51 |
register: query_zone_1 |
| 52 |
|
| 53 |
- name: Query another specific zone under region us-west-1 |
| 54 |
cisco.aci.aci_cloud_zone: |
| 55 |
<<: *aci_info |
| 56 |
cloud: "{{ cloud_type }}" |
| 57 |
region: "{{ region_2 }}" |
| 58 |
zone: us-west-1b |
| 59 |
state: query |
| 60 |
register: query_zone_2 |
| 61 |
|
| 62 |
- name: Verify query_zone_1 and query_zone_2 |
| 63 |
ansible.builtin.assert: |
| 64 |
that: |
| 65 |
- query_zone_1 is not changed |
| 66 |
- query_zone_2 is not changed |
| 67 |
- query_zone_1.current.0.cloudZone.attributes.name == "{{availability_zone}}" |
| 68 |
- query_zone_1.current.0.cloudZone.attributes.dn == "uni/clouddomp/provp-{{cloud_type}}/region-{{region_2}}/zone-us-west-1a" |
| 69 |
- query_zone_2.current.0.cloudZone.attributes.name == "us-west-1b" |
| 70 |
- query_zone_2.current.0.cloudZone.attributes.dn == "uni/clouddomp/provp-{{cloud_type}}/region-{{region_2}}/zone-us-west-1b" |
| 71 |
when: query_zone_1.current != [] and query_zone_2.current != [] |
| 72 |
|
| 73 |
- name: Query non_existing zone under region us-west-1 |
| 74 |
cisco.aci.aci_cloud_zone: |
| 75 |
<<: *aci_info |
| 76 |
cloud: "{{ cloud_type }}" |
| 77 |
region: "{{ region_2 }}" |
| 78 |
zone: non_existing |
| 79 |
state: query |
| 80 |
register: query_non_existing_zone |
| 81 |
|
| 82 |
- name: Query zone under non_existing region |
| 83 |
cisco.aci.aci_cloud_zone: |
| 84 |
<<: *aci_info |
| 85 |
cloud: "{{ cloud_type }}" |
| 86 |
region: non_existing |
| 87 |
zone: "{{ availability_zone | default(omit) }}" |
| 88 |
state: query |
| 89 |
register: query_non_existing_region |
| 90 |
|
| 91 |
- name: Verify query_non_existing_zone |
| 92 |
ansible.builtin.assert: |
| 93 |
that: |
| 94 |
- query_non_existing_zone is not changed |
| 95 |
- query_non_existing_zone.current == [] |
| 96 |
- query_non_existing_region is not changed |
| 97 |
- query_non_existing_region.current == [] |