Debian Codegraph @

ansible_collections/cisco/aci/tests/integration/targets/aci_ap/tasks/main.yml

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2017, Jacob McGill (@jmcgill298)
3 # Copyright: (c) 2020, Shreyas Srish (@shrsr)
4 # Copyright: (c) 2024, Samita Bhattacharjee (@samiib) <[email protected]>
5
6 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
7
8 - name: Test that we have an ACI APIC host, ACI username and ACI password
9 ansible.builtin.fail:
10 msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
11 when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
12
13 - name: Verify Cloud and Non-Cloud Sites in use.
14 ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
15
16 - name: ensure tenant does not exists
17 cisco.aci.aci_tenant: &aci_tenant_absent
18 host: "{{ aci_hostname }}"
19 username: "{{ aci_username }}"
20 password: "{{ aci_password }}"
21 validate_certs: '{{ aci_validate_certs | default(false) }}'
22 use_ssl: '{{ aci_use_ssl | default(true) }}'
23 use_proxy: '{{ aci_use_proxy | default(true) }}'
24 output_level: debug
25 state: absent
26 tenant: ansible_test
27
28 - name: Execute tasks only for non-cloud sites
29 when: query_cloud.current == [] # This condition will execute only non-cloud sites
30 block: # block specifies execution of tasks within, based on conditions
31 - name: ensure tenant exists for tests to kick off
32 cisco.aci.aci_tenant: &aci_tenant_present
33 <<: *aci_tenant_absent
34 state: present
35 register: tenant_present
36
37 - name: ensure monitoring policy exists
38 cisco.aci.aci_epg_monitoring_policy:
39 host: "{{ aci_hostname }}"
40 username: "{{ aci_username }}"
41 password: "{{ aci_password }}"
42 validate_certs: '{{ aci_validate_certs | default(false) }}'
43 use_ssl: '{{ aci_use_ssl | default(true) }}'
44 use_proxy: '{{ aci_use_proxy | default(true) }}'
45 output_level: debug
46 monitoring_policy: check
47 tenant: ansible_test
48
49 - name: ensure ap does not exist initially
50 cisco.aci.aci_ap:
51 <<: *aci_tenant_present
52 ap: anstest
53 state: absent
54
55 - name: create ap - check mode works
56 cisco.aci.aci_ap: &aci_ap_present
57 <<: *aci_tenant_present
58 ap: anstest
59 description: Ansible Test
60 monitoring_policy: check
61 check_mode: true
62 register: ap_present_check_mode
63
64 - name: create ap - creation works
65 cisco.aci.aci_ap:
66 <<: *aci_ap_present
67 register: ap_present
68
69 - name: create ap - extra for query
70 cisco.aci.aci_ap:
71 <<: *aci_tenant_present
72 ap: anstest2
73
74 - name: create ap - idempotency works
75 cisco.aci.aci_ap:
76 <<: *aci_ap_present
77 register: ap_present_idempotent
78
79 - name: update ap - update works
80 cisco.aci.aci_ap:
81 <<: *aci_ap_present
82 description: Ansible Test Update
83 register: ap_present_update
84
85 - name: create ap - creation works
86 cisco.aci.aci_ap:
87 <<: *aci_tenant_present
88 ignore_errors: true
89 register: ap_present_missing_param
90
91 - name: present asserts
92 ansible.builtin.assert:
93 that:
94 - ap_present_check_mode is changed
95 - ap_present is changed
96 - ap_present.previous == []
97 - ap_present.current.0.fvAp.children.0.fvRsApMonPol.attributes.tnMonEPGPolName == 'check'
98 - ap_present.current.0.fvAp.attributes.annotation == 'orchestrator:ansible'
99 - ap_present.sent == ap_present_check_mode.sent
100 - ap_present.sent.fvAp.attributes.descr == 'Ansible Test'
101 - ap_present.sent.fvAp.attributes.name == 'anstest'
102 - ap_present_idempotent is not changed
103 - ap_present_idempotent.previous != []
104 - ap_present_idempotent.sent == {}
105 - ap_present_update is changed
106 - ap_present_update.sent.fvAp.attributes.descr == 'Ansible Test Update'
107 - ap_present_missing_param is failed
108 - 'ap_present_missing_param.msg == "state is present but all of the following are missing: ap"'
109
110 # TEST NO VERIFICATION
111 - name: create ap with no verification (check mode)
112 cisco.aci.aci_ap: &aci_ap_no_verify
113 <<: *aci_ap_present
114 ap: anstest-no-verify
115 no_verification: true
116 check_mode: true
117 register: ap_present_no_verify_cm
118
119 - name: create ap with no verification
120 cisco.aci.aci_ap:
121 <<: *aci_ap_no_verify
122 register: ap_present_no_verify
123
124 - name: create ap with no verification again
125 cisco.aci.aci_ap:
126 <<: *aci_ap_no_verify
127 register: ap_present_no_verify_again
128
129 - name: update ap with no verification
130 cisco.aci.aci_ap:
131 <<: *aci_ap_no_verify
132 description: Ansible Test No Verify
133 register: update_ap_present_no_verify
134
135 - name: delete ap with no verification
136 cisco.aci.aci_ap:
137 <<: *aci_ap_no_verify
138 state: absent
139 register: delete_ap_present_no_verify
140
141 - name: delete ap with no verification again
142 cisco.aci.aci_ap:
143 <<: *aci_ap_no_verify
144 state: absent
145 register: delete_ap_present_no_verify_again
146
147 - name: no verification asserts
148 ansible.builtin.assert:
149 that:
150 - ap_present_no_verify_cm is changed
151 - ap_present_no_verify_cm.current_verified == false
152 - ap_present_no_verify_cm.current.0 == ap_present_no_verify_cm.proposed
153 - ap_present_no_verify is changed
154 - ap_present_no_verify.current_verified == false
155 - ap_present_no_verify.current.0 == ap_present_no_verify.proposed
156 - ap_present_no_verify.previous == []
157 - ap_present_no_verify_again is not changed
158 - ap_present_no_verify_again.current_verified == true
159 - ap_present_no_verify_again.current.0.fvAp.attributes.name == "anstest-no-verify"
160 - ap_present_no_verify_again.current.0.fvAp.attributes.descr == "Ansible Test"
161 - ap_present_no_verify_again.previous.0.fvAp.attributes.name == "anstest-no-verify"
162 - ap_present_no_verify_again.previous.0.fvAp.attributes.descr == "Ansible Test"
163 - update_ap_present_no_verify is changed
164 - update_ap_present_no_verify.current_verified == false
165 - update_ap_present_no_verify.current.0 == update_ap_present_no_verify.proposed
166 - update_ap_present_no_verify.previous.0.fvAp.attributes.name == "anstest-no-verify"
167 - update_ap_present_no_verify.previous.0.fvAp.attributes.descr == "Ansible Test"
168 - delete_ap_present_no_verify is changed
169 - delete_ap_present_no_verify.current_verified == false
170 - delete_ap_present_no_verify.current.0 == delete_ap_present_no_verify.proposed
171 - delete_ap_present_no_verify.previous.0.fvAp.attributes.name == "anstest-no-verify"
172 - delete_ap_present_no_verify.previous.0.fvAp.attributes.descr == "Ansible Test No Verify"
173 - delete_ap_present_no_verify_again is not changed
174 - delete_ap_present_no_verify_again.current_verified == true
175 - delete_ap_present_no_verify_again.current == []
176 - delete_ap_present_no_verify_again.previous == []
177 - delete_ap_present_no_verify_again.proposed == {}
178
179 - name: get ap - query specific ap
180 cisco.aci.aci_ap: &aci_ap_query
181 <<: *aci_ap_present
182 state: query
183 register: query_ap
184
185 - name: get all ap for tenant - query tenant aps
186 cisco.aci.aci_ap:
187 <<: *aci_ap_query
188 ap: "{{ fakevar | default(omit) }}"
189 register: query_ap_tenant
190
191 - name: get all ap by name - query ap name
192 cisco.aci.aci_ap:
193 <<: *aci_ap_query
194 tenant: "{{ fakevar | default(omit) }}"
195 register: query_ap_ap
196
197 - name: get all aps - query general
198 cisco.aci.aci_ap:
199 <<: *aci_ap_query
200 tenant: "{{ fakevar | default(omit) }}"
201 ap: "{{ fakevar | default(omit) }}"
202 register: query_all
203
204 - name: query assertions
205 ansible.builtin.assert:
206 that:
207 - query_ap is not changed
208 - query_ap.current | length == 1
209 - query_ap.current.0.fvAp.attributes.name == "anstest"
210 - query_ap.current.0.fvAp.children.0.fvRsApMonPol.attributes.tnMonEPGPolName == 'check'
211 - '"tn-ansible_test/ap-anstest.json" in query_ap.url'
212 - query_ap_tenant is not changed
213 - query_ap_tenant.current | length == 1
214 - query_ap_tenant.current.0.fvTenant.children | length == 2
215 - '"rsp-subtree-class=fvAp" in query_ap_tenant.filter_string'
216 - '"tn-ansible_test.json" in query_ap_tenant.url'
217 - query_ap_ap is not changed
218 - query_ap_ap.current != []
219 - query_ap_ap.current.0.fvAp is defined
220 - '"query-target-filter=eq(fvAp.name,\"anstest\")" in query_ap_ap.filter_string'
221 - '"class/fvAp.json" in query_ap_ap.url'
222 - query_all is not changed
223 - query_all.current | length > 1
224 - '"class/fvAp.json" in query_all.url'
225
226 - name: delete ap - check_mode works
227 cisco.aci.aci_ap: &aci_ap_absent
228 <<: *aci_ap_present
229 state: absent
230 check_mode: true
231 register: ap_delete_check_mode
232
233 - name: delete ap - delete works
234 cisco.aci.aci_ap:
235 <<: *aci_ap_absent
236 register: ap_delete
237
238 - name: delete ap - delete idempotency works
239 cisco.aci.aci_ap:
240 <<: *aci_ap_absent
241 register: ap_delete_idempotent
242
243 - name: delete ap - missing param error
244 cisco.aci.aci_ap:
245 <<: *aci_ap_absent
246 tenant: "{{ fakevar | default(omit) }}"
247 ignore_errors: true
248 register: ap_delete_missing_param
249
250 - name: delete ap remove ap used for query
251 cisco.aci.aci_ap:
252 <<: *aci_ap_absent
253 ap: anstest2
254
255 - name: absent assertions
256 ansible.builtin.assert:
257 that:
258 - ap_delete_check_mode is changed
259 - ap_delete_check_mode.previous != []
260 - '"tn-ansible_test/ap-anstest.json" in ap_delete_check_mode.url'
261 - ap_delete is changed
262 - ap_delete.previous == ap_delete_check_mode.previous
263 - ap_delete_idempotent is not changed
264 - ap_delete_idempotent.previous == []
265 - ap_delete_missing_param is failed
266 - 'ap_delete_missing_param.msg == "state is absent but all of the following are missing: tenant"'
267
268 - name: delete tenant - cleanup before ending tests
269 cisco.aci.aci_tenant:
270 <<: *aci_tenant_present
271 state: absent
272 when: tenant_present is changed