Appendix C. 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: Latest RHEL 9 KVM Guest Image Latest RHEL 8 KVM Guest 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 Composing a customized Red Hat Enterprise Linux 9 Image or Composing a customized Red Hat Enterprise Linux 8 Image . C.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: Install the following command line tools: Note In the following procedures, enter all commands with the [root@host]# prompt on the workstation that hosts the libvirt environment. C.2. Supported clients in registration Satellite supports the following operating systems and architectures for registration. Supported host operating systems The hosts can use the following operating systems: Red Hat Enterprise Linux 9, 8, 7 Red Hat Enterprise Linux 6 with the ELS Add-On Supported host architectures The hosts can use the following architectures: i386 x86_64 s390x ppc_64 C.3. Configuring a host for registration Configure your host for registration to Satellite Server or Capsule Server. You can use a configuration management tool to configure multiple hosts at once. Prerequisites The host must be using a supported operating system. For more information, see Section C.2, "Supported clients in registration" . The system clock on your Satellite Server and any Capsule Servers must be synchronized across the network. If the system clock is not synchronized, SSL certificate verification might fail. For example, you can use the Chrony suite for timekeeping. Procedure Enable and start a time-synchronization tool on your host. The host must be synchronized with the same NTP server as Satellite Server and any Capsule Servers. On Red Hat Enterprise Linux 7 and later: On Red Hat Enterprise Linux 6: Deploy the SSL CA file on your host so that the host can make a secured registration call. Find where Satellite stores the SSL CA file by navigating to Administer > Settings > Authentication and locating the value of the SSL CA file setting. Transfer the SSL CA file to your host securely, for example by using scp . Login to your host by using SSH. Copy the certificate to the truststore: Update the truststore: C.4. Registering a host You can register a host by using registration templates and set up various integration features and host tools during the registration process. Prerequisites Your Satellite account has the Register hosts role assigned or a role with equivalent permissions. You must have root privileges on the host that you want to register. You have configured the host for registration. For more information, see Section C.3, "Configuring a host for registration" . An activation key must be available for the host. For more information, see Managing Activation Keys in Managing content . Optional: If you want to register hosts to Red Hat Insights, you must synchronize the rhel-8-for-x86_64-baseos-rpms and rhel-8-for-x86_64-appstream-rpms repositories and make them available in the activation key that you use. This is required to install the insights-client package on hosts. Red Hat Satellite Client 6 repository for the operating system version of the host is synchronized on Satellite Server and enabled in the activation key you use. For more information, see Importing Content in Managing content . This repository is required for the remote execution pull client, Puppet agent, Tracer, and other tools. If you want to use Capsule Servers instead of your Satellite Server, ensure that you have configured your Capsule Servers accordingly. For more information, see Configuring Capsule for Host Registration and Provisioning in Installing Capsule Server . If your Satellite Server or Capsule Server is behind an HTTP proxy, configure the Subscription Manager on your host to use the HTTP proxy for connection. For more information, see How to access Red Hat Subscription Manager (RHSM) through a firewall or proxy in the Red Hat Knowledgebase . Procedure In the Satellite web UI, navigate to Hosts > Register Host . Enter the details for how you want the registered hosts to be configured. On the General tab, in the Activation Keys field, enter one or more activation keys to assign to hosts. Click Generate to generate a curl command. Run the curl command as root on the host that you want to register. After registration completes, any Ansible roles assigned to a host group you specified when configuring the registration template will run on the host. The registration details that you can specify include the following: On the General tab, in the Capsule field, you can select the Capsule to register hosts through. A Capsule behind a load balancer takes precedence over a Capsule selected in the Satellite web UI as the content source of the host. On the General tab, you can select the Insecure option to make the first call insecure. During this first call, the host downloads the CA file from Satellite. The host will use this CA file to connect to Satellite with all future calls making them secure. Red Hat recommends that you avoid insecure calls. If an attacker, located in the network between Satellite and a host, fetches the CA file from the first insecure call, the attacker will be able to access the content of the API calls to and from the registered host and the JSON Web Tokens (JWT). Therefore, if you have chosen to deploy SSH keys during registration, the attacker will be able to access the host using the SSH key. On the Advanced tab, in the Repositories field, you can list repositories to be added before the registration is performed. You do not have to specify repositories if you provide them in an activation key. On the Advanced tab, in the Token lifetime (hours) field, you can change the validity duration of the JSON Web Token (JWT) that Satellite uses for authentication. The duration of this token defines how long the generated curl command works. Note that Satellite applies the permissions of the user who generates the curl command to authorization of hosts. If the user loses or gains additional permissions, the permissions of the JWT change too. Therefore, do not delete, block, or change permissions of the user during the token duration. The scope of the JWTs is limited to the registration endpoints only and cannot be used anywhere else. CLI procedure Use the hammer host-registration generate-command to generate the curl command to register the host. On the host that you want to register, run the curl command as root . For more information, see the Hammer CLI help with hammer host-registration generate-command --help . Ansible procedure Use the redhat.satellite.registration_command module. For more information, see the Ansible module documentation with ansible-doc redhat.satellite.registration_command . API procedure Use the POST /api/registration_commands resource. For more information, see the full API reference at https://satellite.example.com/apidoc/v2.html . C.5. Installing and configuring Puppet agent manually You can install and configure the Puppet agent on a host manually. A configured Puppet agent is required on the host for Puppet integration with your Satellite. For more information about Puppet, see Managing configurations using Puppet integration . Prerequisites Puppet must be enabled in your Satellite. For more information, see Enabling Puppet Integration with Satellite in Managing configurations using Puppet integration . The host must have a Puppet environment assigned to it. Red Hat Satellite Client 6 repository for the operating system version of the host is synchronized on Satellite Server, available in the content view and the lifecycle environment of the host, and enabled for the host. For more information, see Changing the repository sets status for a host in Satellite in Managing content . Procedure Log in to the host as the root user. Install the Puppet agent package. On hosts running Red Hat Enterprise Linux 8 and above: On hosts running Red Hat Enterprise Linux 7 and below: Add the Puppet agent to PATH in your current shell using the following script: Configure the Puppet agent. Set the environment parameter to the name of the Puppet environment to which the host belongs: Start the Puppet agent service: Create a certificate for the host: In the Satellite web UI, navigate to Infrastructure > Capsules . From the list in the Actions column for the required Capsule Server, select Certificates . Click Sign to the right of the required host to sign the SSL certificate for the Puppet agent. On the host, run the Puppet agent again: C.6. Completing the Red Hat Enterprise Linux 7 image Procedure Update the system: Install the cloud-init packages: Open the /etc/cloud/cloud.cfg configuration file: Under the heading cloud_init_modules , add: 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. Open the /etc/sysconfig/network file: Add the following line to avoid problems accessing the EC2 metadata service: Un-register the virtual machine so that the resulting image does not contain the same subscription details for every instance cloned based on it: Power off the instance: On your Red Hat Enterprise Linux Workstation, connect to the terminal as the root user and navigate to the /var/lib/libvirt/images/ directory: Reset and clean the image using the virt-sysprep command so it can be used to create instances without issues: 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: This creates a new rhel7-cloud.qcow2 file in the location where you enter the command. C.7. Completing the Red Hat Enterprise Linux 6 image Procedure Update the system: Install the cloud-init packages: Edit the /etc/cloud/cloud.cfg configuration file and under cloud_init_modules add: 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. To prevent network issues, create the /etc/udev/rules.d/75-persistent-net-generator.rules file as follows: 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: Un-register the virtual machine so that the resulting image does not contain the same subscription details for every instance cloned based on it: Power off the instance: 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: 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: 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. C.7.1. 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. C.8. 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.

