idrac_os_deployment ========= Role to deploy operating system and version on the servers.
The role perform the following operations: 1. Downloads or copies the source ISO as a local copy in the ansible controller machine tmp folder. 1. Create a kickstart file using jinja template based on the os name and version . 1. Extract the ISO using the `xorriso` library. 1. Enable the extracted ISO to use kickstart file by modifying the boot configurations for bios and uefi. 1. Compile the iso to generate a custom iso by embedding the kickstart file in an iso using the `mkisofs`, `isohybrid` and `implantisomd5` commands. 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. - CIFS/NFS uses the local file mount to copy the ISO to a location. - HTTP/HTTPS uses the SSH to copy/transfer the ISO to a location where the web server content is served. 1. Using an iDRAC `idrac_virtual_media` module mount the custom ISO as virtual media (virtual CD) in an iDRAC. 1. Using an iDRAC `idrac_boot` module set the boot target to CD and enable a reboot to CD once. 1. Track for the OS deployment for the specified amount of user input time. 1. Eject the virtual media after the specfied time is finished. Requirements ------------ ### Prerequisite * 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. * 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. ### Development Requirements to develop and contribute to the role. ``` ansible python xorriso syslinux isomd5sum wget ``` ### Production Requirements to use the role. ``` ansible python xorriso syslinux isomd5sum wget ``` ### Ansible collections Collections required to use the role ``` dellemc.openmanage ansible.utils ansible.windows ``` Role Variables --------------
Name Required Default Value Choices Type Description
hostname true str iDRAC IP Address or hostname
username true str iDRAC username with admin privilages
password true str iDRAC user password.
https_port false 443 int iDRAC port.
validate_certs false true bool If C(false), the SSL certificates will not be validated.
Configure C(false) only on personally controlled sites where self-signed certificates are used.
ca_path false path The Privacy Enhanced Mail (PEM) file that contains a CA certificate to be used for the validation.
https_timeout false 30 int The HTTPS socket level timeout in seconds.
os_name false str - The operating system name to match the jinja template of the kickstart file.
- Supported os name is versions for RHEL and ESXI.
- Jinja template file should exists in the format `os_name_upper_os_version_major.j2`
os_version false str - The operating system version to match the jinja template of the kickstart file.
- Supported versions for RHEL are 9.x and 8.x and for ESXi is 8.x.
- Jinja template file should exists in the format `os_name_upper_os_version_major.j2`
source true dict HTTP/HTTPS share or local path of the ISO.
     protocol true ["https", "http", "local", "cifs", "nfs"] str - Type of the the transfer protocol used to download the iso.
- C(https) uses the https protocol to download the iso.
- C(http) uses the http protocol to download the iso.
- C(nfs) uses the locally mounted nfs folder path to download the iso.
- C(cifs) uses the locally mounted cifs folder path to download the iso.
- C(local) uses the local folder path to download the iso.
- If I(custom_iso_true) is C(true) this will be used to mount the custom iso to virtual media.
     hostname true str - HTTP/HTTPS address to download the ISO.
- Hostname of the http/https/cifs and nfs to mount the custom iso to virtual media.
- 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).
- 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).
- I(hostname) will be used to attach the virtual media when I(is_custom_iso) is C(true).
     iso_path true path - Absolute local path or http/https share path of the iso.
- when I(custom_iso) true I(iso_path) should be http, https, nfs or cifs path.
     iso_name true str Name of the iso file.
     ks_path false path - Absolute local path or http/https share path kickstart file.
- When I(ks_path) is provided role skips the generation of kickstart file and uses the one provided in the input.
     is_custom_iso false false bool - Specifies the source iso is a custom iso.
- C(true) uses the custom iso and skips the kickstart file generation and custom iso compilation.
- when C(true), I(destination) is ignored and uses the I(iso_path) to mount the virtual media on idrac.
- C(false) runs the the kickstart file generation and custom iso compilation
     username false str - Username of the http, https and cifs share.
- I(username) is applicable only when I(protocol) is C(http) , C(https) to download the iso file.
- 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).
- I(username) is ignored when I(protocol) is C(local).
     password false str - Password of the http, https and cifs share.
- I(password) is applicable only when I(protocol) is C(http) , C(https) to download the iso file.
- 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).
- I(password) is ignored when I(protocol) is C(local).
destination true dict - Share path to mount the ISO to iDRAC.
- Share needs to have a write permission to copy the generated ISO.
- CIFS, NFS, HTTP and HTTPS shares are supported.
- I(destination) is ignored when I(is_custom_iso) is C(true)
- 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.
- When the protocol is of C(cifs), c(nfs) custom iso is copied into the locally mounted nfs or cifs location location.
     protocol true ["https", "http", "nfs", "cifs"] str - 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.
     hostname true str - Target machine address/hostname where the custom iso will be copied.
- Address/hostname used to mount the iso as a virtual media.
- I(hostname) is applicable to copy iso using ssh when I(protocol) is C(http) or C(https).
- I(hostname) will be defaulted to localhost to copy iso when I(protocol) is C(nfs), C(cifs).
- 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).
     iso_path true path Custom iso absolute path to be used to mount as a virtual media in idrac.
     iso_name false str Custom iso file name. If not specified defaulted to C(hostname-source.iso_name).
     mountpoint true path - Target machine absolute path where the custom iso will be copied.
