Appendix D. Building Cloud Images for Red Hat Satellite


Use this section to build and register images to Red Hat Satellite.

You can use a preconfigured Red Hat Enterprise Linux KVM guest QCOW2 image:

These images contain cloud-init. To function properly, they must use ec2-compatible metadata services for provisioning an SSH key.

Note

For the KVM guest images:

  • The root account in the image is disabled, but sudo access is granted to a special user named cloud-user.
  • There is no root password set for this image.

The root password is locked in /etc/shadow by placing !! in the second field.

If you want to create custom Red Hat Enterprise Linux images, see Creating a Red Hat Enterprise Linux 7 Image and Creating a Red Hat Enterprise Linux 6 Image.

D.1. Creating Custom Red Hat Enterprise Linux Images

Prerequisites:

  • Use a Linux host machine to create an image. In this example, we use a Red Hat Enterprise Linux 7 Workstation.
  • Use virt-manager on your workstation to complete this procedure. If you create the image on a remote server, connect to the server from your workstation with virt-manager.
  • A Red Hat Enterprise Linux 7 or 6 ISO file (see Red Hat Enterprise Linux 7.4 Binary DVD or Red Hat Enterprise Linux 6.9 Binary DVD).

For more information about installing a Red Hat Enterprise Linux Workstation, see Red Hat Enterprise Linux 7 Installation Guide.

Before you can create custom images, install the following packages:

  • Install libvirt, qemu-kvm and graphical tools:

    [root@host]# yum install virt-manager virt-viewer libvirt qemu-kvm
  • Install the following command line tools:

    [root@host]# yum install virt-install libguestfs-tools-c
Note

In the following procedures, enter all commands with the [root@host]# prompt on the workstation that hosts the libvirt environment.

D.2. Creating a Red Hat Enterprise Linux 7 Image

Use this section to create an image in the QCOW2 format using a Red Hat Enterprise Linux 7 ISO file.

  1. Using your web browser, download the Red Hat Enterprise Linux binary ISO file to a temporary location, for example, the Downloads directory.
  2. Copy the Red Hat Enterprise Linux binary ISO file to the /var/lib/libvirt/images/ directory.

    [root@host]# cp ~/home/user/Downloads/rhel-server-7.4-x86_64-dvd.iso /var/lib/libvirt/images/
  3. Verify that virtbr0 is the virtual bridge:

    [root@host]# ip a
  4. Start libvirtd:

    [root@host]# systemctl start libvirtd
  5. Navigate to the /var/lib/libvirt/images/ directory:

    [root@host]# cd /var/lib/libvirt/images/
  6. Prepare the QEMU image:

    [root@host]# qemu-img create -f qcow2 rhel7.qcow2 8G
  7. Start the installation using virt-install. Use the following example as a guide:

    [root@host]# virt-install --virt-type qemu --name rhel7 --ram 2048 \
    --cdrom rhel-server-7.4-x86_64-dvd.iso \
    --disk rhel7.qcow2,format=qcow2 \
    --network=bridge:virbr0 --graphics vnc,listen=0.0.0.0 \
    --noautoconsole --os-type=linux --os-variant=rhel7
    Note

    For GUI users, if the instance does not launch automatically, enter the virt-manager command to view the console:

    [root@host]# virt-manager
  8. Follow the steps of the Red Hat Enterprise Linux installation wizard.

    1. For the installation source, add an HTTP link to your repository in Red Hat Satellite, for example satellite.example.com/pub/export/RHEL7/content/dist/rhel/server/7/7Server/x86_64/os/
    2. For the type of devices your installation uses, select Auto-detected installation media.
    3. For the type of installation destination, select Local Standard Disks.
    4. For other storage options, select Automatically configure partitioning.
    5. For software selection, select Minimal Install.
    6. Set the network interface to ON to ensure the interface activates on system start.
    7. Enter a host name, and click Apply.
    8. Enter a root password.
  9. When the installation completes, reboot the instance and log in as the root user.
  10. Confirm that the network interface is up and that the IP address is assigned:

    # ip a
  11. Confirm that the hostname is correct:

    # hostname
  12. Create a /etc/NetworkManager/conf.d/XX-cloud-image.conf file where XX is a two-digit number that indicates order of precedence. Add the following contents to the file:

    [main]
    dns=none
  13. Proceed to Configuring a Host for Registration.

D.3. Creating a Red Hat Enterprise Linux 6 Image

