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.
For the KVM guest images:
-
The
root
account in the image is disabled, butsudo
access is granted to a special user namedcloud-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 withvirt-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
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.
-
Using your web browser, download the Red Hat Enterprise Linux binary ISO file to a temporary location, for example, the
Downloads
directory. 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/
Verify that virtbr0 is the virtual bridge:
[root@host]# ip a
Start
libvirtd
:[root@host]# systemctl start libvirtd
Navigate to the
/var/lib/libvirt/images/
directory:[root@host]# cd /var/lib/libvirt/images/
Prepare the QEMU image:
[root@host]# qemu-img create -f qcow2 rhel7.qcow2 8G
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
NoteFor GUI users, if the instance does not launch automatically, enter the
virt-manager
command to view the console:[root@host]# virt-manager
Follow the steps of the Red Hat Enterprise Linux installation wizard.
-
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/
- For the type of devices your installation uses, select Auto-detected installation media.
- For the type of installation destination, select Local Standard Disks.
- For other storage options, select Automatically configure partitioning.
- For software selection, select Minimal Install.
- Set the network interface to ON to ensure the interface activates on system start.
- Enter a host name, and click Apply.
-
Enter a
root
password.
-
For the installation source, add an HTTP link to your repository in Red Hat Satellite, for example
- When the installation completes, reboot the instance and log in as the root user.
Confirm that the network interface is up and that the IP address is assigned:
# ip a
Confirm that the hostname is correct:
# hostname
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
- 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.
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.
NoteIf the instance does not launch automatically, enter the
virt-viewer
command to view the console:[root@host]# virt-viewer rhel6
Set up the virtual machines as follows:
- At the initial Installer boot menu, select the Install or upgrade an existing system option.
- Select the appropriate Language and Keyboard options.
- When prompted about which type of devices your installation uses, select Basic Storage Devices.
-
Select a
hostname
for your device. The default host name islocalhost.localdomain
. - Set a root password.
- Based on the space on the disk, select the type of installation.
- Select the Basic Server install, which includes an SSH server.
-
Reboot the instance and log in as the
root
user. 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
Restart the service network:
# service network restart
- 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:
- Take note of the fully qualified domain name (FQDN) of the Satellite Server or Capsule Server, for example server.example.com.
- On the host, connect to a terminal on the host as the root user
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.- On the Red Hat Enterprise Linux Workstation, connect to a terminal as the root user.
Register the host using Red Hat Subscription Manager:
# subscription-manager register --org="My_Organization" --activationkey="MyKey"
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"
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.
- On Red Hat Satellite, select Hosts > Content Hosts.
- Select the name of the host that needs to be changed.
- In the Content Host Content section click the edit icon to the right of Release Version.
- Select "6.3" from the Release Version drop-down menu.
- 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. For more information about enabling Satellite Tools, see Installing the Katello Agent in Managing Hosts.
To Install the Katello Agent
Install the
katello-agent
RPM package using the following command:# yum install katello-agent
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.
Install the Puppet agent RPM package using the following command:
# yum install puppet
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
Update the system:
# yum update
Install the
cloud-init
packages:# yum install cloud-utils-growpart cloud-init
Open the
/etc/cloud/cloud.cfg
configuration file:# vi /etc/cloud/cloud.cfg
Under the heading
cloud_init_modules
, add:- resolv-conf
The
resolv-conf
option automatically configures theresolv.conf
when an instance boots for the first time. This file contains information related to the instance such asnameservers
,domain
and other options.Open the
/etc/sysconfig/network
file:# vi /etc/sysconfig/network
Add the following line to avoid problems accessing the EC2 metadata service:
NOZEROCONF=yes
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
Power off the instance:
# poweroff
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/
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
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
Update the system:
# yum update
Install the
cloud-init
packages:# yum install cloud-utils-growpart cloud-init
Edit the
/etc/cloud/cloud.cfg
configuration file and undercloud_init_modules
add:- resolv-conf
The
resolv-conf
option automatically configures theresolv.conf
configuration file when an instance boots for the first time. This file contains information related to the instance such asnameservers
,domain
, and other options.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).Add the following line to
/etc/sysconfig/network
to avoid problems accessing the EC2 metadata service:NOZEROCONF=yes
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
Power off the instance:
# poweroff
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
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.NoteYou 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.