Ce contenu n'est pas disponible dans la langue sélectionnée.
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
rootaccount in the image is disabled, butsudoaccess is granted to a special user namedcloud-user. -
There is no
rootpassword 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 Copier lienLien copié sur presse-papiers!
Prerequisites:
- Use a Linux host machine to create an image. In this example, we use a Red Hat Enterprise Linux 7 Workstation.
-
Use
virt-manageron 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-kvmand graphical tools:yum install virt-manager virt-viewer libvirt qemu-kvm
[root@host]# yum install virt-manager virt-viewer libvirt qemu-kvmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the following command line tools:
yum install virt-install libguestfs-tools-c
[root@host]# yum install virt-install libguestfs-tools-cCopy to Clipboard Copied! Toggle word wrap Toggle overflow
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 Copier lienLien copié sur presse-papiers!
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
Downloadsdirectory. Copy the Red Hat Enterprise Linux binary ISO file to the
/var/lib/libvirt/images/directory.cp ~/home/user/Downloads/rhel-server-7.4-x86_64-dvd.iso /var/lib/libvirt/images/
[root@host]# cp ~/home/user/Downloads/rhel-server-7.4-x86_64-dvd.iso /var/lib/libvirt/images/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that virtbr0 is the virtual bridge:
ip a
[root@host]# ip aCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start
libvirtd:systemctl start libvirtd
[root@host]# systemctl start libvirtdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to the
/var/lib/libvirt/images/directory:cd /var/lib/libvirt/images/
[root@host]# cd /var/lib/libvirt/images/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Prepare the QEMU image:
qemu-img create -f qcow2 rhel7.qcow2 8G
[root@host]# qemu-img create -f qcow2 rhel7.qcow2 8GCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the installation using
virt-install. Use the following example as a guide: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
[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=rhel7Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteFor GUI users, if the instance does not launch automatically, enter the
virt-managercommand to view the console:virt-manager
[root@host]# virt-managerCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
rootpassword.
-
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
# ip aCopy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that the hostname is correct:
hostname
# hostnameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
/etc/NetworkManager/conf.d/XX-cloud-image.conffile where XX is a two-digit number that indicates order of precedence. Add the following contents to the file:[main] dns=none
[main] dns=noneCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Proceed to Configuring a Host for Registration.
D.3. Creating a Red Hat Enterprise Linux 6 Image Copier lienLien copié sur presse-papiers!
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:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This launches an instance and starts the installation process.
NoteIf the instance does not launch automatically, enter the
virt-viewercommand to view the console:virt-viewer rhel6
[root@host]# virt-viewer rhel6Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
hostnamefor 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
rootuser. Update the
/etc/sysconfig/network-scripts/ifcfg-eth0file so it only contains the following values:TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=no
TYPE=Ethernet DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp NM_CONTROLLED=noCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the service network:
service network restart
# service network restartCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Proceed to Configuring a Host for Registration.
D.4. Configuring a Host for Registration Copier lienLien copié sur presse-papiers!
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
# chkconfig ntpd on; service ntpd startCopy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat Enterprise Linux 7:
systemctl enable chronyd; systemctl start chronyd
# systemctl enable chronyd; systemctl start chronydCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Ensure that the daemon
rhsmcertdis enabled and running on the hosts.For Red Hat Enterprise Linux 6:
chkconfig rhsmcertd on; service rhsmcertd start
# chkconfig rhsmcertd on; service rhsmcertd startCopy to Clipboard Copied! Toggle word wrap Toggle overflow For Red Hat Enterprise Linux 7:
systemctl start rhsmcertd
# systemctl start rhsmcertdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
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
# rpm -Uvh http://server.example.com/pub/katello-ca-consumer-latest.noarch.rpmCopy to Clipboard Copied! Toggle word wrap Toggle overflow
D.5. Registering a Host Copier lienLien copié sur presse-papiers!
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-attachfunction enabled. The feature is commonly used with hosts used as hypervisors. Ensure that the version of the
subscription-managerutility 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"
# subscription-manager register --org="My_Organization" --activationkey="MyKey"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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"
# 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 Copier lienLien copié sur presse-papiers!
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
Install the
katello-agentRPM package using the following command:yum install katello-agent
# yum install katello-agentCopy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure goferd is running:
systemctl start goferd
# systemctl start goferdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
D.7. Installing the Puppet Agent Copier lienLien copié sur presse-papiers!
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
# yum install puppetCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the puppet agent to start at boot:
On Red Hat Enterprise Linux 6:
chkconfig puppet on
# chkconfig puppet onCopy to Clipboard Copied! Toggle word wrap Toggle overflow On Red Hat Enterprise Linux 7:
systemctl enable puppet
# systemctl enable puppetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
D.8. Completing the Red Hat Enterprise Linux 7 image Copier lienLien copié sur presse-papiers!
Update the system:
yum update
# yum updateCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the
cloud-initpackages:yum install cloud-utils-growpart cloud-init
# yum install cloud-utils-growpart cloud-initCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open the
/etc/cloud/cloud.cfgconfiguration file:vi /etc/cloud/cloud.cfg
# vi /etc/cloud/cloud.cfgCopy to Clipboard Copied! Toggle word wrap Toggle overflow Under the heading
cloud_init_modules, add:- resolv-conf
- resolv-confCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
resolv-confoption automatically configures theresolv.confwhen an instance boots for the first time. This file contains information related to the instance such asnameservers,domainand other options.Open the
/etc/sysconfig/networkfile:vi /etc/sysconfig/network
# vi /etc/sysconfig/networkCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the following line to avoid problems accessing the EC2 metadata service:
NOZEROCONF=yes
NOZEROCONF=yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
# subscription-manager repos --disable=* # subscription-manager unregisterCopy to Clipboard Copied! Toggle word wrap Toggle overflow Power off the instance:
poweroff
# poweroffCopy to Clipboard Copied! Toggle word wrap Toggle overflow On your Red Hat Enterprise Linux Workstation, connect to the terminal as the root user and navigate to the
/var/lib/libvirt/images/directory:cd /var/lib/libvirt/images/
[root@host]# cd /var/lib/libvirt/images/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reset and clean the image using the
virt-sysprepcommand so it can be used to create instances without issues:virt-sysprep -d rhel7
[root@host]# virt-sysprep -d rhel7Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reduce image size using the
virt-sparsifycommand. This command converts any free space within the disk image back to free space within the host:virt-sparsify --compress rhel7.qcow2 rhel7-cloud.qcow2
[root@host]# virt-sparsify --compress rhel7.qcow2 rhel7-cloud.qcow2Copy to Clipboard Copied! Toggle word wrap Toggle overflow This creates a new
rhel7-cloud.qcow2file in the location where you enter the command.
D.9. Completing the Red Hat Enterprise Linux 6 image Copier lienLien copié sur presse-papiers!
Update the system:
yum update
# yum updateCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the
cloud-initpackages:yum install cloud-utils-growpart cloud-init
# yum install cloud-utils-growpart cloud-initCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
/etc/cloud/cloud.cfgconfiguration file and undercloud_init_modulesadd:- resolv-conf
- resolv-confCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
resolv-confoption automatically configures theresolv.confconfiguration 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.rulesfile as follows:echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rules
# echo "#" > /etc/udev/rules.d/75-persistent-net-generator.rulesCopy to Clipboard Copied! Toggle word wrap Toggle overflow This prevents
/etc/udev/rules.d/70-persistent-net.rulesfile from being created. If/etc/udev/rules.d/70-persistent-net.rulesis 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/networkto avoid problems accessing the EC2 metadata service:NOZEROCONF=yes
NOZEROCONF=yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
# subscription-manager repos --disable=* # subscription-manager unregister # yum clean allCopy to Clipboard Copied! Toggle word wrap Toggle overflow Power off the instance:
poweroff
# poweroffCopy to Clipboard Copied! Toggle word wrap Toggle overflow On your Red Hat Enterprise Linux Workstation, log in as root and reset and clean the image using the
virt-sysprepcommand so it can be used to create instances without issues:virt-sysprep -d rhel6
[root@host]# virt-sysprep -d rhel6Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reduce image size using the
virt-sparsifycommand. This command converts any free space within the disk image back to free space within the host:virt-sparsify --compress rhel6.qcow2 rhel6-cloud.qcow2
[root@host]# virt-sparsify --compress rhel6.qcow2 rhel6-cloud.qcow2Copy to Clipboard Copied! Toggle word wrap Toggle overflow This creates a new
rhel6-cloud.qcow2file 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 Copier lienLien copié sur presse-papiers!
- 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.