Use this section to create an image in the QCOW2 format using a Red Hat Enterprise Linux 6 ISO file.

  1. Start the installation using virt-install:

    [root@host]# qemu-img create -f qcow2 rhel6.qcow2 4G
    [root@host]# virt-install --connect=qemu:///system --network=bridge:virbr0 \
    --name=rhel6 --os-type linux --os-variant rhel6 \
    --disk path=rhel6.qcow2,format=qcow2,size=10,cache=none \
    --ram 4096 --vcpus=2 --check-cpu --accelerate \
    --hvm --cdrom=rhel-server-6.8-x86_64-dvd.iso

    This launches an instance and starts the installation process.

    Note

    If the instance does not launch automatically, enter the virt-viewer command to view the console:

    [root@host]# virt-viewer rhel6
  2. Set up the virtual machines as follows:

    1. At the initial Installer boot menu, select the Install or upgrade an existing system option.
    2. Select the appropriate Language and Keyboard options.
    3. When prompted about which type of devices your installation uses, select Basic Storage Devices.
    4. Select a hostname for your device. The default host name is localhost.localdomain.
    5. Set a root password.
    6. Based on the space on the disk, select the type of installation.
    7. Select the Basic Server install, which includes an SSH server.
  3. Reboot the instance and log in as the root user.
  4. Update the /etc/sysconfig/network-scripts/ifcfg-eth0 file so it only contains the following values:

    TYPE=Ethernet
    DEVICE=eth0
    ONBOOT=yes
    BOOTPROTO=dhcp
    NM_CONTROLLED=no
  5. Restart the service network:

    # service network restart
  6. Proceed to Configuring a Host for Registration.

D.4. Configuring a Host for Registration

Red Hat Enterprise Linux virtual machines register to Customer Portal Subscription Management by default. You must update each virtual machine configuration so that they receive updates from the correct Satellite Server or Capsule Server.

Prerequisites

  • Hosts must be using the following Red Hat Enterprise Linux version:

    • 6.4 or later
    • 7.0 or later
  • All architectures of Red Hat Enterprise Linux are supported (i386, x86_64, s390x, ppc_64).
  • Ensure that a time synchronization tool is enabled and runs on the Satellite Servers, any Capsule Servers, and the hosts.

    • For Red Hat Enterprise Linux 6:

      # chkconfig ntpd on; service ntpd start
    • For Red Hat Enterprise Linux 7:

      # systemctl enable chronyd; systemctl start chronyd
  • Ensure that the daemon rhsmcertd is enabled and running on the hosts.

    • For Red Hat Enterprise Linux 6:

      # chkconfig rhsmcertd on; service rhsmcertd start
    • For Red Hat Enterprise Linux 7:

      # systemctl start rhsmcertd

To Configure a Host for Registration:

  1. Take note of the fully qualified domain name (FQDN) of the Satellite Server or Capsule Server, for example server.example.com.
  2. On the host, connect to a terminal on the host as the root user
  3. Install the consumer RPM from the Satellite Server or Capsule Server to which the host is to be registered. The consumer RPM updates the content source location of the host and allows the host to download content from the content source specified in Red Hat Satellite.

    # rpm -Uvh http://server.example.com/pub/katello-ca-consumer-latest.noarch.rpm

D.5. Registering a Host

Prerequisites

  • Ensure that an activation key that is associated with the appropriate content view and environment exists for the host. For more information, see Managing Activation Keys in the Content Management Guide. By default, an activation key has the auto-attach function enabled. The feature is commonly used with hosts used as hypervisors.
  • Ensure that the version of the subscription-manager utility is 1.10 or higher. The package is available in the standard Red Hat Enterprise Linux repository.

    1. On the Red Hat Enterprise Linux Workstation, connect to a terminal as the root user.
    2. Register the host using Red Hat Subscription Manager:

      # subscription-manager register --org="My_Organization" --activationkey="MyKey"
Note

You can use the --environment option to override the content view and life cycle environment defined by the activation key. For example, to register a host to the content view "MyView" in a "Development" life cycle environment:

# subscription-manager register --org="My_Organization" \
--environment=Development/MyView \
--activationkey="MyKey"
Note

For Red Hat Enterprise Linux 6.3 hosts, the release version defaults to Red Hat Enterprise Linux 6 Server and must point to the 6.3 repository.

  1. On Red Hat Satellite, select Hosts > Content Hosts.
  2. Select the name of the host that needs to be changed.
  3. In the Content Host Content section click the edit icon to the right of Release Version.
  4. Select "6.3" from the Release Version drop-down menu.
  5. Click Save.

D.6. Installing the Katello Agent

