| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 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 |
- name: ensure tenant exists for tests to kick off |
| 12 |
cisco.aci.aci_tenant: &aci_tenant_present |
| 13 |
host: "{{ aci_hostname }}" |
| 14 |
username: "{{ aci_username }}" |
| 15 |
password: "{{ aci_password }}" |
| 16 |
validate_certs: '{{ aci_validate_certs | default(false) }}' |
| 17 |
use_ssl: '{{ aci_use_ssl | default(true) }}' |
| 18 |
use_proxy: '{{ aci_use_proxy | default(true) }}' |
| 19 |
output_level: debug |
| 20 |
state: present |
| 21 |
tenant: ansible_test |
| 22 |
register: tenant_present |
| 23 |
|
| 24 |
- name: Verify Cloud and Non-Cloud Sites in use. |
| 25 |
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml |
| 26 |
|
| 27 |
- name: Execute tasks only for cloud sites |
| 28 |
when: query_cloud.current | length > 0 |
| 29 |
block: |
| 30 |
- name: ensure cloud ap does not exist initially |
| 31 |
cisco.aci.aci_cloud_ap: |
| 32 |
<<: *aci_tenant_present |
| 33 |
name: '{{ item }}' |
| 34 |
state: absent |
| 35 |
loop: |
| 36 |
- anstest |
| 37 |
- anstest2 |
| 38 |
|
| 39 |
- name: create cloud ap - check mode |
| 40 |
cisco.aci.aci_cloud_ap: &aci_cloud_ap_present |
| 41 |
<<: *aci_tenant_present |
| 42 |
name: anstest |
| 43 |
description: Ansible Test Cloud APIC |
| 44 |
state: present |
| 45 |
check_mode: true |
| 46 |
register: cm_create_cloud_ap |
| 47 |
|
| 48 |
- name: create cloud ap - normal mode |
| 49 |
cisco.aci.aci_cloud_ap: |
| 50 |
<<: *aci_cloud_ap_present |
| 51 |
register: nm_create_cloud_ap |
| 52 |
|
| 53 |
- name: create cloud ap again - idempotency works |
| 54 |
cisco.aci.aci_cloud_ap: |
| 55 |
<<: *aci_cloud_ap_present |
| 56 |
register: create_cloud_ap_again |
| 57 |
|
| 58 |
- name: create another ap - extra for query |
| 59 |
cisco.aci.aci_cloud_ap: |
| 60 |
<<: *aci_cloud_ap_present |
| 61 |
name: anstest2 |
| 62 |
register: extra_cloud_ap |
| 63 |
|
| 64 |
- name: update cloud ap |
| 65 |
cisco.aci.aci_cloud_ap: |
| 66 |
<<: *aci_cloud_ap_present |
| 67 |
description: Update Ansible Test Update |
| 68 |
register: update_cloud_ap |
| 69 |
|
| 70 |
- name: verify cloud ap creation |
| 71 |
ansible.builtin.assert: |
| 72 |
that: |
| 73 |
- cm_create_cloud_ap is changed |
| 74 |
- nm_create_cloud_ap is changed |
| 75 |
- cm_create_cloud_ap.previous == nm_create_cloud_ap.previous == [] |
| 76 |
- cm_create_cloud_ap.proposed.cloudApp.attributes.name == 'anstest' |
| 77 |
- cm_create_cloud_ap.proposed.cloudApp.attributes.descr == 'Ansible Test Cloud APIC' |
| 78 |
- nm_create_cloud_ap.current.0.cloudApp.attributes.annotation == 'orchestrator:ansible' |
| 79 |
- nm_create_cloud_ap.current.0.cloudApp.attributes.name == 'anstest' |
| 80 |
- nm_create_cloud_ap.current.0.cloudApp.attributes.descr == 'Ansible Test Cloud APIC' |
| 81 |
- create_cloud_ap_again is not changed |
| 82 |
- extra_cloud_ap is changed |
| 83 |
- extra_cloud_ap.previous == [] |
| 84 |
- extra_cloud_ap.current.0.cloudApp.attributes.name == 'anstest2' |
| 85 |
- extra_cloud_ap.current.0.cloudApp.attributes.descr == 'Ansible Test Cloud APIC' |
| 86 |
- update_cloud_ap is changed |
| 87 |
- update_cloud_ap.previous.0.cloudApp.attributes.name == 'anstest' |
| 88 |
- update_cloud_ap.previous.0.cloudApp.attributes.descr == 'Ansible Test Cloud APIC' |
| 89 |
- update_cloud_ap.current.0.cloudApp.attributes.name == 'anstest' |
| 90 |
- update_cloud_ap.current.0.cloudApp.attributes.descr == 'Update Ansible Test Update' |
| 91 |
|
| 92 |
- name: query all cloud ap for tenant - query tenant aps |
| 93 |
cisco.aci.aci_cloud_ap: &aci_cloud_ap_query |
| 94 |
<<: *aci_cloud_ap_present |
| 95 |
name: "{{ fakevar | default(omit) }}" |
| 96 |
state: query |
| 97 |
register: query_all_tenant |
| 98 |
|
| 99 |
- name: query all cloud ap by name |
| 100 |
cisco.aci.aci_cloud_ap: |
| 101 |
<<: *aci_cloud_ap_query |
| 102 |
tenant: "{{ fakevar | default(omit) }}" |
| 103 |
name: anstest |
| 104 |
register: query_all_ap |
| 105 |
|
| 106 |
- name: query all cloud ap - query general |
| 107 |
cisco.aci.aci_cloud_ap: |
| 108 |
<<: *aci_cloud_ap_query |
| 109 |
tenant: "{{ fakevar | default(omit) }}" |
| 110 |
name: "{{ fakevar | default(omit) }}" |
| 111 |
register: query_all |
| 112 |
|
| 113 |
- name: query specific cloud ap |
| 114 |
cisco.aci.aci_cloud_ap: |
| 115 |
<<: *aci_cloud_ap_present |
| 116 |
tenant: ansible_test |
| 117 |
name: anstest |
| 118 |
state: query |
| 119 |
register: query_cloud_ap |
| 120 |
|
| 121 |
- name: verify query |
| 122 |
ansible.builtin.assert: |
| 123 |
that: |
| 124 |
- query_all_tenant is not changed |
| 125 |
- query_all_tenant.current.0.fvTenant.children | length >= 2 |
| 126 |
- query_all_ap is not changed |
| 127 |
- query_all_ap.current.0.cloudApp.attributes.name == 'anstest' |
| 128 |
- query_all_ap.current.0.cloudApp.attributes.descr == 'Update Ansible Test Update' |
| 129 |
- query_all is not changed |
| 130 |
- query_all.current | length >= 2 |
| 131 |
- query_cloud_ap is not changed |
| 132 |
- query_cloud_ap.current.0.cloudApp.attributes.name == 'anstest' |
| 133 |
- query_cloud_ap.current.0.cloudApp.attributes.descr == 'Update Ansible Test Update' |
| 134 |
- query_cloud_ap.current.0.cloudApp.attributes.dn == 'uni/tn-ansible_test/cloudapp-anstest' |
| 135 |
|
| 136 |
- name: delete cloud ap |
| 137 |
cisco.aci.aci_cloud_ap: |
| 138 |
<<: *aci_tenant_present |
| 139 |
name: anstest |
| 140 |
state: absent |
| 141 |
register: rm_cloud_ap |
| 142 |
|
| 143 |
- name: delete cloud ap again |
| 144 |
cisco.aci.aci_cloud_ap: |
| 145 |
<<: *aci_tenant_present |
| 146 |
name: anstest |
| 147 |
state: absent |
| 148 |
register: rm_cloud_ap_again |
| 149 |
|
| 150 |
- name: verify deletion |
| 151 |
ansible.builtin.assert: |
| 152 |
that: |
| 153 |
- rm_cloud_ap is changed |
| 154 |
- rm_cloud_ap.previous.0.cloudApp.attributes.name == 'anstest' |
| 155 |
- rm_cloud_ap.current == [] |
| 156 |
- rm_cloud_ap_again is not changed |
| 157 |
- rm_cloud_ap_again.previous == rm_cloud_ap_again.current == [] |