Debian Codegraph @

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

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2022, Sabari Jaganathan (@sajagana)
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 # SET VARS
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: Query system information
24 cisco.aci.aci_system:
25 <<: *aci_info
26 id: 1
27 state: query
28 register: version
29
30 - name: Ensure anstest_sec_domain does not exists
31 cisco.aci.aci_aaa_domain: &sec_domain_absent
32 <<: *aci_info
33 name: anstest_sec_domain
34 description: "Anstest Sec Domain Descr"
35 state: absent
36
37 - name: Add anstest_sec_domain security domain with check mode
38 cisco.aci.aci_aaa_domain: &cm_sec_domain_present
39 <<: *sec_domain_absent
40 state: present
41 check_mode: true
42 register: cm_sec_domain_present
43
44 - name: Assertions check for add anstest_sec_domain security domain with check mode
45 ansible.builtin.assert:
46 that:
47 - cm_sec_domain_present is changed
48 - cm_sec_domain_present.current | length == 0
49 - cm_sec_domain_present.previous | length == 0
50 - cm_sec_domain_present.sent.aaaDomain.attributes.name == 'anstest_sec_domain'
51
52 - name: Add anstest_sec_domain security domain with normal mode
53 cisco.aci.aci_aaa_domain: &nm_sec_domain_present
54 <<: *cm_sec_domain_present
55 register: nm_sec_domain_present
56
57 - name: Assertions check for add anstest_sec_domain security domain with normal mode
58 ansible.builtin.assert:
59 that:
60 - nm_sec_domain_present is changed
61 - nm_sec_domain_present.current | length == 1
62 - nm_sec_domain_present.previous | length == 0
63 - nm_sec_domain_present.current.0.aaaDomain.attributes.name == 'anstest_sec_domain'
64
65 - name: Assertions check for nm_sec_domain_present in v5.0+
66 ansible.builtin.assert:
67 that:
68 - nm_sec_domain_present.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
69 when: version.current.0.topSystem.attributes.version is version('5', '>=')
70
71 - name: Add anstest_sec_domain security domain with normal mode - idempotency works
72 cisco.aci.aci_aaa_domain:
73 <<: *nm_sec_domain_present
74 register: idempotency_sec_domain_present
75
76 - name: Idempotency assertions check for add anstest_sec_domain security domain with normal mode
77 ansible.builtin.assert:
78 that:
79 - idempotency_sec_domain_present is not changed
80 - idempotency_sec_domain_present.current | length == 1
81 - idempotency_sec_domain_present.previous | length == 1
82 - idempotency_sec_domain_present.current.0.aaaDomain.attributes.name == 'anstest_sec_domain'
83 - idempotency_sec_domain_present.previous.0.aaaDomain.attributes.name == 'anstest_sec_domain'
84
85 - name: Assertions check for idempotency_sec_domain_present in v5.0+
86 ansible.builtin.assert:
87 that:
88 - idempotency_sec_domain_present.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
89 - idempotency_sec_domain_present.previous.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
90 when: version.current.0.topSystem.attributes.version is version('5', '>=')
91
92 - name: Execute tasks only for ACI v5+
93 when: version.current.0.topSystem.attributes.version is version('5', '>=')
94 block: # block specifies execution of tasks within, based on conditions
95 - name: Update anstest_sec_domain security domain restricted_rbac_domain state to true
96 cisco.aci.aci_aaa_domain:
97 <<: *nm_sec_domain_present
98 restricted_rbac_domain: true
99 register: update_sec_domain_present_true
100
101 - name: Assertions check for update anstest_sec_domain security domain restricted_rbac_domain state to true
102 ansible.builtin.assert:
103 that:
104 - update_sec_domain_present_true is changed
105 - update_sec_domain_present_true.current | length == 1
106 - update_sec_domain_present_true.previous | length == 1
107 - update_sec_domain_present_true.current.0.aaaDomain.attributes.name == 'anstest_sec_domain'
108 - update_sec_domain_present_true.current.0.aaaDomain.attributes.restrictedRbacDomain == 'yes'
109 - update_sec_domain_present_true.sent.aaaDomain.attributes.restrictedRbacDomain == 'yes'
110 - update_sec_domain_present_true.previous.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
111
112 - name: Update anstest_sec_domain security domain restricted_rbac_domain state to false
113 cisco.aci.aci_aaa_domain:
114 <<: *nm_sec_domain_present
115 restricted_rbac_domain: false
116 register: update_sec_domain_present_false
117
118 - name: Assertions check for update anstest_sec_domain security domain restricted_rbac_domain state to false
119 ansible.builtin.assert:
120 that:
121 - update_sec_domain_present_false is changed
122 - update_sec_domain_present_false.current | length == 1
123 - update_sec_domain_present_false.previous | length == 1
124 - update_sec_domain_present_false.current.0.aaaDomain.attributes.name == 'anstest_sec_domain'
125 - update_sec_domain_present_false.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
126 - update_sec_domain_present_false.sent.aaaDomain.attributes.restrictedRbacDomain == 'no'
127 - update_sec_domain_present_false.previous.0.aaaDomain.attributes.restrictedRbacDomain == 'yes'
128
129 - name: Query a security domain with name
130 cisco.aci.aci_aaa_domain:
131 <<: *aci_info
132 name: anstest_sec_domain
133 state: query
134 register: query_sec_domain_with_name
135
136 - name: Assertions check for query a security domain with name
137 ansible.builtin.assert:
138 that:
139 - query_sec_domain_with_name is not changed
140 - query_sec_domain_with_name.current | length == 1
141 - query_sec_domain_with_name.current.0.aaaDomain.attributes.name == 'anstest_sec_domain'
142 - query_sec_domain_with_name.current.0.aaaDomain.attributes.descr == 'Anstest Sec Domain Descr'
143
144 - name: Assertions check for query_sec_domain_with_name in v5.0+
145 ansible.builtin.assert:
146 that:
147 - query_sec_domain_with_name.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
148 when: version.current.0.topSystem.attributes.version is version('5', '>=')
149
150 - name: Query all security domains
151 cisco.aci.aci_aaa_domain:
152 <<: *aci_info
153 state: query
154 register: query_all_sec_domains
155
156 - name: Assertions check for query all security domains
157 ansible.builtin.assert:
158 that:
159 - query_all_sec_domains is not changed
160 - query_all_sec_domains.current | length >= 1
161
162 - name: Remove anstest_sec_domain security domain with check mode
163 cisco.aci.aci_aaa_domain: &cm_sec_domain_absent
164 <<: *nm_sec_domain_present
165 state: absent
166 check_mode: true
167 register: cm_sec_domain_absent
168
169 - name: Assertions check for remove anstest_sec_domain security domain with check mode
170 ansible.builtin.assert:
171 that:
172 - cm_sec_domain_absent is changed
173 - cm_sec_domain_absent.current | length == 1
174 - cm_sec_domain_absent.previous | length == 1
175 - cm_sec_domain_absent.current.0.aaaDomain.attributes.name == 'anstest_sec_domain'
176 - cm_sec_domain_absent.previous.0.aaaDomain.attributes.name == 'anstest_sec_domain'
177
178 - name: Assertions check for cm_sec_domain_absent in v5.0+
179 ansible.builtin.assert:
180 that:
181 - cm_sec_domain_absent.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
182 - cm_sec_domain_absent.previous.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
183 when: version.current.0.topSystem.attributes.version is version('5', '>=')
184
185 - name: Remove anstest_sec_domain security domain with normal mode
186 cisco.aci.aci_aaa_domain: &nm_sec_domain_absent
187 <<: *cm_sec_domain_absent
188 register: nm_sec_domain_absent
189
190 - name: Assertions check for remove anstest_sec_domain security domain with normal mode
191 ansible.builtin.assert:
192 that:
193 - nm_sec_domain_absent is changed
194 - nm_sec_domain_absent.current | length == 0
195 - nm_sec_domain_absent.previous | length == 1
196 - nm_sec_domain_absent.previous.0.aaaDomain.attributes.name == 'anstest_sec_domain'
197
198 - name: Assertions check for nm_sec_domain_absent in v5.0+
199 ansible.builtin.assert:
200 that:
201 - nm_sec_domain_absent.previous.0.aaaDomain.attributes.restrictedRbacDomain == 'no'
202 when: version.current.0.topSystem.attributes.version is version('5', '>=')
203
204 - name: Remove anstest_sec_domain security domain with normal mode - idempotency works
205 cisco.aci.aci_aaa_domain:
206 <<: *nm_sec_domain_absent
207 register: idempotency_sec_domain_absent
208
209 - name: Idempotency assertions check for remove anstest_sec_domain security domain with normal mode
210 ansible.builtin.assert:
211 that:
212 - idempotency_sec_domain_absent is not changed
213 - idempotency_sec_domain_absent.current | length == 0
214 - idempotency_sec_domain_absent.previous | length == 0
215
216 - name: Query a removed security domain with name
217 cisco.aci.aci_aaa_domain:
218 <<: *aci_info
219 name: anstest_sec_domain
220 state: query
221 register: removed_sec_domain_with_name
222
223 - name: Assertions check for query a removed security domain with name
224 ansible.builtin.assert:
225 that:
226 - removed_sec_domain_with_name is not changed
227 - removed_sec_domain_with_name.current | length == 0