Debian Codegraph @

ansible_collections/dellemc/openmanage/roles/idrac_os_deployment/README.md

raw symbols SCIP
1 idrac_os_deployment
2 =========
3
4 Role to deploy operating system and version on the servers.</br>
5
6 The role perform the following operations:
7 1. Downloads or copies the source ISO as a local copy in the ansible controller machine tmp folder.
8 1. Create a kickstart file using jinja template based on the os name and version .
9 1. Extract the ISO using the `xorriso` library.
10 1. Enable the extracted ISO to use kickstart file by modifying the boot configurations for bios and uefi.
11 1. Compile the iso to generate a custom iso by embedding the kickstart file in an iso using the `mkisofs`, `isohybrid` and `implantisomd5` commands.
12 1. Copy the custom ISO generated to destination share location as specfied to the role input. Based on the input a following method is used to copy the destination to a shared repository.
13 - CIFS/NFS uses the local file mount to copy the ISO to a location.
14 - HTTP/HTTPS uses the SSH to copy/transfer the ISO to a location where the web server content is served.
15 1. Using an iDRAC `idrac_virtual_media` module mount the custom ISO as virtual media (virtual CD) in an iDRAC.
16 1. Using an iDRAC `idrac_boot` module set the boot target to CD and enable a reboot to CD once.
17 1. Track for the OS deployment for the specified amount of user input time.
18 1. Eject the virtual media after the specfied time is finished.
19
20 Requirements
21 ------------
22
23 ### Prerequisite
24 * To Support the HTTP/HTTPS repository as a destination an ssh to a target machine should be enabled to copy the custom iso into a http/https share location.
25 * To Support the CIFS/NFS repository as a destination the repository needs to be manually mounted to local (ansible controller) copy the custom iso into locally mounted CIFS/NFS share location.
26 ### Development
27 Requirements to develop and contribute to the role.
28 ```
29 ansible
30 python
31 xorriso
32 syslinux
33 isomd5sum
34 wget
35 ```
36 ### Production
37 Requirements to use the role.
38 ```
39 ansible
40 python
41 xorriso
42 syslinux
43 isomd5sum
44 wget
45 ```
46
47 ### Ansible collections
48 Collections required to use the role
49 ```
50 dellemc.openmanage
51 ansible.utils
52 ansible.windows
53 ```
54 Role Variables
55 --------------
56
57 <table>
58 <thead>
59 <tr>
60 <th>Name</th>
61 <th>Required</th>
62 <th>Default Value</th>
63 <th>Choices</th>
64 <th>Type</th>
65 <th>Description</th>
66 </tr>
67 </thead>
68 <tbody>
69 <tr>
70 <td>hostname</td>
71 <td>true</td>
72 <td></td>
73 <td></td>
74 <td>str</td>
75 <td>iDRAC IP Address or hostname</td>
76 </tr>
77 <tr>
78 <td>username</td>
79 <td>true</td>
80 <td></td>
81 <td></td>
82 <td>str</td>
83 <td>iDRAC username with admin privilages</td>
84 </tr>
85 <tr>
86 <td>password</td>
87 <td>true</td>
88 <td></td>
89 <td></td>
90 <td>str</td>
91 <td>iDRAC user password.</td>
92 </tr>
93 <tr>
94 <td>https_port</td>
95 <td>false</td>
96 <td>443</td>
97 <td></td>
98 <td>int</td>
99 <td>iDRAC port.</td>
100 </tr>
101 <tr>
102 <td>validate_certs</td>
103 <td>false</td>
104 <td>true</td>
105 <td></td>
106 <td>bool</td>
107 <td>If C(false), the SSL certificates will not be validated.<br>Configure C(false) only on personally controlled sites where self-signed certificates are used.</td>
108 </tr>
109 <tr>
110 <td>ca_path</td>
111 <td>false</td>
112 <td></td>
113 <td></td>
114 <td>path</td>
115 <td>The Privacy Enhanced Mail (PEM) file that contains a CA certificate to be used for the validation.</td>
116 </tr>
117 <tr>
118 <td>https_timeout</td>
119 <td>false</td>
120 <td>30</td>
121 <td></td>
122 <td>int</td>
123 <td> The HTTPS socket level timeout in seconds.</td>
124 </tr>
125 <tr>
126 <td>os_name</td>
127 <td>false</td>
128 <td></td>
129 <td></td>
130 <td>str</td>
131 <td>- The operating system name to match the jinja template of the kickstart file.</br>- Supported os name is versions for RHEL and ESXI.</br>- Jinja template file should exists in the format `os_name_upper_os_version_major.j2`</td>
132 </tr>
133 <tr>
134 <td>os_version</td>
135 <td>false</td>
136 <td></td>
137 <td></td>
138 <td>str</td>
139 <td>- The operating system version to match the jinja template of the kickstart file.</br>- Supported versions for RHEL are 10.x, 9.x and 8.x and for ESXi is 8.x.</br> - Jinja template file should exists in the format `os_name_upper_os_version_major.j2`</td>
140 </tr>
141 <tr>
142 <td>source</td>
143 <td>true</td>
144 <td></td>
145 <td></td>
146 <td>dict</td>
147 <td>HTTP/HTTPS share or local path of the ISO.</td>
148 </tr>
149 <tr>
150 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protocol</td>
151 <td>true</td>
152 <td></td>
153 <td>["https", "http", "local", "cifs", "nfs"]</td>
154 <td>str</td>
155 <td>- Type of the the transfer protocol used to download the iso.<br/>- C(https) uses the https protocol to download the iso.<br/>- C(http) uses the http protocol to download the iso.<br/>- C(nfs) uses the locally mounted nfs folder path to download the iso.<br/>- C(cifs) uses the locally mounted cifs folder path to download the iso.<br/>- C(local) uses the local folder path to download the iso.<br/>- If I(custom_iso_true) is C(true) this will be used to mount the custom iso to virtual media.</td>
156 </tr>
157 <tr>
158 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hostname</td>
159 <td>true</td>
160 <td></td>
161 <td></td>
162 <td>str</td>
163 <td>- HTTP/HTTPS address to download the ISO.<br/>- Hostname of the http/https/cifs and nfs to mount the custom iso to virtual media.<br/>- I(hostname) is applicable to download iso only when I(protocol) is C(http) or C(https) and I(is_custom_iso) is C(false).<br/>- I(hostname) is ignored to download the iso when I(protocol) is C(local), C(nfs) or C(cifs) and I(is_custom_iso) is C(false).<br/>- I(hostname) will be used to attach the virtual media when I(is_custom_iso) is C(true).</td>
164 </tr>
165 <tr>
166 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iso_path</td>
167 <td>true</td>
168 <td></td>
169 <td></td>
170 <td>path</td>
171 <td>- Absolute local path or http/https share path of the iso.<br/>- when I(custom_iso) true I(iso_path) should be http, https, nfs or cifs path.</td>
172 </tr>
173 <tr>
174 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iso_name</td>
175 <td>true</td>
176 <td></td>
177 <td></td>
178 <td>str</td>
179 <td>Name of the iso file.</td>
180 </tr>
181 <tr>
182 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ks_path</td>
183 <td>false</td>
184 <td></td>
185 <td></td>
186 <td>path</td>
187 <td>- Absolute local path or http/https share path kickstart file.<br/>- When I(ks_path) is provided role skips the generation of kickstart file and uses the one provided in the input.</td>
188 </tr>
189 <tr>
190 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is_custom_iso</td>
191 <td>false</td>
192 <td>false</td>
193 <td></td>
194 <td>bool</td>
195 <td>- Specifies the source iso is a custom iso.<br/>- C(true) uses the custom iso and skips the kickstart file generation and custom iso compilation.<br/>- when C(true), I(destination) is ignored and uses the I(iso_path) to mount the virtual media on idrac.<br/>- C(false) runs the the kickstart file generation and custom iso compilation</td>
196 </tr>
197 <tr>
198 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username</td>
199 <td>false</td>
200 <td></td>
201 <td></td>
202 <td>str</td>
203 <td>- Username of the http, https and cifs share.<br/>- I(username) is applicable only when I(protocol) is C(http) , C(https) to download the iso file.<br/>- I(username) is used to mount the virtual media on idrac and applicable when I(protocol) is C(http), C(https) or C(cifs) and I(is_custom_iso) is C(true).<br/>- I(username) is ignored when I(protocol) is C(local).</td>
204 </tr>
205 <tr>
206 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password</td>
207 <td>false</td>
208 <td></td>
209 <td></td>
210 <td>str</td>
211 <td>- Password of the http, https and cifs share.<br/>- I(password) is applicable only when I(protocol) is C(http) , C(https) to download the iso file.<br/>- I(password) is applicable to mount the custom iso as a virtual media in idrac when I(protocol) is C(http) , C(https), c(cifs) and I(is_custom_iso) is C(true).<br/>- I(password) is ignored when I(protocol) is C(local).</td>
212 </tr>
213 <tr>
214 <td>destination</td>
215 <td>true</td>
216 <td></td>
217 <td></td>
218 <td>dict</td>
219 <td>- Share path to mount the ISO to iDRAC.<br/>- Share needs to have a write permission to copy the generated ISO.<br/>- CIFS, NFS, HTTP and HTTPS shares are supported.<br/>- I(destination) is ignored when I(is_custom_iso) is C(true)<br>- When the protocol is of C(http), C(https) custom iso is copied into a destination location/folder where the web server content is served.<br/>- When the protocol is of C(cifs), c(nfs) custom iso is copied into the locally mounted nfs or cifs location location.</td>
220 </tr>
221 <tr>
222 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protocol</td>
223 <td>true</td>
224 <td></td>
225 <td>["https", "http", "nfs", "cifs"]</td>
226 <td>str</td>
227 <td>- Type of the the transfer protocol used to mount the virtual media on to idrac.- C(https) uses the ssh protocol to copy the custom iso to the I(mountpoint) and uses https protocol to the mount the virtual media.- C(http) uses the ssh protocol to copy the custom iso to the I(mountpoint) and uses https protocol to the mount the virtual media.- C(nfs) copies the the custom iso to the I(mountpoint) mounted localy and uses nfs protocol to the mount the virtual media.- C(cifs) copies the the custom iso to the I(mountpoint) mounted localy and uses cifs protocol to the mount the virtual media.</td>
228 </tr>
229 <tr>
230 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hostname</td>
231 <td>true</td>
232 <td></td>
233 <td></td>
234 <td>str</td>
235 <td>- Target machine address/hostname where the custom iso will be copied.<br/>- Address/hostname used to mount the iso as a virtual media.<br/>- I(hostname) is applicable to copy iso using ssh when I(protocol) is C(http) or C(https).<br/>- I(hostname) will be defaulted to localhost to copy iso when I(protocol) is C(nfs), C(cifs).<br/> - I(hostname) will be used to mount the virtual media in idrac when I(protocol) is C(http), C(https), C(nfs) or C(cifs).</td>
236 </tr>
237 <tr>
238 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iso_path</td>
239 <td>true</td>
240 <td></td>
241 <td></td>
242 <td>path</td>
243 <td>Custom iso absolute path to be used to mount as a virtual media in idrac.</td>
244 </tr>
245 <tr>
246 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iso_name</td>
247 <td>false</td>
248 <td></td>
249 <td></td>
250 <td>str</td>
251 <td>Custom iso file name. If not specified defaulted to C(hostname-source.iso_name).</td>
252 </tr>
253 <tr>
254 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mountpoint</td>
255 <td>true</td>
256 <td></td>
257 <td></td>
258 <td>path</td>
259 <td>- Target machine absolute path where the custom iso will be copied.<br/>- I(mountpoint) will be path where http/https is served from when I(protocol) is C(http), C(https).<br/>- I(mountpoint) will be local folder mounted with nfs/cifs share when I(protocol) is C(nfs) C(cifs).</td>
260 </tr>
261 <tr>
262 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;os_type</td>
263 <td>false</td>
264 <td>linux</td>
265 <td>["linux", "windows"]</td>
266 <td>str</td>
267 <td>HTTP/HTTPS share based on linux/Windows.</td>
268 </tr>
269 <tr>
270 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username</td>
271 <td>false</td>
272 <td></td>
273 <td></td>
274 <td>str</td>
275 <td>Username of the http/https/cifs share where customized ISO is used to mount as a virtual media.</td>
276 </tr>
277 <tr>
278 <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password</td>
279 <td>false</td>
280 <td></td>
281 <td></td>
282 <td>str</td>
283 <td>Password of the http/https/cifs share where customized ISO is used to mount as a virtual media.</td>
284 </tr>
285 <tr>
286 <td>wait_for_os_deployment</td>
287 <td>false</td>
288 <td>true</td>
289 <td></td>
290 <td>bool</td>
291 <td>Wait for the OS deployment to finish.</td>
292 </tr>
293 <tr>
294 <td>os_deployment_timeout</td>
295 <td>false</td>
296 <td>30</td>
297 <td></td>
298 <td>int</td>
299 <td>Time in minutes to wait for the OS deployment to finish.</td>
300 </tr>
301 <tr>
302 <td>eject_iso</td>
303 <td>false</td>
304 <td>true</td>
305 <td></td>
306 <td>bool</td>
307 <td>- Eject the virtual media (ISO) after the tracking of OS deployment is finished.<br/>- ISO will be ejected if I(eject_iso) is C(true) and I(wait_for_os_deployment) is C(true).</td>
308 </tr>
309 <tr>
310 <td>delete_custom_iso</td>
311 <td>false</td>
312 <td></td>
313 <td>true</td>
314 <td>bool</td>
315 <td>- Deletes the Custom iso after the OS deployment is finshed.<br/>- ISO will be delete if I(delete_custom_iso) is C(true) and I(wait_for_os_deployment) is C(true).</td>
316 </tr>
317 </tbody>
318 </table>
319
320 ## SSH ansible Variables
321 <table>
322 <thead>
323 <tr>
324 <th>Name</th>
325 <th>Sample</th>
326 <th>Description</th>
327 </tr>
328 </thead>
329 <tbody>
330 <tr>
331 <td>ansible_ssh_user</td>
332 <td>user</td>
333 <td>Username of the target ssh machine where the custom iso is copied</br>This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.</td>
334 </tr>
335 <tr>
336 <td>ansible_ssh_password</td>
337 <td>password</td>
338 <td>Password of the target ssh machine where the custom iso is copied</br>This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.</td>
339 </tr>
340 <tr>
341 <td>ansible_remote_tmp</td>
342 <td>C://User//tmp</td>
343 <td>Temp directory of the target ssh machine where the custom iso is copied</br>This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.</td>
344 </tr>
345 <tr>
346 <td>become_method</td>
347 <td>runas</td>
348 <td>Overrides the default method of shh</br>This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.</td>
349 </tr>
350 <tr>
351 <td>shell_type</td>
352 <td>cmd</td>
353 <td>Defines the shell type to be used on the target ssh machine where the custom iso is copied</br>This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.</td>
354 </tr>
355 </tbody>
356 </table>
357
358 ## Fact variables
359
360 <table>
361 <thead>
362 <tr>
363 <th>Name</th>
364 <th>Sample</th>
365 <th>Description</th>
366 </tr>
367 </thead>
368 <tbody>
369 <tr>
370 <td>idrac_os_deployment_out</td>
371 <td>Successfully deployed the Operating System</td>
372 <td>Output of the OS deployment role.</td>
373 </tr>
374 <tr>
375 <td>idrac_os_deployment_failure</td>
376 <td>The combination of OS name %s and version %s is not supported.</td>
377 <td>Error result of the task</td>
378 </tr>
379 <tr>
380 <td>idrac_os_deployment_kickstart_file</td>
381 <td>/tmp/omam_osd_kufwni/kickstart.cfg</td>
382 <td>Path of the kickstart file generated or downloaded</td>
383 </tr>
384 <tr>
385 <td>idrac_os_deployment_iso_file</td>
386 <td>/tmp/omam_osd_kufwni/rhel.iso</td>
387 <td>Path of the iso file downloaded</td>
388 </tr>
389 <tr>
390 <td>idrac_os_deployment_iso_extract_dir</td>
391 <td>/tmp/omam_osd_kufwni/extract</td>
392 <td>Path of the extract folder created within the tmp directory</td>
393 </tr>
394 <tr>
395 <td>idrac_os_deployment_custom_iso_filename</td>
396 <td>198.192.0.1_rhel.iso</td>
397 <td>Filename of the custom iso file genereated</td>
398 </tr>
399 <tr>
400 <td>idrac_os_deployment_custom_iso_file</td>
401 <td>/tmp/omam_osd_kufwni/198.192.0.1_rhel.iso</td>
402 <td>Path of the custom iso file genereated</td>
403 </tr>
404 <tr>
405 <td>idrac_os_deployment_hybrid_cmd</td>
406 <td>isohybrid --uefi /tmp/omam_osd_kufwni/198.192.0.1_rhel.iso</td>
407 <td>Command isohybrid applied the custom iso file</td>
408 </tr>
409 <tr>
410 <td>idrac_os_deployment_checksum_cmd</td>
411 <td>implantisomd5 --uefi /tmp/omam_osd_kufwni/198.192.0.1_rhel.iso</td>
412 <td>Command to implant md5 checksum on the custom iso file</td>
413 </tr>
414 <tr>
415 <td>idrac_os_deployment_xorriso_cmd</td>
416 <td>xorriso -osirrox -indev /tmp/omam_osd_kufwni/rhel.iso -extract / /tmp/omam_osd_kufwni/extract</td>
417 <td>Command xorisso to extract the downloaded iso</td>
418 </tr>
419 <tr>
420 <td>idrac_os_deployment_delegate</td>
421 <td>localhost</td>
422 <td>Enables the delgate task to run on localhost or container in case of molecules</td>
423 </tr>
424 <tr>
425 <td>idrac_os_deployment_supported_os</td>
426 <td>{ RHEL: ["8", "9", "10"], ESXI: ["8"] }</td>
427 <td>Hold the map data of supported os name and version</td>
428 </tr>
429 </tbody>
430 </table>
431
432 ## Env Varaibles
433
434 When we have to SSH into a machine a fingerprint has to be added into the ansible controller machine for it to connect succesfully, if you trust the machine you are copying you use the below environment variable disable the fingerprint check.
435
436 ```export ANSIBLE_HOST_KEY_CHECKING=False```
437
438 Example Playbook
439 ----------------
440
441 ```
442 - name: Generate Kickstart file, custom iso and install RHEL OS
443 ansible.builtin.import_role:
444 name: idrac_os_deployment
445 vars:
446 hostname: 192.168.0.1
447 username: root
448 password: password
449 os_name: RHEL
450 os_version: 9
451 source:
452 protocol: https
453 hostname: 198.192.0.1
454 iso_path: /to/iso
455 iso_name: rhel9.iso
456 destination:
457 protocol: https
458 hostname: 198.192.0.1
459 mountpath: /user/www/myrepo
460 os_type: linux
461 iso_path: /to/iso
462 ```
463 ```
464 - name: Generate custom iso using a kickstart file and install RHEL OS
465 ansible.builtin.import_role:
466 name: idrac_os_deployment
467 vars:
468 hostname: 192.168.0.1
469 username: root
470 password: password
471 ca_path: path/to/ca
472 os_name: RHEL
473 os_version: 9
474 source:
475 protocol: https
476 hostname: 198.192.0.1
477 ks_path: /to/iso/rhel-9.cfg
478 path: /to/iso
479 iso_name: rhel9.iso
480 destination:
481 protocol: https
482 hostname: 198.192.0.1
483 mountpath: /user/www/myrepo
484 os_type: linux
485 iso_path: /to/iso
486 ```
487 ```
488 - name: Install RHEL OS using a custom iso
489 ansible.builtin.import_role:
490 name: idrac_os_deployment
491 vars:
492 hostname: 192.168.0.1
493 username: root
494 password: password
495 os_name: RHEL
496 os_version: 9
497 source:
498 protocol: https
499 hostname: 198.192.0.1
500 iso_path: /to/iso
501 iso_name: custom-rhel.iso
502 is_custom_iso: true
503 ```
504 Author Information
505 ------------------
506 Dell Technologies <br>
507 Sachin Apagundi ([email protected]) 2023 <br>
508 Abhishek Sinha ([email protected]) 2023 <br>
509 Jagadeesh N V ([email protected]) 2023