-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathoneview_enclosure.yml
447 lines (414 loc) · 14.1 KB
/
oneview_enclosure.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
###
# Copyright (2016-2021) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
---
- hosts: all
vars:
config: "{{ playbook_dir }}/oneview_config.json"
enclosure_name: 0000A66101
variant: Synergy
scope_uris:
- '/rest/scopes/9dd1856d-2490-4013-92a5-c7bf89bd9f0f'
#Required to create a certificate signing request
csr_data:
type: CertificateDtoV2
organization: HPE
organizationalUnit: IT
locality: 'Fort Collins'
state: Colorado
country: US
commonName: 'e10-oa'
bay_number: 1 #Required for C7000
#Required to import a certificate signing request
certificate_data:
type: CertificateDataV2
base64Data: certificate
tasks:
# This play is compatible with C7000 Enclosures
- name: Ensure the Enclosure with hostname '{{ enclosure_hostname }}' is present with name 'Test-Enclosure'
oneview_enclosure:
config: "{{ config }}"
state: present
data:
enclosureGroupUri: '{{ enclosure_group_uri }}'
hostname: '{{ enclosure_hostname }}'
username: '{{ enclosure_username }}'
password: '{{ enclosure_password }}'
name: '{{ enclosure_name }}'
licensingIntent : 'OneView'
rackName: 'Rack-Name'
scopeUris: '{{ scope_uris }}'
when: variant == 'C7000'
delegate_to: localhost
- name: Ensure the Enclosure framelink with ipv6 '{{ enclosure_framelink_ipv6 }}' is present
oneview_enclosure:
config: "{{ config }}"
state: present
data:
hostname: '{{ enclosure_framelink_ipv6 }}'
when: variant == 'Synergy' and enclosure_framelink_ipv6 is defined
delegate_to: localhost
# Waiting for 10 seconds before attempting operations on enclosure
- wait_for: port=22 host="{{ ansible_host }}" delay=10
connection: local
# This play is compatible with C7000 Enclosures
- name: Do nothing with the Enclosure when no changes are provided
oneview_enclosure:
config: "{{ config }}"
state: present
data:
enclosureGroupUri: '{{ enclosure_group_uri }}'
hostname: '{{ enclosure_hostname }}'
username: '{{ enclosure_username }}'
password: '{{ enclosure_password }}'
name: '{{ enclosure_name }}'
licensingIntent : 'OneView'
rackName: 'Rack-Name'
when: variant == 'C7000'
delegate_to: localhost
# Waiting for 10 seconds before attempting operations on enclosure
- wait_for: port=22 host="{{ ansible_host }}" delay=10
connection: local
- name: Update the name of the enclosure to "Test-Enclosure-Renamed"
oneview_enclosure:
config: "{{ config }}"
state: present
validate_etag: False
data:
name: '{{ enclosure_name }}'
newName: 'Test-Enclosure-Renamed'
delegate_to: localhost
# Waiting for 10 seconds before attempting operations on enclosure
- wait_for: port=22 host="{{ ansible_host }}" delay=10
connection: local
- name: Update the name of the rack to "Rack-Renamed" and rename the Enclosure again
oneview_enclosure:
config: "{{ config }}"
state: present
validate_etag: False
data:
name: 'Test-Enclosure-Renamed'
newName: '{{ enclosure_name }}'
rackName: 'Rack-Renamed'
delegate_to: localhost
- name: Reconfigure the enclosure
oneview_enclosure:
config: "{{ config }}"
state: reconfigured
data:
name: '{{ enclosure_name }}'
delegate_to: localhost
- name: Refresh the enclosure along with all of its components
oneview_enclosure:
config: "{{ config }}"
state: refreshed
data:
name: '{{ enclosure_name }}'
refreshState: 'RefreshPending'
delegate_to: localhost
# Waiting for 10 seconds before attempting operations on enclosure
- wait_for: port=22 host="{{ ansible_host }}" delay=10
connection: local
- name: Create certificate signing request for Synergy
oneview_enclosure:
config: "{{ config }}"
state: create_certificate_request
data:
name: '{{ enclosure_name }}'
type: '{{ csr_data.type }}'
organization: '{{ csr_data.organization }}'
organizationalUnit: '{{ csr_data.organizationalUnit }}'
locality: '{{ csr_data.locality }}'
state: '{{ csr_data.state }}'
country: '{{ csr_data.country }}'
commonName: '{{ csr_data.commonName }}'
delegate_to: localhost
when: variant == 'Synergy'
- name: Create certificate signing request for C7000
oneview_enclosure:
config: "{{ config }}"
state: create_certificate_request
data:
name: '{{ enclosure_name }}'
type: '{{ csr_data.type }}'
organization: '{{ csr_data.organization }}'
organizationalUnit: '{{ csr_data.organizationalUnit }}'
locality: '{{ csr_data.locality }}'
state: '{{ csr_data.state }}'
country: '{{ csr_data.country }}'
commonName: '{{ csr_data.commonName }}'
bay_number: '{{ bay_number }}' #Required for C7000
delegate_to: localhost
when: variant == 'C7000'
- name: Get certificate signing request for Synergy
oneview_enclosure:
config: "{{ config }}"
state: get_certificate_request
data:
name: '{{ enclosure_name }}'
delegate_to: localhost
- name: Get certificate signing request for C7000
oneview_enclosure:
config: "{{ config }}"
state: get_certificate_request
data:
name: '{{ enclosure_name }}'
bay_number: '{{ bay_number }}' #Required for C7000
delegate_to: localhost
when: variant == 'C7000'
# Waiting for 10 seconds before attempting operations on enclosure
- wait_for: port=22 host="{{ ansible_host }}" delay=10
connection: local
- name: Import certificate signing request
oneview_enclosure:
config: "{{ config }}"
state: import_certificate_request
data:
name: '{{ enclosure_name }}'
type: '{{ certificate_data.type }}'
base64Data: '{{ certificate_data.base64Data }}'
delegate_to: localhost
ignore_errors: true
# This state is only available for C7000 enclosures
- name: Set the supportDataCollectionState equals to 'PendingCollection' for the enclosure
oneview_enclosure:
config: "{{ config }}"
state: support_data_collection_set
data:
name: '{{ enclosure_name }}'
supportDataCollectionState: 'PendingCollection'
when: variant == 'C7000'
delegate_to: localhost
ignore_errors: yes
register: result
- debug: var=result.msg
when: variant == 'C7000'
# This state is only available on HPE Synergy.
- name: Set the appliance bay power state on
oneview_enclosure:
config: "{{ config }}"
state: appliance_bays_powered_on
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 1
when: variant == 'Synergy'
delegate_to: localhost
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: Set the appliance UID state off
oneview_enclosure:
config: "{{ config }}"
state: uid_off
validate_etag: False
data:
name: '{{ enclosure_name }}'
when: variant == 'Synergy'
delegate_to: localhost
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: Set the appliance UID state on
oneview_enclosure:
config: "{{ config }}"
state: uid_on
validate_etag: False
data:
name: '{{ enclosure_name }}'
when: variant == 'Synergy'
delegate_to: localhost
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: Set the UID for the Synergy Frame Link Module state on
oneview_enclosure:
config: "{{ config }}"
state: manager_bays_uid_on
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 1
when: variant == 'Synergy'
delegate_to: localhost
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: Set the UID for the Synergy Frame Link Module state off
oneview_enclosure:
config: "{{ config }}"
state: manager_bays_uid_off
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 1
when: variant == 'Synergy'
delegate_to: localhost
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: E-Fuse the Synergy Frame Link Module bay 1
oneview_enclosure:
config: "{{ config }}"
state: manager_bays_power_state_e_fuse
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 1
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: Reset the Synergy Frame Link Module bay 2
oneview_enclosure:
config: "{{ config }}"
state: manager_bays_power_state_reset
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 2
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: E-Fuse the appliance bay 1
oneview_enclosure:
config: "{{ config }}"
state: appliance_bays_power_state_e_fuse
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 1
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: E-Fuse the device bay 10
oneview_enclosure:
config: "{{ config }}"
state: device_bays_power_state_e_fuse
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 10
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: Reset the device bay 11
oneview_enclosure:
config: "{{ config }}"
state: device_bays_power_state_reset
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 11
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: E-Fuse the IC bay 3
oneview_enclosure:
config: "{{ config }}"
state: interconnect_bays_power_state_e_fuse
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 3
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: Set the active Synergy Frame Link Module on bay 2
oneview_enclosure:
config: "{{ config }}"
state: manager_bays_role_active
validate_etag : False
data:
name: '{{ enclosure_name }}'
bayNumber: 2
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy.
- name: Release IPv4 address in the device bay 3
oneview_enclosure:
config: "{{ config }}"
state: device_bays_ipv4_removed
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 3
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# This state is only available on HPE Synergy
- name: Release IPv4 address in the interconnect bay 6
oneview_enclosure:
config: "{{ config }}"
state: interconnect_bays_ipv4_removed
validate_etag: False
data:
name: '{{ enclosure_name }}'
bayNumber: 6
when: variant == 'Synergy'
delegate_to: localhost
ignore_errors: true
register: result
- debug: var=result.msg
when: variant == 'Synergy'
# - name: Remove the Enclosure
# oneview_enclosure:
# config: "{{ config }}"
# state: absent
# data:
# name: '{{ enclosure_name }}'
# delegate_to: localhost
# - name: Do nothing when Enclosure is absent
# oneview_enclosure:
# config: "{{ config }}"
# state: absent
# data:
# name: '{{ enclosure_name }}'
# delegate_to: localhost