Deploying RHEL and a Hello World PHP application using a custom unattend file

This scenario installs the RHEL v7.5 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 unattend 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.

Before you begin

You can deploy RHEL with custom software in a few different ways. This example uses a custom attend file that you include in the custom OS-image profile. You can also use a post-installation script that installs custom software that you import into the repository and include in the custom OS-image profile. For installing software using a post-installation script, see Deploying RHEL and a Hello World PHP application using custom software and a post-installation script.

This scenario uses the following sample file.

Procedure

To deploy RHEL v7.5 with custom software using a custom unatttend file, 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-7.5-<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. Modify the RHEL unattend (kickstart) file to register the operating system with your RHEL satellite subscription service, install HTTP (Apache) and PHP packages, and create a simple Hello World PHP application, add the required predefined macros and other predefined macros where applicable, such as the IP address, gateway, DNS and host name settings, and then import the custom file to the OS-images repository. For more information, see Importing custom unattend files.
    Add commands to register the host with your RHEL satellite, for example:
    rpm -Uvh http://<YOUR_SATELLITE_SERVER_IP>/pub/katello-ca-consumer-latest.noarch.rpm
    subscription-manager register --org="<YOUR_ORGANIZATION>" --activationkey="RHEL_Base" --force
    subscription-manager repos --enable rhel-7-server-rpms
    
    Important: In the example unattend file, specify the IP address of your satellite server and your organization based on our subscription service configuration.
    Add commands to update the host and to install and configure apache and php packages, for example:
    %packages
    @base
    @core
    @fonts
    @gnome-desktop
    @internet-browser
    @multimedia
    @x11
    @print-client
    -gnome-initial-setup
    
    #Add the Apache and PHP packages
    httpd
    mod_ssl 
    openssl 
    php 
    php-mysql 
    php-gd 
    %end 
    
    yum -y update
    
    systemctl enable httpd.service
    
    firewall-cmd --permanent --zone=public --add-service=http 
    firewall-cmd --permanent --zone=public --add-service=https
    firewall-cmd --reload
    
    echo "<?PHP 
    echo 'Hello World !! ';
    ?>" | tee /var/www/html/index.php
    
    sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.original
    
    sudo sed -i -e 's/^[ \t]*//' /etc/httpd/conf/httpd.conf
    sudo sed -i "s|IncludeOptional|#IncludeOptional|" /etc/httpd/conf/httpd.conf
    sudo sed -i "s|#ServerName www.example.com:80|ServerName localhost|" /etc/httpd/conf/httpd.conf
    sudo sed -i "s|DirectoryIndex index.html|DirectoryIndex index.html index.php|" /etc/httpd/conf/httpd.conf
    
    echo "AddType application/x-httpd-php .php" | tee -a /etc/httpd/conf/httpd.conf
    Note: The example unattend file modifies the default packages that are being installed with the kickstart file. It specifies the Apache and PHO packages as part of the %packages section.

    For ESXi and RHEL only, XClarity Administrator provides the #predefined.unattendSettings.networkConfig# macro, which adds all network settings that are defined in the UI to the unattend file, and the #predefined.unattendSettings.storageConfig# macro, which adds all storage settings that are defined in the UI to the unattend file. The example unattend file already contains these macros.

    XClarity Administrator also provides some basic convenience macros, such as OOB driver injection, status reporting, post-install scripts, custom software. However, to take advantage of these predefine macros, you must specify the following macros in the custom unattend file. The example file already contains the required macros.
    #predefined.unattendSettings.preinstallConfig#
    #predefined.unattendSettings.postinstallConfig#

    The example file already contains the required macros and additional predefined macros for dynamically specifying network settings for the target server and timezone. For more information about adding macros to unattend files, see Injecting predefined and custom macros to an unattend file.

    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.

    To import the custom unattend file, complete these steps.

    1. Click the Unattend Files 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_customUnattend.cfg).

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

  3. 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 custom unattend).

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

      3. Select Only unattend files 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, click Next.

    7. On the Unattend Files tab, select custom unattend file (for example, RHEL_installSoftware_customUnattend.cfg), and click Next.

    8. On the Installation Scripts tab, click Next.

    9. On the Summary tab, review the settings.

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

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

        • The network settings that you specify on the Network Settings dialog are added to the unattend file at runtime using the #predefined.hostPlatforms.networkSettings.<setting># macros.

      3. Select the custom OS-image profile (for example, <base_OS>|<timestamp>_Custom RHEL with software using custom unattend) from the drop-down list in the Image to Deploy column

        Note: Ensure that all target servers use the same custom profile.
      4. (Optional) Click the License Key icon (License key icon) and specify the license key to use to activate the operating system after it is installed.

      5. 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.
      6. 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 Custom Settings tab, click the Unattend and Configuration Settings subtab, and select the custom unattend file (for example, RHEL_installSoftware_customUnattend.cfg).


      Graphic showing initial setup screen for VMware ESXi
    5. On the Summary tab, review the settings.

    6. Click Deploy to deploy the operating system.