-
Notifications
You must be signed in to change notification settings - Fork 0
/
redfish_storage_volume.yml
131 lines (121 loc) · 3.75 KB
/
redfish_storage_volume.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
---
- hosts: idrac
name: Set the iDRAC manager and system attributes
connection: local
gather_facts: False
vars:
ansible_python_interpreter: python
volume_name: "Virtual Disk 0"
storage_controller: "RAID.Slot.1-1"
drives:
- "Disk.Bay.0:Enclosure.Internal.0-1:RAID.Slot.1-1"
- "Disk.Bay.1:Enclosure.Internal.0-1:RAID.Slot.1-1"
optimum_io_size_bytes: 65536
volume_type: "Mirrored"
tasks:
- name: Get storage controller details
uri:
url: "https://{{inventory_hostname}}/redfish/v1/Systems/System.Embedded.1/Storage/{{ storage_controller }}"
user: "{{ idrac_user }}"
password: "{{ idrac_password }}"
method: GET
headers:
accept: "application/json"
force_basic_auth: no
validate_certs: no
register: result
tags:
- storage
- name: Get the drives associated with the storage controller
set_fact:
associated_drives: "{{ associated_drives | default({}) | combine( {item['@odata.id'].split('/')[-1]: item['@odata.id']} ) }}"
loop: "{{ result.json.Drives }}"
when: result.json['[email protected]'] > 0
tags:
- storage
- name: Assert if no drives are available
assert:
that:
- result.json['[email protected]'] > 0
- drives is defined
- drives != None
- drives | length > 0
tags:
- storage
- name: Assert if the drives are not associated with storage controller
assert:
that:
- item in associated_drives.keys()
loop: "{{ drives }}"
tags:
- storage
- name: Create drives payload
set_fact:
drives_payload: "{{ drives_payload|default([]) + [ item[1] ] }}"
loop: "{{ drives | product(result.json.Drives) | list }}"
when: item[1]['@odata.id'].split('/')[-1] == item[0]
tags:
- storage
- name: Assert if drives payload is not defined
assert:
that:
- drives_payload is defined
tags:
- storage
- name: Submit a POST operation to create the virtual disk
uri:
url: "https://{{inventory_hostname}}/redfish/v1/Systems/System.Embedded.1/Storage/{{ storage_controller }}/Volumes"
user: "{{ idrac_user }}"
password: "{{ idrac_password }}"
method: POST
headers:
accept: "application/json"
content-type: "application/json"
body: "{{ create_raid_volume_payload }}"
body_format: "json"
force_basic_auth: no
validate_certs: no
status_code: [200, 202]
vars:
create_raid_volume_payload:
"Name": "{{ volume_name }}"
"VolumeType": "{{ volume_type }}"
"Drives": "{{ drives_payload }}"
"OptimumIOSizeBytes": "{{ optimum_io_size_bytes }}"
register: result
tags:
- storage
- name: Get the JOB details
uri:
url: "{{ result.location }}"
user: "{{ idrac_user }}"
password: "{{ idrac_password }}"
method: GET
headers:
accept: "application/json"
force_basic_auth: no
validate_certs: no
status_code: [200, 202]
register: task
tags:
- storage
- name: If JobType == RealTimeNoRebootConfiguration then loop over the JOB until it completes or fails
uri:
url: "{{ result.location }}"
user: "{{ idrac_user }}"
password: "{{ idrac_password }}"
method: GET
headers:
accept: "application/json"
force_basic_auth: no
validate_certs: no
status_code: [200, 202]
register: result
until: result.json['TaskState'] == 'Completed' or result.json['TaskState'] == 'Failed'
when: task.json['Oem']['Dell']['JobType'] == 'RealTimeNoRebootConfiguration'
retries: 20
delay: 90
changed_when: result.json['TaskState'] == 'Completed'
failed_when: result.json['TaskState'] == 'Failed'
tags:
- storage