Debian Codegraph @

ansible_collections/cisco/mso/tests/integration/targets/mso_schema_validate/tasks/main.yml

raw
1 # Test code for the MSO modules
2 # Copyright: (c) 2021, Anvitha Jain (@anvitha-jain) <[email protected]>
3 #
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 MultiSite host, username and password
8 ansible.builtin.fail:
9 msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.'
10 when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined
11
12 # CLEAN ENVIRONMENT
13 - name: Set vars
14 ansible.builtin.set_fact:
15 mso_info: &mso_info
16 host: '{{ mso_hostname }}'
17 username: '{{ mso_username }}'
18 password: '{{ mso_password }}'
19 validate_certs: '{{ mso_validate_certs | default(false) }}'
20 use_ssl: '{{ mso_use_ssl | default(true) }}'
21 use_proxy: '{{ mso_use_proxy | default(true) }}'
22 output_level: '{{ mso_output_level | default("debug") }}'
23
24 - name: Query MSO version
25 cisco.mso.mso_version:
26 <<: *mso_info
27 state: query
28 register: version
29
30 - name: Ensure site exist
31 cisco.mso.mso_site:
32 <<: *mso_info
33 site: '{{ mso_site | default("ansible_test") }}'
34 apic_username: '{{ apic_username }}'
35 apic_password: '{{ apic_password }}'
36 apic_site_id: '{{ apic_site_id | default(101) }}'
37 urls:
38 - https://{{ apic_hostname }}
39 state: present
40
41 - name: Remove schemas
42 cisco.mso.mso_schema:
43 <<: *mso_info
44 schema: '{{ item }}'
45 state: absent
46 loop:
47 - '{{ mso_schema | default("ansible_test") }}_2'
48 - '{{ mso_schema | default("ansible_test") }}'
49
50 - name: Ensure tenant ansible_test exists
51 cisco.mso.mso_tenant:
52 <<: *mso_info
53 tenant: ansible_test
54 users:
55 - '{{ mso_username }}'
56 sites:
57 - '{{ mso_site | default("ansible_test") }}'
58 state: present
59
60 # Validate schema when MSO version >= 3.3
61 - name: Execute tasks only for MSO version >= 3.3
62 when: version.current.version is version('3.3', '>=')
63 block:
64 - name: Ensure schema 1 with Template 1 exist
65 cisco.mso.mso_schema_template:
66 <<: *mso_info
67 schema: '{{ mso_schema | default("ansible_test") }}'
68 tenant: ansible_test
69 template: Template 1
70 state: present
71
72 - name: Ensure VRF exist
73 cisco.mso.mso_schema_template_vrf:
74 <<: *mso_info
75 schema: '{{ mso_schema | default("ansible_test") }}'
76 template: Template 1
77 vrf: VRF_1
78 state: present
79
80 - name: Add bd
81 cisco.mso.mso_schema_template_bd:
82 <<: *mso_info
83 schema: '{{ mso_schema | default("ansible_test") }}'
84 template: Template1
85 bd: BD_1
86 vrf:
87 name: VRF_1
88 state: present
89
90 - name: Get Validation status
91 cisco.mso.mso_schema_validate:
92 <<: *mso_info
93 schema: ansible_test
94 state: query
95 register: query_validate
96
97 - name: Verify query_validate for NDO 4.1 and higher
98 ansible.builtin.assert:
99 that:
100 - query_validate is not changed
101 - query_validate.current.result == true
102 when: version.current.version is version('4.0', '>=')
103
104 - name: Verify query_validate
105 ansible.builtin.assert:
106 that:
107 - query_validate is not changed
108 - query_validate.current.result == "true"
109 when: version.current.version is version('4.0', '<')
110
111 - name: Add physical site to a schema
112 cisco.mso.mso_schema_site:
113 <<: *mso_info
114 schema: '{{ mso_schema | default("ansible_test") }}'
115 site: '{{ mso_site | default("ansible_test") }}'
116 template: Template 1
117 state: present
118
119 - name: Get Validation status
120 cisco.mso.mso_schema_validate:
121 <<: *mso_info
122 schema: ansible_test
123 state: query
124 register: query_validate_again
125
126 - name: Verify query_validate_again for NDO 4.1 and higher
127 ansible.builtin.assert:
128 that:
129 - query_validate_again is not changed
130 - query_validate_again.current.result == true
131 when: version.current.version is version('4.0', '>=')
132
133 - name: Verify query_validate_again for NDO 3.7 and lower
134 ansible.builtin.assert:
135 that:
136 - query_validate_again is not changed
137 - query_validate_again.current.result == "true"
138 when: version.current.version is version('4.0', '<')
139
140 - name: Deploy templates for NDO 3.7 and lower (normal_mode)
141 cisco.mso.mso_schema_template_deploy:
142 <<: *mso_info
143 schema: ansible_test
144 template: Template 1
145 site: '{{ mso_site | default("ansible_test") }}'
146 state: deploy
147 register: nm_deploy_template_37
148 when: version.current.version is version('4.0', '<')
149
150 - name: Deploy templates for NDO 4.1 and higher (normal_mode)
151 cisco.mso.ndo_schema_template_deploy:
152 <<: *mso_info
153 schema: ansible_test
154 template: Template 1
155 sites:
156 - '{{ mso_site | default("ansible_test") }}'
157 state: deploy
158 register: nm_deploy_template_40
159 when: version.current.version is version('4.0', '>=')
160
161 - name: Verify nm_deploy_template for NDO 3.7 and lower
162 ansible.builtin.assert:
163 that:
164 - nm_deploy_template_37 is not changed
165 - nm_deploy_template_37.msg == "Successfully deployed"
166 when: version.current.version is version('4.0', '<')
167
168 - name: Verify nm_deploy_template for NDO 4.1 and higher
169 ansible.builtin.assert:
170 that:
171 - '"deploy" in nm_deploy_template_40.current.reqDetails'
172 when: version.current.version is version('4.0', '>=')
173
174 - name: Ensure schema 2 with Template 2 exist
175 cisco.mso.mso_schema_template:
176 <<: *mso_info
177 schema: '{{ mso_schema | default("ansible_test") }}_2'
178 tenant: ansible_test
179 template: Template 2
180 state: present
181
182 - name: Ensure VRF exist
183 cisco.mso.mso_schema_template_vrf:
184 <<: *mso_info
185 schema: '{{ mso_schema | default("ansible_test") }}_2'
186 template: Template 2
187 vrf: VRF_2
188 layer3_multicast: true
189 vzany: true
190 state: present
191
192 - name: Get Validation status
193 cisco.mso.mso_schema_validate:
194 <<: *mso_info
195 schema: ansible_test_2
196 state: query
197 ignore_errors: true
198 register: query_validate_2
199
200 - name: Set error messages for query validation
201 ansible.builtin.set_fact:
202 error_message_query_validate_above_41: "MSO Error 400: VRF: VRF_2 in Schema: ansible_test_2, Template: Template2, has VzAnyEnabled flag enabled but is not consuming or providing contracts"
203 error_message_query_validate_below_40: "MSO Error 400: Bad Request: Patch Failed, Received: vzAny contract must be configured if vzAny flag is set. VRF(s) : VRF_2 exception while trying to update schema"
204
205 - name: Verify query_validate_2 for NDO 4.1 and higher
206 ansible.builtin.assert:
207 that:
208 - query_validate_2 is not changed
209 - query_validate_2.msg == error_message_query_validate_above_41
210 when: version.current.version is version('4.0', '>=')
211
212 - name: Verify query_validate_2 for NDO 3.7 and lower
213 ansible.builtin.assert:
214 that:
215 - query_validate_2 is not changed
216 - query_validate_2.msg == error_message_query_validate_below_40
217 when: version.current.version is version('4.0', '<')
218
219 always:
220 - name: Undeploy template from Schema 1
221 cisco.mso.mso_schema_template_deploy:
222 <<: *mso_info
223 schema: ansible_test
224 template: Template 1
225 site: '{{ mso_site | default("ansible_test") }}'
226 state: undeploy
227 ignore_errors: true
228 when: version.current.version is version('4.0', '<')
229
230 - name: Undeploy template from Schema 1
231 cisco.mso.ndo_schema_template_deploy:
232 <<: *mso_info
233 schema: ansible_test
234 template: Template 1
235 sites:
236 - '{{ mso_site | default("ansible_test") }}'
237 state: undeploy
238 ignore_errors: true