This scenario installs the RHEL operating system along
with custom software (Apache HTTP, PHP, and a hello-world PHP application).
A custom OS-image profile is used that includes the custom software
and a post-installation script that registers the operating system
with the internal Lenovo RHEL subscription service so that it can
use the yum repositories, installs the Apache and PHP packages, configures
the firewall to allow Apache connections, creates a Hello World PHP
application and copies to the Apache web server directory, and configures
the Apache configuration files to support PHP. The custom software
packages are exported to the host during the deployment and made available
for the custom post-installation script to use.
Before you begin
You can deploy RHEL and a Hello World PHP application in a
few different ways. This example uses a post-installation script that
installs custom software that you import into the repository and include
in the custom OS-image profile. You can also use a custom attend file
that you include in the custom OS-image profile. For installing software
using a custom attend file, see Deploying RHEL and a Hello World PHP application using a custom unattend file.
This
scenario uses the following sample files.
Note:
RHEL installation scripts can be in one of the following formats: Bash (.sh), Perl (.pm or .pl),
Python (.py)
Software files and installation scripts are installed from
the custom data and files path that you specify during deployment. The default custom data and files path
is /home/lxca.
Procedure
To deploy RHEL with custom software using a post-installation script,
complete the following steps.
- Download the base RHEL operating system from the Red Hat
website to the local system, and import the image to the OS-images
repository. For more information, see Importing operating-system images.
From the XClarity Administrator menu bar, click to display the Deploy Operating System: Manage OS Images page.
Click the OS Images tab.
Click Import icon ().
Click Local Import.
Click Browse to find and select the
RHEL image to import (for example, RHEL-<ver>–<date>-Server-x86_64-dvd1.iso).
Click Import to upload the image to
the OS-images repository.
Wait for the import to complete. This might take a while.
- Download the custom software to the local system and import
the files into the OS-images repository. For more information, see Importing custom software.
Tip: To import
custom software into XClarity Administrator, the files must be contained in a tar.gz file. For this
example, compress the example software files httpd.conf and index.php into a tar.gz file named RHEL_installSoftware_customsw.tar.gz before
continuing
Click the Software tab.
Click the Import icon ().
Click Local Import.
Select RHEL for the operating system.
Click Browse to find and select the
software file to import (for example, RHEL_installSoftware_customsw.tar.gz).
Click Import to upload the file to the
OS-images repository.
- Create a custom post-installation script, and import the
file to the OS-images repository.
Add commands to register the host with the RHEL satellite,
for example:
rpm -Uvh http://satellite.labs.lenovo.com/pub/katello-ca-consumer-latest.noarch.rpm
subscription-manager register --org="Default_Organization" --activationkey="RHEL_Base" --force
subscription-manager repos --enable rhel-7-server-rpms A
Add a command to update the host and install and configure
apache and php packages, for example:
yum -y update
yum -y install httpd mod_ssl openssl php php-mysql php-gd
systemctl enable httpd.service
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
Add commands to add our PHP
application to the web serversatellite, for example:
cp #predefined.otherSettings.deployDataAndSoftwareLocation#/lxca/index.php /var/www/html/index.php
Add commands to configure Apache HTTP, for example:
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.original
cp #predefined.otherSettings.deployDataAndSoftwareLocation#/httpd.conf /etc/httpd/conf/httpd.conf
Note that
these commands use predefined macros for the path to the extracted
data and software files (predefined.otherSettings.deployDataAndSoftwareLocation).
You can also add commands to send custom messages to the
jobs log in XClarity Administrator. For more information, see Adding custom status reporting to installation scripts.
To
import the custom installation script, complete these steps. For more
information, see Importing custom installation scripts.
Click the Installation Scripts tab.
Click the Import icon ().
Click Local Import.
Select RHEL for the operating system.
Click Browse to find and select the
post-installation script to import (for example, RHEL_installSoftware_customScript.sh).
Click Import to upload the file to the
OS-images repository.
- Create a custom OS-image profile that includes the custom
software and post-installation script. For more information, see Creating a custom OS-image profile.
Click the OS Images tab.
Select an OS-image profile to customize (for example, Basic).
Click Create icon () to display the Create Customized
Profile dialog.
On the General tab:
Enter a name for the profile (for example, Custom RHEL with software using post-installation
script).
Use the default value for the Custom data and file
path field.
Select None for the customization type.
Click Next.
On the Driver Options tab, click Next. The inbox device drivers are included by default.
On the Software tab, select the software
installation files (for example httpd.conf and index.php), and click Next.
On the Installation Scripts tab, select
the installation scripts (for example, RHEL_installSoftware_customScript.sh), and click Next.
On the Summary tab, review the settings.
Click Customize to create the custom
OS-image profile.
- Deploy the custom OS-image profile to the target servers.
For more information, see Deploying an operating-system image.
From the XClarity Administrator menu bar, click to display the Deploy Operating System: Deploy OS Images page.
For each target server:
Select the server.
Click , and specify
the hostname, IP address, DNS, MTU and VLAN settings for the server.
Tip: VLAN settings
are available only when VLAN mode is set in .
Select the custom OS-image profile (for example, <base_OS>|<timestamp>_Custom RHEL with software using post-installation
script) from the drop-down list in the Image to Deploy column
Note: Ensure that all target servers use the same custom
profile.
Select the preferred storage location where you want to deploy
the operating system image from the Storage column.
Note: To ensure that operating-system deployments are
successful, detach all storage from the managed server except the
storage that is chosen for the operating-system deployment.
Verify that the deployment status for the selected server is Ready.
Select all target servers, and click the Deploy
image icon () to initiate the operating-system
deployment.
On the Summary tab, review the settings.
Click Deploy to deploy the operating
system.