| 1 |
--- |
| 2 |
- name: Setting up hostname with port |
| 3 |
ansible.builtin.set_fact: |
| 4 |
baseuri: "{{ hostname }}:{{ https_port }}" |
| 5 |
|
| 6 |
- name: Setting common options |
| 7 |
ansible.builtin.set_fact: |
| 8 |
idrac_inputs: &idrac_inputs |
| 9 |
baseuri: "{{ baseuri }}" |
| 10 |
username: "{{ username }}" |
| 11 |
password: "{{ password }}" |
| 12 |
validate_certs: "{{ validate_certs }}" |
| 13 |
ca_path: "{{ ca_path | default(omit) }}" |
| 14 |
timeout: "{{ https_timeout }}" |
| 15 |
no_log: true |
| 16 |
|
| 17 |
- name: Storage controller reset configuration. |
| 18 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 19 |
<<: *idrac_inputs |
| 20 |
command: "ResetConfig" |
| 21 |
controller_id: "{{ controller_id }}" |
| 22 |
job_wait: "{{ job_wait }}" |
| 23 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 24 |
register: reset_config_out |
| 25 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 26 |
when: reset_config is defined and reset_config is true |
| 27 |
|
| 28 |
- name: Storage controller attributes configuration. |
| 29 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 30 |
<<: *idrac_inputs |
| 31 |
controller_id: "{{ controller_id }}" |
| 32 |
attributes: "{{ attributes }}" |
| 33 |
apply_time: "{{ apply_time }}" |
| 34 |
maintenance_window: "{{ maintenance_window | default(omit) }}" |
| 35 |
job_wait: "{{ job_wait }}" |
| 36 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 37 |
register: attributes_config_out |
| 38 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 39 |
when: attributes is defined |
| 40 |
|
| 41 |
- name: Storage set controller key configuration. |
| 42 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 43 |
<<: *idrac_inputs |
| 44 |
command: "SetControllerKey" |
| 45 |
controller_id: "{{ controller_id }}" |
| 46 |
key: "{{ key | default(omit) }}" |
| 47 |
key_id: "{{ key_id | default(omit) }}" |
| 48 |
job_wait: "{{ job_wait }}" |
| 49 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 50 |
register: set_controller_key_out |
| 51 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 52 |
when: |
| 53 |
- set_controller_key is defined |
| 54 |
- set_controller_key is true |
| 55 |
- key is defined |
| 56 |
- key_id is defined |
| 57 |
- mode is undefined |
| 58 |
|
| 59 |
- name: Storage remove controller key configuration. |
| 60 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 61 |
<<: *idrac_inputs |
| 62 |
command: "RemoveControllerKey" |
| 63 |
controller_id: "{{ controller_id }}" |
| 64 |
job_wait: "{{ job_wait }}" |
| 65 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 66 |
register: remove_controller_key_out |
| 67 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 68 |
when: remove_key is defined and remove_key is true |
| 69 |
|
| 70 |
- name: Storage controller rekey configuration. |
| 71 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 72 |
<<: *idrac_inputs |
| 73 |
command: "ReKey" |
| 74 |
controller_id: "{{ controller_id }}" |
| 75 |
key: "{{ key | default(omit) }}" |
| 76 |
key_id: "{{ key_id | default(omit) }}" |
| 77 |
old_key: "{{ old_key | default(omit) }}" |
| 78 |
mode: "{{ mode | default(omit) }}" |
| 79 |
job_wait: "{{ job_wait }}" |
| 80 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 81 |
register: storage_controller_rekey |
| 82 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 83 |
when: rekey is defined and rekey is true |
| 84 |
|
| 85 |
- name: Storage enable controller encryption. |
| 86 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 87 |
<<: *idrac_inputs |
| 88 |
command: "EnableControllerEncryption" |
| 89 |
controller_id: "{{ controller_id }}" |
| 90 |
key: "{{ key | default(omit) }}" |
| 91 |
key_id: "{{ key_id | default(omit) }}" |
| 92 |
mode: "{{ mode | default(omit) }}" |
| 93 |
job_wait: "{{ job_wait }}" |
| 94 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 95 |
register: enable_encryption_out |
| 96 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 97 |
when: |
| 98 |
- set_controller_key is defined |
| 99 |
- set_controller_key is true |
| 100 |
- key is defined |
| 101 |
- key_id is defined |
| 102 |
- mode is defined |
| 103 |
|
| 104 |
- name: Performing secure erase on a physical disk. |
| 105 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 106 |
<<: *idrac_inputs |
| 107 |
command: "SecureErase" |
| 108 |
controller_id: "{{ controller_id }}" |
| 109 |
target: "{{ disks.id }}" |
| 110 |
job_wait: "{{ job_wait }}" |
| 111 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 112 |
register: erase_state_out |
| 113 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 114 |
when: disks.erase is defined and disks.erase is true |
| 115 |
|
| 116 |
- name: Change physical disk state. |
| 117 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 118 |
<<: *idrac_inputs |
| 119 |
command: |
| 120 |
"{{ 'ChangePDStateToOnline' if disks.status == 'online' |
| 121 |
else 'ChangePDStateToOffline' }}" |
| 122 |
controller_id: "{{ controller_id }}" |
| 123 |
target: "{{ disks.id }}" |
| 124 |
job_wait: "{{ job_wait }}" |
| 125 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 126 |
register: pd_state_out |
| 127 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 128 |
when: disks.status is defined |
| 129 |
|
| 130 |
- name: Change physical disk raid state. |
| 131 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 132 |
<<: *idrac_inputs |
| 133 |
command: |
| 134 |
"{{ 'ConvertToRAID' if disks.raid_state == 'raid' |
| 135 |
else 'ConvertToNonRAID' }}" |
| 136 |
controller_id: "{{ controller_id }}" |
| 137 |
target: "{{ disks.id }}" |
| 138 |
job_wait: "{{ job_wait }}" |
| 139 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 140 |
register: raid_state_out |
| 141 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 142 |
when: disks.raid_state is defined |
| 143 |
|
| 144 |
- name: Assign dedicated hot spare |
| 145 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 146 |
<<: *idrac_inputs |
| 147 |
command: "AssignSpare" |
| 148 |
controller_id: "{{ controller_id }}" |
| 149 |
volume_id: "{{ volumes.id }}" |
| 150 |
target: "{{ volumes.dedicated_hot_spare }}" |
| 151 |
job_wait: "{{ job_wait }}" |
| 152 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 153 |
register: assign_dedicated_spare_out |
| 154 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 155 |
when: volumes.id is defined and volumes.dedicated_hot_spare is defined |
| 156 |
|
| 157 |
- name: Assign global hot spare |
| 158 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 159 |
<<: *idrac_inputs |
| 160 |
command: "AssignSpare" |
| 161 |
controller_id: "{{ controller_id }}" |
| 162 |
target: "{{ disks.id }}" |
| 163 |
job_wait: "{{ job_wait }}" |
| 164 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 165 |
register: assign_global_spare_out |
| 166 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 167 |
when: |
| 168 |
- disks is defined |
| 169 |
- disks.id is defined |
| 170 |
- '"global_hot_spare" in disks' |
| 171 |
- disks.global_hot_spare is true |
| 172 |
|
| 173 |
- name: Unassign hot spare |
| 174 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 175 |
<<: *idrac_inputs |
| 176 |
command: "UnassignSpare" |
| 177 |
controller_id: "{{ controller_id }}" |
| 178 |
target: "{{ disks.id }}" |
| 179 |
job_wait: "{{ job_wait }}" |
| 180 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 181 |
register: unassign_hotspare_out |
| 182 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 183 |
when: |
| 184 |
- disks is defined |
| 185 |
- '"global_hot_spare" in disks' |
| 186 |
- disks.global_hot_spare is false |
| 187 |
- disks.id is defined |
| 188 |
|
| 189 |
- name: Lock virtual disk |
| 190 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 191 |
<<: *idrac_inputs |
| 192 |
command: "LockVirtualDisk" |
| 193 |
controller_id: "{{ controller_id }}" |
| 194 |
volume_id: "{{ volumes.id }}" |
| 195 |
job_wait: "{{ job_wait }}" |
| 196 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 197 |
register: lock_vd_out |
| 198 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 199 |
when: |
| 200 |
volumes is defined and "encrypted" in volumes and volumes.encrypted is true |
| 201 |
|
| 202 |
- name: Online capacity expansion of a volume using target |
| 203 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 204 |
<<: *idrac_inputs |
| 205 |
command: "OnlineCapacityExpansion" |
| 206 |
controller_id: "{{ controller_id }}" |
| 207 |
volume_id: "{{ volumes.id }}" |
| 208 |
target: "{{ volumes.expand_capacity_disk | default(omit) }}" |
| 209 |
size: "{{ volumes.expand_capacity_size | default(omit) }}" |
| 210 |
job_wait: "{{ job_wait }}" |
| 211 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 212 |
register: oce_vd_out |
| 213 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 214 |
when: |
| 215 |
- volumes is defined |
| 216 |
- (volumes.expand_capacity_disk is defined or |
| 217 |
volumes.expand_capacity_size is defined) |
| 218 |
|
| 219 |
- name: Blink and Un-blink virtual disk |
| 220 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 221 |
<<: *idrac_inputs |
| 222 |
command: |
| 223 |
"{{ 'BlinkTarget' if volumes.blink is true else 'UnBlinkTarget' }}" |
| 224 |
controller_id: "{{ controller_id }}" |
| 225 |
volume_id: "{{ volumes.id }}" |
| 226 |
register: blink_vd_out |
| 227 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 228 |
when: volumes is defined and volumes.blink is defined |
| 229 |
|
| 230 |
- name: Blink and Un-blink physical disk |
| 231 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 232 |
<<: *idrac_inputs |
| 233 |
command: |
| 234 |
"{{ 'BlinkTarget' if disks.blink is true else 'UnBlinkTarget' }}" |
| 235 |
controller_id: "{{ controller_id }}" |
| 236 |
target: "{{ disks.id }}" |
| 237 |
register: blink_pd_out |
| 238 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 239 |
when: disks is defined and disks.blink is defined |
| 240 |
|
| 241 |
- name: Enable security on storage controller |
| 242 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 243 |
<<: *idrac_inputs |
| 244 |
command: "EnableSecurity" |
| 245 |
controller_id: "{{ controller_id }}" |
| 246 |
job_wait: "{{ job_wait }}" |
| 247 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 248 |
register: enable_security_out |
| 249 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 250 |
when: enable_security is defined and enable_security is true |
| 251 |
|
| 252 |
- name: Disable security on storage controller |
| 253 |
dellemc.openmanage.idrac_redfish_storage_controller: |
| 254 |
<<: *idrac_inputs |
| 255 |
command: "DisableSecurity" |
| 256 |
controller_id: "{{ controller_id }}" |
| 257 |
job_wait: "{{ job_wait }}" |
| 258 |
job_wait_timeout: "{{ job_wait_timeout }}" |
| 259 |
register: disable_security_out |
| 260 |
delegate_to: "{{ idrac_storage_controller_task_delegate }}" |
| 261 |
when: disable_security is defined and disable_security is true |
| 262 |
|
| 263 |
- name: Collecting all the registers |
| 264 |
ansible.builtin.set_fact: |
| 265 |
idrac_storage_controller_out: |
| 266 |
controller_reset_config: "{{ reset_config_out }}" |
| 267 |
controller_attributes_config: "{{ attributes_config_out }}" |
| 268 |
controller_rekey: "{{ storage_controller_rekey }}" |
| 269 |
enable_encryption: "{{ enable_encryption_out }}" |
| 270 |
set_controller_key: "{{ set_controller_key_out }}" |
| 271 |
remove_controller_key: "{{ remove_controller_key_out }}" |
| 272 |
physical_disk_state: "{{ pd_state_out }}" |
| 273 |
physical_disk_raid_state: "{{ raid_state_out }}" |
| 274 |
assign_dedicated_spare: "{{ assign_dedicated_spare_out }}" |
| 275 |
assign_global_spare: "{{ assign_global_spare_out }}" |
| 276 |
unassign_hotspare: "{{ unassign_hotspare_out }}" |
| 277 |
lock_vd: "{{ lock_vd_out }}" |
| 278 |
oce_vd: "{{ oce_vd_out }}" |
| 279 |
blink_vd: "{{ blink_vd_out }}" |
| 280 |
blink_pd: "{{ blink_pd_out }}" |
| 281 |
secure_erase: "{{ erase_state_out }}" |