Debian Codegraph @

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

raw
1 # Test code for the ACI modules
2 # Copyright: (c) 2017, Bruno Calogero <[email protected]>
3 # Copyright: (c) 2023, Gaspard Micol <[email protected]>
4
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 - name: Test that we have an ACI APIC host, ACI username and ACI password
8 ansible.builtin.fail:
9 msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
10 when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
11
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 # CLEAN ENVIRONMENT
24 - name: Remove fabric node
25 cisco.aci.aci_fabric_node: &aci_fabric_node_absent
26 <<: *aci_info
27 serial: ansible_test
28 node_id: 105
29 state: absent
30
31 - name: Remove fabric node 2
32 cisco.aci.aci_fabric_node: &aci_fabric_node_absent_2
33 <<: *aci_info
34 serial: ansible_test_2
35 node_id: 106
36 state: absent
37
38 # ADD FABRIC NODE
39 - name: Add fabric node with tier-2 leaf (check_mode)
40 cisco.aci.aci_fabric_node: &aci_fabric_node_present
41 <<: *aci_fabric_node_absent
42 switch: anstest
43 role: leaf
44 node_type: tier_2
45 state: present
46 check_mode: true
47 register: cm_add_fabric_node_tier_2
48
49 - name: Add fabric node with remote leaf
50 cisco.aci.aci_fabric_node: &aci_fabric_node_present_2
51 <<: *aci_fabric_node_absent_2
52 switch: anstest_2
53 role: leaf
54 node_type: remote
55 remote_leaf_pool_id: 2
56 state: present
57 register: nm_add_fabric_node_remote
58
59 - name: Add fabric node (normal mode)
60 cisco.aci.aci_fabric_node: *aci_fabric_node_present
61 register: nm_add_fabric_node
62
63 - name: Add fabric node again (check_mode)
64 cisco.aci.aci_fabric_node: *aci_fabric_node_present
65 check_mode: true
66 register: cm_add_fabric_node_again
67
68 - name: Add fabric node again (normal mode)
69 cisco.aci.aci_fabric_node: *aci_fabric_node_present
70 register: nm_add_fabric_node_again
71
72 - name: test error - mutually exclusive attributes
73 cisco.aci.aci_fabric_node:
74 <<: *aci_fabric_node_present_2
75 node_type: tier_2
76 register: test_error_mutually_exclusive
77 ignore_errors: true
78
79 - name: test error - check failure when changing node type
80 cisco.aci.aci_fabric_node:
81 <<: *aci_fabric_node_present
82 node_type: virtual
83 register: test_error_change__node_type
84 ignore_errors: true
85
86 - name: test error - check failure when changing Pool Id
87 cisco.aci.aci_fabric_node:
88 <<: *aci_fabric_node_present_2
89 remote_leaf_pool_id: 3
90 register: test_error_change_Pool_Id
91 ignore_errors: true
92
93 - name: Verify add_fabric_node
94 ansible.builtin.assert:
95 that:
96 - cm_add_fabric_node_tier_2 is changed
97 - nm_add_fabric_node is changed
98 - nm_add_fabric_node.current.0.fabricNodeIdentP.attributes.annotation == 'orchestrator:ansible'
99 - nm_add_fabric_node.current.0.fabricNodeIdentP.attributes.role == 'leaf'
100 - nm_add_fabric_node.current.0.fabricNodeIdentP.attributes.nodeType == 'tier-2-leaf'
101 - nm_add_fabric_node_remote is changed
102 - nm_add_fabric_node_remote.current.0.fabricNodeIdentP.attributes.nodeType == 'remote-leaf-wan'
103 - nm_add_fabric_node_remote.current.0.fabricNodeIdentP.attributes.extPoolId == '2'
104 # FIXME: Module is not idempotent
105 - cm_add_fabric_node_again is not changed
106 - nm_add_fabric_node_again is not changed
107 - test_error_mutually_exclusive.msg == "External Pool Id is not compatible with a node type other than 'remote'."
108 - test_error_change__node_type.error.text == "Create-only and naming props cannot be modified after creation, class=fabricNodeIdentP, prop=nodeType"
109 - test_error_change_Pool_Id.error.text == "Create-only and naming props cannot be modified after creation, class=fabricNodeIdentP, prop=extPoolId"
110
111
112 # CHANGE FABRIC NODE
113 - name: Change description of fabric node (check_mode)
114 cisco.aci.aci_fabric_node:
115 <<: *aci_fabric_node_present
116 description: Ansible test fabric node
117 check_mode: true
118 register: cm_add_fabric_node_descr
119
120 - name: Change description of fabric node (normal mode)
121 cisco.aci.aci_fabric_node:
122 <<: *aci_fabric_node_present
123 description: Ansible test fabric node
124 register: nm_add_fabric_node_descr
125
126 - name: Change description of fabric nodeagain (check_mode)
127 cisco.aci.aci_fabric_node:
128 <<: *aci_fabric_node_present
129 description: Ansible test fabric node
130 check_mode: true
131 register: cm_add_fabric_node_descr_again
132
133 - name: Change description of fabric node again (normal mode)
134 cisco.aci.aci_fabric_node:
135 <<: *aci_fabric_node_present
136 description: Ansible test fabric node
137 register: nm_add_fabric_node_descr_again
138
139 - name: Verify add_fabric_node_descr
140 ansible.builtin.assert:
141 that:
142 - cm_add_fabric_node_descr is changed
143 - nm_add_fabric_node_descr is changed
144 # FIXME: Module is not idempotent
145 - cm_add_fabric_node_descr_again is not changed
146 - nm_add_fabric_node_descr_again is not changed
147
148
149 # ADD FABRIC NODE AGAIN
150 - name: Add fabric node again with no description (check_mode)
151 cisco.aci.aci_fabric_node: *aci_fabric_node_present
152 check_mode: true
153 register: cm_add_fabric_node_again_no_descr
154
155 - name: Add fabric node again with no description (normal mode)
156 cisco.aci.aci_fabric_node: *aci_fabric_node_present
157 register: nm_add_fabric_node_again_no_descr
158
159 - name: Verify add_fabric_node_again_no_descr
160 ansible.builtin.assert:
161 that:
162 # FIXME: Module is not idempotent
163 - cm_add_fabric_node_again_no_descr is not changed
164 - nm_add_fabric_node_again_no_descr is not changed
165
166
167 # QUERY ALL FABRIC NODES
168 - name: Query fabric nodes (check_mode)
169 cisco.aci.aci_fabric_node: &aci_fabric_node_query
170 host: '{{ aci_hostname }}'
171 username: '{{ aci_username }}'
172 password: '{{ aci_password }}'
173 validate_certs: '{{ aci_validate_certs | default(false) }}'
174 use_ssl: '{{ aci_use_ssl | default(true) }}'
175 use_proxy: '{{ aci_use_proxy | default(true) }}'
176 output_level: '{{ aci_output_level | default("info") }}'
177 state: query
178 check_mode: true
179 register: cm_query_all_fabric_nodes
180
181 - name: Query all fabric nodes (normal mode)
182 cisco.aci.aci_fabric_node: *aci_fabric_node_query
183 register: nm_query_all_fabric_nodes
184
185 - name: Verify query_all_fabric_nodes
186 ansible.builtin.assert:
187 that:
188 - cm_query_all_fabric_nodes is not changed
189 - nm_query_all_fabric_nodes is not changed
190 - cm_query_all_fabric_nodes == nm_query_all_fabric_nodes
191
192
193 # QUERY A FABRIC NODE
194 - name: Query our fabric_node
195 cisco.aci.aci_fabric_node:
196 <<: *aci_fabric_node_query
197 serial: ansible_test
198 check_mode: true
199 register: cm_query_fabric_node
200
201 - name: Query our fabric_node
202 cisco.aci.aci_fabric_node:
203 <<: *aci_fabric_node_query
204 serial: ansible_test
205 register: nm_query_fabric_node
206
207 - name: Verify query_fabric_node
208 ansible.builtin.assert:
209 that:
210 - cm_query_fabric_node is not changed
211 - nm_query_fabric_node is not changed
212 - cm_query_fabric_node == nm_query_fabric_node
213
214
215 # REMOVE FABRIC NODE
216 - name: Remove fabric_node (check_mode)
217 cisco.aci.aci_fabric_node: *aci_fabric_node_absent
218 check_mode: true
219 register: cm_remove_fabric_node
220
221 - name: Remove fabric_node (normal mode)
222 cisco.aci.aci_fabric_node: *aci_fabric_node_absent
223 register: nm_remove_fabric_node
224
225 - name: Remove fabric_node again (check_mode)
226 cisco.aci.aci_fabric_node: *aci_fabric_node_absent
227 check_mode: true
228 register: cm_remove_fabric_node_again
229
230 - name: Remove fabric_node again (normal mode)
231 cisco.aci.aci_fabric_node: *aci_fabric_node_absent
232 register: nm_remove_fabric_node_again
233
234 - name: Verify remove_fabric_node
235 ansible.builtin.assert:
236 that:
237 - cm_remove_fabric_node is changed
238 - nm_remove_fabric_node is changed
239 - cm_remove_fabric_node_again is not changed
240 - nm_remove_fabric_node_again is not changed
241
242
243 # QUERY NON-EXISTING LEAF PROFILE
244 - name: Query non-existing fabric_node (check_mode)
245 cisco.aci.aci_fabric_node:
246 <<: *aci_fabric_node_query
247 serial: ansible_test
248 check_mode: true
249 register: cm_query_non_fabric_node
250
251 - name: Query non-existing fabric_node (normal mode)
252 cisco.aci.aci_fabric_node:
253 <<: *aci_fabric_node_query
254 serial: ansible_test
255 register: nm_query_non_fabric_node
256
257 - name: Verify query_non_fabric_node
258 ansible.builtin.assert:
259 that:
260 - cm_query_non_fabric_node is not changed
261 - nm_query_non_fabric_node is not changed
262 - cm_query_non_fabric_node == nm_query_non_fabric_node