- I(mountpoint) will be path where http/https is served from when I(protocol) is C(http), C(https).
- I(mountpoint) will be local folder mounted with nfs/cifs share when I(protocol) is C(nfs) C(cifs).
     os_type false linux ["linux", "windows"] str HTTP/HTTPS share based on linux/Windows.
     username false str Username of the http/https/cifs share where customized ISO is used to mount as a virtual media.
     password false str Password of the http/https/cifs share where customized ISO is used to mount as a virtual media.
wait_for_os_deployment false true bool Wait for the OS deployment to finish.
os_deployment_timeout false 30 int Time in minutes to wait for the OS deployment to finish.
eject_iso false true bool - Eject the virtual media (ISO) after the tracking of OS deployment is finished.
- ISO will be ejected if I(eject_iso) is C(true) and I(wait_for_os_deployment) is C(true).
delete_custom_iso false true bool - Deletes the Custom iso after the OS deployment is finshed.
- ISO will be delete if I(delete_custom_iso) is C(true) and I(wait_for_os_deployment) is C(true).
## SSH ansible Variables
Name Sample Description
ansible_ssh_user user Username of the target ssh machine where the custom iso is copied
This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.
ansible_ssh_password password Password of the target ssh machine where the custom iso is copied
This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.
ansible_remote_tmp C://User//tmp Temp directory of the target ssh machine where the custom iso is copied
This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.
become_method runas Overrides the default method of shh
This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.
shell_type cmd Defines the shell type to be used on the target ssh machine where the custom iso is copied
This is used copy/ssh the custom ISO to the destination folder where http/https web server serves the content.
## Fact variables
Name Sample Description
idrac_os_deployment_out Successfully deployed the Operating System Output of the OS deployment role.
idrac_os_deployment_failure The combination of OS name %s and version %s is not supported. Error result of the task
idrac_os_deployment_kickstart_file /tmp/omam_osd_kufwni/kickstart.cfg Path of the kickstart file generated or downloaded
idrac_os_deployment_iso_file /tmp/omam_osd_kufwni/rhel.iso Path of the iso file downloaded
idrac_os_deployment_iso_extract_dir /tmp/omam_osd_kufwni/extract Path of the extract folder created within the tmp directory
idrac_os_deployment_custom_iso_filename 198.192.0.1_rhel.iso Filename of the custom iso file genereated
idrac_os_deployment_custom_iso_file /tmp/omam_osd_kufwni/198.192.0.1_rhel.iso Path of the custom iso file genereated
idrac_os_deployment_hybrid_cmd isohybrid --uefi /tmp/omam_osd_kufwni/198.192.0.1_rhel.iso Command isohybrid applied the custom iso file
idrac_os_deployment_checksum_cmd implantisomd5 --uefi /tmp/omam_osd_kufwni/198.192.0.1_rhel.iso Command to implant md5 checksum on the custom iso file
idrac_os_deployment_xorriso_cmd xorriso -osirrox -indev /tmp/omam_osd_kufwni/rhel.iso -extract / /tmp/omam_osd_kufwni/extract Command xorisso to extract the downloaded iso
idrac_os_deployment_delegate localhost Enables the delgate task to run on localhost or container in case of molecules
idrac_os_deployment_supported_os { RHEL: ["8", "9"], ESXI: ["8"] } Hold the map data of supported os name and version
## Env Varaibles 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. ```export ANSIBLE_HOST_KEY_CHECKING=False``` Example Playbook ---------------- ``` - name: Generate Kickstart file, custom iso and install RHEL OS ansible.builtin.import_role: name: idrac_os_deployment vars: hostname: 192.168.0.1 username: root password: password os_name: RHEL os_version: 9 source: protocol: https hostname: 198.192.0.1 iso_path: /to/iso iso_name: rhel9.iso destination: protocol: https hostname: 198.192.0.1 mountpath: /user/www/myrepo os_type: linux iso_path: /to/iso ``` ``` - name: Generate custom iso using a kickstart file and install RHEL OS ansible.builtin.import_role: name: idrac_os_deployment vars: hostname: 192.168.0.1 username: root password: password ca_path: path/to/ca os_name: RHEL os_version: 9 source: protocol: https hostname: 198.192.0.1 ks_path: /to/iso/rhel-9.cfg path: /to/iso iso_name: rhel9.iso destination: protocol: https hostname: 198.192.0.1 mountpath: /user/www/myrepo os_type: linux iso_path: /to/iso ``` ``` - name: Install RHEL OS using a custom iso ansible.builtin.import_role: name: idrac_os_deployment vars: hostname: 192.168.0.1 username: root password: password os_name: RHEL os_version: 9 source: protocol: https hostname: 198.192.0.1 iso_path: /to/iso iso_name: custom-rhel.iso is_custom_iso: true ``` Author Information ------------------ Dell Technologies
Sachin Apagundi (Sachin_Apagundi@Dell.com) 2023
Abhishek Sinha (Abhishek.Sinha10@Dell.com) 2023
Jagadeesh N V (Jagadeesh.N.V@Dell.com) 2023