Commands:
yum install virt-manager virt-viewer libvirt qemu-kvm
yum install virt-install libguestfs-tools-c
systemctl enable --now chronyd
chkconfig --add ntpd chkconfig ntpd on service ntpd start
cp My_SSL_CA_file .pem /etc/pki/ca-trust/source/anchors
update-ca-trust
dnf install puppet-agent
yum install puppet-agent
. /etc/profile.d/puppet-agent.sh
puppet config set server satellite.example.com --section agent puppet config set environment My_Puppet_Environment --section agent
puppet resource service puppet ensure=running enable=true
puppet ssl bootstrap
puppet ssl bootstrap
yum update
yum install cloud-utils-growpart cloud-init
vi /etc/cloud/cloud.cfg
- resolv-conf
vi /etc/sysconfig/network
NOZEROCONF=yes
subscription-manager repos --disable=* subscription-manager unregister
poweroff
cd /var/lib/libvirt/images/
virt-sysprep -d rhel7
virt-sparsify --compress rhel7.qcow2 rhel7-cloud.qcow2
yum update
yum install cloud-utils-growpart cloud-init
- resolv-conf
echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rules
NOZEROCONF=yes
subscription-manager repos --disable=* subscription-manager unregister yum clean all
poweroff
virt-sysprep -d rhel6
virt-sparsify --compress rhel6.qcow2 rhel6-cloud.qcow2