| 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: Set vars |
| 12 |
ansible.builtin.set_fact: |
| 13 |
aci_info: &aci_info |
| 14 |
host: "{{ aci_hostname }}" |
| 15 |
username: "{{ aci_username }}" |
| 16 |
password: "{{ aci_password }}" |
| 17 |
validate_certs: '{{ aci_validate_certs | default(false) }}' |
| 18 |
use_ssl: '{{ aci_use_ssl | default(true) }}' |
| 19 |
use_proxy: '{{ aci_use_proxy | default(true) }}' |
| 20 |
output_level: '{{ aci_output_level | default("info") }}' |
| 21 |
|
| 22 |
- name: Verify Cloud and Non-Cloud Sites in use. |
| 23 |
ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml |
| 24 |
|
| 25 |
- name: Execute tasks only for cloud sites |
| 26 |
when: query_cloud.current | length > 0 |
| 27 |
block: |
| 28 |
- name: Ensure tenant doesn't exist |
| 29 |
cisco.aci.aci_tenant: |
| 30 |
<<: *aci_info |
| 31 |
state: absent |
| 32 |
tenant: ansible_test |
| 33 |
register: tenant_absent |
| 34 |
|
| 35 |
- name: Ensure tenant exists |
| 36 |
cisco.aci.aci_tenant: &aci_tenant_present |
| 37 |
<<: *aci_info |
| 38 |
state: present |
| 39 |
tenant: ansible_test |
| 40 |
register: tenant_present |
| 41 |
|
| 42 |
- name: Ensure application profile exists |
| 43 |
cisco.aci.aci_cloud_ap: &aci_cloud_ap_present |
| 44 |
<<: *aci_tenant_present |
| 45 |
name: anstest |
| 46 |
description: Ansible Test Cloud APIC |
| 47 |
state: present |
| 48 |
register: create_cloud_ap |
| 49 |
|
| 50 |
- name: Ensure vrf exist |
| 51 |
cisco.aci.aci_vrf: &aci_vrf_present |
| 52 |
<<: *aci_tenant_present |
| 53 |
vrf: anstest |
| 54 |
description: Ansible Test |
| 55 |
register: vrf_present |
| 56 |
|
| 57 |
- name: Create another vrf |
| 58 |
cisco.aci.aci_vrf: |
| 59 |
<<: *aci_vrf_present |
| 60 |
vrf: anstest_2 |
| 61 |
register: another_vrf_present |
| 62 |
|
| 63 |
- name: Create aci cloud epg (check_mode) |
| 64 |
cisco.aci.aci_cloud_epg: &aci_cloud_epg_present |
| 65 |
<<: *aci_info |
| 66 |
tenant: ansible_test |
| 67 |
ap: anstest |
| 68 |
vrf: anstest |
| 69 |
description: Aci Cloud EPG |
| 70 |
name: anstest |
| 71 |
state: present |
| 72 |
check_mode: true |
| 73 |
register: cm_epg_present |
| 74 |
|
| 75 |
- name: Create aci cloud epg (normal mode) |
| 76 |
cisco.aci.aci_cloud_epg: |
| 77 |
<<: *aci_cloud_epg_present |
| 78 |
register: nm_epg_present |
| 79 |
|
| 80 |
- name: Create aci cloud epg again |
| 81 |
cisco.aci.aci_cloud_epg: |
| 82 |
<<: *aci_cloud_epg_present |
| 83 |
register: nm_epg_present_again |
| 84 |
|
| 85 |
- name: Create another cloud epg |
| 86 |
cisco.aci.aci_cloud_epg: |
| 87 |
<<: *aci_cloud_epg_present |
| 88 |
name: ansible_cloud_epg |
| 89 |
register: nm_another_epg_present |
| 90 |
|
| 91 |
- name: Verify cloud epg creation |
| 92 |
ansible.builtin.assert: |
| 93 |
that: |
| 94 |
- cm_epg_present is changed |
| 95 |
- nm_epg_present is changed |
| 96 |
- nm_epg_present_again is not changed |
| 97 |
- cm_epg_present.previous == nm_epg_present.previous == [] |
| 98 |
- cm_epg_present.proposed.cloudEPg.attributes.name == 'anstest' |
| 99 |
- cm_epg_present.proposed.cloudEPg.attributes.descr == 'Aci Cloud EPG' |
| 100 |
- cm_epg_present.proposed.cloudEPg.attributes.dn == 'uni/tn-ansible_test/cloudapp-anstest/cloudepg-anstest' |
| 101 |
- cm_epg_present.proposed.cloudEPg.children.0.cloudRsCloudEPgCtx.attributes.tnFvCtxName == 'anstest' |
| 102 |
- nm_epg_present.current.0.cloudEPg.attributes.annotation == 'orchestrator:ansible' |
| 103 |
- nm_epg_present.current.0.cloudEPg.attributes.name == 'anstest' |
| 104 |
- nm_epg_present.current.0.cloudEPg.attributes.descr == 'Aci Cloud EPG' |
| 105 |
- nm_epg_present.current.0.cloudEPg.attributes.dn == 'uni/tn-ansible_test/cloudapp-anstest/cloudepg-anstest' |
| 106 |
- nm_epg_present.current.0.cloudEPg.children.0.cloudRsCloudEPgCtx.attributes.tnFvCtxName == 'anstest' |
| 107 |
- nm_epg_present_again.previous == nm_epg_present_again.current |
| 108 |
- nm_another_epg_present is changed |
| 109 |
- nm_another_epg_present.previous == [] |
| 110 |
- nm_another_epg_present.current.0.cloudEPg.attributes.name == 'ansible_cloud_epg' |
| 111 |
|
| 112 |
- name: Update cloud epg with another vrf |
| 113 |
cisco.aci.aci_cloud_epg: |
| 114 |
<<: *aci_cloud_epg_present |
| 115 |
vrf: anstest_2 |
| 116 |
register: update_cloud_epg |
| 117 |
|
| 118 |
- name: Update cloud epg without vrf |
| 119 |
cisco.aci.aci_cloud_epg: |
| 120 |
<<: *aci_cloud_epg_present |
| 121 |
vrf: "{{ fakevar | default(omit) }}" |
| 122 |
register: no_vrf |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
- name: Veirfy update_cloud_epg |
| 132 |
ansible.builtin.assert: |
| 133 |
that: |
| 134 |
- update_cloud_epg is changed |
| 135 |
- update_cloud_epg.current.0.cloudEPg.children.0.cloudRsCloudEPgCtx.attributes.tnFvCtxName == 'anstest_2' |
| 136 |
|
| 137 |
- name: Query specific cloud epg |
| 138 |
cisco.aci.aci_cloud_epg: |
| 139 |
<<: *aci_info |
| 140 |
tenant: ansible_test |
| 141 |
ap: anstest |
| 142 |
name: anstest |
| 143 |
state: query |
| 144 |
register: cloud_epg_query |
| 145 |
|
| 146 |
- name: query all |
| 147 |
cisco.aci.aci_cloud_epg: |
| 148 |
<<: *aci_info |
| 149 |
tenant: ansible_test |
| 150 |
ap: anstest |
| 151 |
state: query |
| 152 |
register: query_all |
| 153 |
|
| 154 |
- name: Verify query |
| 155 |
ansible.builtin.assert: |
| 156 |
that: |
| 157 |
- cloud_epg_query is not changed |
| 158 |
- cloud_epg_query.current.0.cloudEPg.attributes.name == 'anstest' |
| 159 |
- cloud_epg_query.current.0.cloudEPg.attributes.dn == 'uni/tn-ansible_test/cloudapp-anstest/cloudepg-anstest' |
| 160 |
- cloud_epg_query.current.0.cloudEPg.attributes.descr == 'Aci Cloud EPG' |
| 161 |
- cloud_epg_query.current.0.cloudEPg.children.0.cloudRsCloudEPgCtx.attributes.tnFvCtxName == 'anstest_2' |
| 162 |
- cloud_epg_query.current.0.cloudEPg.children.0.cloudRsCloudEPgCtx.attributes.tDn == 'uni/tn-ansible_test/ctx-anstest_2' |
| 163 |
- query_all is not changed |
| 164 |
- query_all.current.0.cloudApp.children | length >= 2 |
| 165 |
|
| 166 |
- name: Remove cloud epg |
| 167 |
cisco.aci.aci_cloud_epg: &cloud_epg_absent |
| 168 |
<<: *aci_info |
| 169 |
tenant: ansible_test |
| 170 |
ap: anstest |
| 171 |
name: anstest |
| 172 |
state: absent |
| 173 |
register: cloud_epg_absent |
| 174 |
|
| 175 |
- name: Remove cloud epg again |
| 176 |
cisco.aci.aci_cloud_epg: |
| 177 |
<<: *cloud_epg_absent |
| 178 |
register: cloud_epg_absent_again |
| 179 |
|
| 180 |
- name: Verify deletion |
| 181 |
ansible.builtin.assert: |
| 182 |
that: |
| 183 |
- cloud_epg_absent is changed |
| 184 |
- cloud_epg_absent.current == [] |
| 185 |
- cloud_epg_absent_again is not changed |