Skip to main content

Deploying RHEL and a Hello World PHP application using custom software and a post-installation script

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.

  1. 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.
    1. From the XClarity Administrator menu bar, click Provisioning > Manage OS Images to display the Deploy Operating System: Manage OS Images page.

    2. Click the OS Images tab.

    3. Click Import icon (Import icon).

    4. Click Local Import.

    5. Click Browse to find and select the RHEL image to import (for example, RHEL-<ver>–<date>-Server-x86_64-dvd1.iso).

    6. Click Import to upload the image to the OS-images repository.

    7. Wait for the import to complete. This might take a while.

  2. 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
    1. Click the Software tab.

    2. Click the Import icon (Import icon).

    3. Click Local Import.

    4. Select RHEL for the operating system.

    5. Click Browse to find and select the software file to import (for example, RHEL_installSoftware_customsw.tar.gz).

    6. Click Import to upload the file to the OS-images repository.

  3. 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.

    1. Click the Installation Scripts tab.

    2. Click the Import icon (Import icon).

    3. Click Local Import.

    4. Select RHEL for the operating system.

    5. Click Browse to find and select the post-installation script to import (for example, RHEL_installSoftware_customScript.sh).

    6. Click Import to upload the file to the OS-images repository.

  4. 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.
    1. Click the OS Images tab.

    2. Select an OS-image profile to customize (for example, Basic).

    3. Click Create icon (Create icon) to display the Create Customized Profile dialog.

    4. On the General tab:

      1. Enter a name for the profile (for example, Custom RHEL with software using post-installation script).

      2. Use the default value for the Custom data and file path field.

      3. Select None for the customization type.

      4. Click Next.

    5. On the Driver Options tab, click Next. The inbox device drivers are included by default.

    6. On the Software tab, select the software installation files (for example httpd.conf and index.php), and click Next.

    7. On the Installation Scripts tab, select the installation scripts (for example, RHEL_installSoftware_customScript.sh), and click Next.

    8. On the Summary tab, review the settings.

    9. Click Customize to create the custom OS-image profile.

  5. Deploy the custom OS-image profile to the target servers. For more information, see Deploying an operating-system image.
    1. From the XClarity Administrator menu bar, click Provisioning > Deploy OS Images to display the Deploy Operating System: Deploy OS Images page.

    2. For each target server:

      1. Select the server.

      2. Click Change Selected > Network Settings, 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 Global Settings > IP Assignment > Use VLANs.
      3. 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.
      4. 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.
      5. Verify that the deployment status for the selected server is Ready.

    3. Select all target servers, and click the Deploy image icon (Deploy image icon) to initiate the operating-system deployment.

    4. On the Summary tab, review the settings.

    5. Click Deploy to deploy the operating system.