|
| 1 | +Role Name |
| 2 | +========= |
| 3 | + |
| 4 | +This Ansible role "Red Hat Linux Installation for IBM PowerVM" automates the process of installing Red Hat Enterprise Linux (RHEL) on IBM PowerVM logical partitions (LPARs) using a **network-based installation via TFTP boot**. |
| 5 | + |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +This Ansible role automates the installation of Red Hat Enterprise Linux (RHEL) on IBM PowerVM logical partitions (LPARs) using a network-based TFTP boot method. It orchestrates the entire setup process including infrastructure configuration, VM provisioning, and OS deployment. |
| 10 | + |
| 11 | +The role is designed to handle both existing and non-existing LPAR scenarios: |
| 12 | + |
| 13 | +- If the LPAR already exists, the user can specify the `network_name` to attach the appropriate virtual network. |
| 14 | +- If the LPAR does not exist, the role will automatically create one. In this case, the user must provide values for `network_name`, `mem`, `proc` and `volume_size`. If these parameters are omitted, default values defined in the role's `vars` will be used. |
| 15 | + |
| 16 | +> ⚠️ **Note:** This role does not support idempotency. Re-running the playbook may result in duplicate or conflicting configurations. This role supports single LPAR installation in a playbook run. |
| 17 | +
|
| 18 | + |
| 19 | +## Required Infrastructure |
| 20 | + |
| 21 | +To perform the installation, the following components must be configured: |
| 22 | + |
| 23 | +1. **HTTP (Repo) Server** |
| 24 | + Hosts the RHEL distribution files and serves them via HTTP. This can be a dedicated server with multiple distro builds or a simple HTTP server with the required build. |
| 25 | + |
| 26 | +2. **PXE Server** |
| 27 | + Runs both `tftpd` and `dhcpd` services. This role will configure these services if they are not already running. |
| 28 | + |
| 29 | +3. **LPAR (Logical Partition)** |
| 30 | + The target system where RHEL will be installed. If LPAR is not available, it will be created by using the given details |
| 31 | + |
| 32 | +## Role Workflow |
| 33 | + |
| 34 | +1. **LPAR Existence Check and Creation** |
| 35 | +- Checks if the LPAR already exists on the HMC. |
| 36 | +- If not found, creates a new LPAR with the specified network configuration and volume size. |
| 37 | + |
| 38 | +2. **MAC Address Retrieval and Formatting** |
| 39 | +- Retrieves the MAC address of the LPAR. |
| 40 | +- Converts the MAC address into colon and hyphen formats for use in DHCP and GRUB configurations. |
| 41 | + |
| 42 | +3. **DHCP and TFTP Service Setup** |
| 43 | +- Checks if DHCP and TFTP services are running on the PXE server. |
| 44 | +- Installs and configures these services if not already running. |
| 45 | +- Calculates DHCP range and generates configuration using templates. |
| 46 | + |
| 47 | +4. **Kickstart File Generation** |
| 48 | +- Creates a kickstart file on the repository server using a Jinja2 template. |
| 49 | + |
| 50 | +5. **Boot File Preparation and GRUB Configuration** |
| 51 | +- Downloads required boot files from the repository server to the PXE server. |
| 52 | +- Creates GRUB netboot directory and configuration files. |
| 53 | +- Copies GRUB configuration to appropriate boot paths. |
| 54 | + |
| 55 | +6. **DHCP Configuration Updates and Reversion** |
| 56 | +- Adds LPAR-specific DHCP entries to the PXE server configuration. |
| 57 | +- Restarts DHCP service to apply changes. |
| 58 | +- Reverts DHCP configuration after installation. |
| 59 | + |
| 60 | +7. **Network Boot Initiation** |
| 61 | +- Executes `lpar_netboot` from the HMC to initiate network boot on the LPAR. |
| 62 | + |
| 63 | +8. **Post-Installation Validation** |
| 64 | +- Waits for SSH availability on the LPAR. |
| 65 | +- Gathers system facts and prints OS distribution and version. |
| 66 | + |
| 67 | +Role Variables |
| 68 | +-------------- |
| 69 | + |
| 70 | +1. distro: |
| 71 | + * type: str |
| 72 | + * required: true |
| 73 | + * description: Redhat distribution version in format Redhat9.3 |
| 74 | + |
| 75 | +2. repo_dir: |
| 76 | + * type: str |
| 77 | + * required: optional |
| 78 | + * description: The path in which http server is hosting the redhat repository, can be in default path /var/www/html/ a directory "crtl". Specify in format "crtl", this is used in roles as http://abc.com/crtl/ |
| 79 | + |
| 80 | +3. curr_hmc_auth: |
| 81 | + * type: str |
| 82 | + * required: true |
| 83 | + * description: Username and Password to login to HMC system, For security purposes, it is highly recommended to store this sensitive information in an encrypted secret vault file. |
| 84 | + |
| 85 | +4. host_ip/host_gw/host_subnet/host_netmask: |
| 86 | + * type: str |
| 87 | + * required: true |
| 88 | + * description: lpar Network details in format 9.9.9.9 |
| 89 | + |
| 90 | +5. dns_ip: |
| 91 | + * type: str |
| 92 | + * required: true |
| 93 | + * description: Nameserver IP details in format 9.1.1.1 |
| 94 | + |
| 95 | +6. hostname: |
| 96 | + * type: str |
| 97 | + * required: true |
| 98 | + * description: hostname of the lpar in format aaa.abc.com |
| 99 | + |
| 100 | +7. lpar_name: |
| 101 | + * type: str |
| 102 | + * required: true |
| 103 | + * desription: name of lpar as in the HMC |
| 104 | + |
| 105 | +8. network_name: |
| 106 | + * type: str |
| 107 | + * required: true |
| 108 | + * description: Name of the Virtual Network to be attached to the lpar. |
| 109 | + |
| 110 | +9. managed_system: |
| 111 | + * type: str |
| 112 | + * required: true |
| 113 | + * description: system name in HMC in which lpar is available |
| 114 | + |
| 115 | +10. disk_size: |
| 116 | + * type: int |
| 117 | + * required: true |
| 118 | + * description: Physical volume size in MB. Required while creating LPAR |
| 119 | + |
| 120 | +11. mem: |
| 121 | + * type: int |
| 122 | + * required: true |
| 123 | + * description: The value of dedicated memory value in megabytes to create a partition, Default value is '2048 MB'. Required while creating LPAR |
| 124 | + |
| 125 | +12. proc: |
| 126 | + * type: int |
| 127 | + * required: true |
| 128 | + * description: The number of dedicated processors to create a partition. Default value is '2'. This will not work during shared processor setting. |
| 129 | + |
| 130 | + |
| 131 | +Example Playbook |
| 132 | +---------------- |
| 133 | + --- |
| 134 | + - name: Redhat Install linux |
| 135 | + hosts: vm |
| 136 | + collections: |
| 137 | + - ibm.power_hmc |
| 138 | + gather_facts: false |
| 139 | + roles: |
| 140 | + - role: redhat_linux_install |
| 141 | + vars: |
| 142 | + host_ip: 9.9.9.9 |
| 143 | + host_gw: 9.9.9.1 |
| 144 | + host_subnet: 9.9.9.0 |
| 145 | + host_netmask: 255.255.255.0 |
| 146 | + dns_ip: 9.1.1.1 |
| 147 | + hostname: aaa.abc.com |
| 148 | + lpar_name: name_in_hmc |
| 149 | + netowrk_name: test |
| 150 | + mem: 6144 |
| 151 | + proc: 4 |
| 152 | + disk_size: 28590 |
| 153 | + managed_system: system_name_in_HMC |
| 154 | + |
| 155 | +Inventory file with detials of pxe server, repository server and HMC server is required while running the playbook |
| 156 | +--------- |
| 157 | +For security purposes, it is highly recommended to store this sensitive information in an encrypted secret vault file. |
| 158 | + |
| 159 | + |
| 160 | + [repo] |
| 161 | + repo_server ansible_host=1.4.2.5 ansible_become_pass='abcd' ansible_user=hmc ansible_password=abcd |
| 162 | + [pxe] |
| 163 | + pxe_server ansible_host=1.4.2.9 ansible_become_pass='abcd' ansible_user=root ansible_password=abcd |
| 164 | + [hmcs] |
| 165 | + hmc_server ansible_host=1.4.2.2 ansible_become_pass='abcd' ansible_user=root ansible_password=abcd |
| 166 | + [vm] |
| 167 | + host_vm ansible_host=aaa.abc.com ansible_user=root ansible_password=abcd host_ip=9.9.9.9 |
| 168 | + |
| 169 | +----------- |
| 170 | +License |
| 171 | +------- |
| 172 | + |
| 173 | +GPL-3.0-only |
| 174 | + |
| 175 | +Author Information |
| 176 | +------------------ |
| 177 | + |
| 178 | +Spoorthy S |
0 commit comments