Use the following procedure to install the Katello agent on a host registered to Satellite 6. The katello-agent package depends on the gofer package that provides the goferd service. This service must be enabled so that the Red Hat Satellite Server or Capsule Server can provide information about errata that are applicable for content hosts.

Prerequisites

The Satellite Tools repository must be enabled, synchronized to the Red Hat Satellite Server, and made available to your hosts as it provides the required packages.

To Install the Katello Agent

  1. Install the katello-agent RPM package using the following command:

    # yum install katello-agent
  2. Ensure goferd is running:

    # systemctl start goferd

D.7. Installing the Puppet Agent

Use this section to install and configure the Puppet agent on a host. When you have correctly installed and configured the Puppet agent, you can navigate to Hosts > All hosts to list all hosts visible to Red Hat Satellite Server.

  1. Install the Puppet agent RPM package using the following command:

    # yum install puppet
  2. Configure the puppet agent to start at boot:

    On Red Hat Enterprise Linux 6:

    # chkconfig puppet on

    On Red Hat Enterprise Linux 7:

    # systemctl enable puppet

D.8. Completing the Red Hat Enterprise Linux 7 image

  1. Update the system:

    # yum update
  2. Install the cloud-init packages:

    # yum install cloud-utils-growpart cloud-init
  3. Open the /etc/cloud/cloud.cfg configuration file:

    # vi /etc/cloud/cloud.cfg
  4. Under the heading cloud_init_modules, add:

    - resolv-conf

    The resolv-conf option automatically configures the resolv.conf when an instance boots for the first time. This file contains information related to the instance such as nameservers, domain and other options.

  5. Open the /etc/sysconfig/network file:

    # vi /etc/sysconfig/network
  6. Add the following line to avoid problems accessing the EC2 metadata service:

    NOZEROCONF=yes
  7. Un-register the virtual machine so that the resulting image does not contain the same subscription details for every instance cloned based on it:

    # subscription-manager repos --disable=*
    # subscription-manager unregister
  8. Power off the instance:

    # poweroff
  9. On your Red Hat Enterprise Linux Workstation, connect to the terminal as the root user and navigate to the /var/lib/libvirt/images/ directory:

    [root@host]# cd /var/lib/libvirt/images/
  10. Reset and clean the image using the virt-sysprep command so it can be used to create instances without issues:

    [root@host]# virt-sysprep -d rhel7
  11. Reduce image size using the virt-sparsify command. This command converts any free space within the disk image back to free space within the host:

    [root@host]# virt-sparsify --compress rhel7.qcow2 rhel7-cloud.qcow2

    This creates a new rhel7-cloud.qcow2 file in the location where you enter the command.

D.9. Completing the Red Hat Enterprise Linux 6 image

  1. Update the system:

    # yum update
  2. Install the cloud-init packages:

    # yum install cloud-utils-growpart cloud-init
  3. Edit the /etc/cloud/cloud.cfg configuration file and under cloud_init_modules add:

    - resolv-conf

    The resolv-conf option automatically configures the resolv.conf configuration file when an instance boots for the first time. This file contains information related to the instance such as nameservers, domain, and other options.

  4. To prevent network issues, create the /etc/udev/rules.d/75-persistent-net-generator.rules file as follows:

    # echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rules

    This prevents /etc/udev/rules.d/70-persistent-net.rules file from being created. If /etc/udev/rules.d/70-persistent-net.rules is created, networking might not function properly when booting from snapshots (the network interface is created as "eth1" rather than "eth0" and IP address is not assigned).

  5. Add the following line to /etc/sysconfig/network to avoid problems accessing the EC2 metadata service:

    NOZEROCONF=yes
  6. Un-register the virtual machine so that the resulting image does not contain the same subscription details for every instance cloned based on it:

    # subscription-manager repos --disable=*
    # subscription-manager unregister
    # yum clean all
  7. Power off the instance:

    # poweroff
  8. On your Red Hat Enterprise Linux Workstation, log in as root and reset and clean the image using the virt-sysprep command so it can be used to create instances without issues:

    [root@host]# virt-sysprep -d rhel6
  9. Reduce image size using the virt-sparsify command. This command converts any free space within the disk image back to free space within the host:

    [root@host]# virt-sparsify --compress rhel6.qcow2 rhel6-cloud.qcow2

    This creates a new rhel6-cloud.qcow2 file in the location where you enter the command.

    Note

    You must manually resize the partitions of instances based on the image in accordance with the disk space in the flavor that is applied to the instance.

D.10. Next steps

  • Repeat the procedures for every image that you want to provision with Satellite.
  • Move the image to the location where you want to store for future use.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.