Chapter 12. Provisioning virtual machines in VMware vSphere
VMware vSphere is an enterprise-level virtualization platform from VMware. Red Hat Satellite can interact with the vSphere platform, including creating new virtual machines and controlling their power management states.
12.1. Prerequisites for VMware provisioning Copy linkLink copied to clipboard!
Before you can deploy virtual machines to VMware vSphere, ensure that your environment meets the following requirements.
The requirements for VMware vSphere provisioning include:
A supported version of VMware vCenter Server. The following versions have been fully tested with Satellite:
- vCenter Server 8.0
- vCenter Server 7.0
- A Capsule Server managing a network on the vSphere environment. Ensure no other DHCP services run on this network to avoid conflicts with Capsule Server. For more information, see Chapter 2, Preparing networking.
- An existing VMware template if you want to use image-based provisioning.
- You can use synchronized content repositories for Red Hat Enterprise Linux. For more information, see Repository synchronization in Managing content.
- Provide an activation key for host registration. For more information, see Creating an activation key by using Satellite web UI in Managing content.
12.2. VMware user privileges Copy linkLink copied to clipboard!
The VMware vSphere server requires an administration-like user for Satellite Server communication. For security reasons, do not use the administrator user for such communication. Instead, create a user with the required privileges.
In VMware vCenter Server version 8.0 or 7.0, set the following privileges:
-
All Privileges
Datastore Allocate Space, Browse datastore, Update Virtual Machine files, Low level file operations -
All Privileges
Network Assign Network -
All Privileges
Resource Assign virtual machine to resource pool -
All Privileges
Virtual Machine Change Config (All) -
All Privileges
Virtual Machine Interaction (All) -
All Privileges
Virtual Machine Edit Inventory (All) -
All Privileges
Virtual Machine Provisioning (All) -
All Privileges
Virtual Machine Guest Operations (All)
If you want to create virtual machines with a Virtual Trusted Platform Module (TPM) for enhanced security, set the following privileges:
-
All Privileges
Cryptographic operations Clone, Encrypt, Encrypt new, Migrate, Register VM -
All Privileges
Cryptographic operations Direct Access – required to open a console session
12.3. Adding a VMware connection to Satellite Server by using Satellite web UI Copy linkLink copied to clipboard!
Use this procedure to add a VMware vSphere connection in Satellite Server’s compute resources.
Prerequisites
- Ensure that the host and network-based firewalls are configured to allow communication from Satellite Server to vCenter on TCP port 443.
- Verify that Satellite Server and vCenter can resolve each other’s host names.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources, and in the Compute Resources window, click Create Compute Resource.
- In the Name field, enter a name for the resource.
- From the Provider list, select VMware.
- In the Description field, enter a description for the resource.
- In the VCenter/Server field, enter the IP address or host name of the vCenter server.
- In the User field, enter the user name with permission to access the vCenter’s resources.
- In the Password field, enter the password for the user.
- Click Load Datacenters to populate the list of data centers from your VMware vSphere environment.
- From the Datacenter list, select a specific data center to manage from this list.
- In the Fingerprint field, ensure that this field is populated with the fingerprint from the data center.
- From the Display Type list, select a console type, for example, VNC or VMRC. Note that VNC consoles are unsupported on VMware ESXi 6.5 and later.
- Optional: In the VNC Console Passwords field, select the Set a randomly generated password on the display connection checkbox to secure console access for new hosts with a randomly generated password.
- From the Enable Caching list, you can select whether to enable caching of compute resources. For more information, see Section 12.17, “Caching of compute resources”.
- Click the Locations and Organizations tabs and verify that the values are automatically set to your current context. You can also add additional contexts.
- Click Submit to save the connection.
12.4. Adding a VMware connection to Satellite Server by using Hammer CLI Copy linkLink copied to clipboard!
Use this procedure to add a VMware vSphere connection to Satellite Server.
Prerequisites
- Ensure that the host and network-based firewalls are configured to allow communication from Satellite Server to vCenter on TCP port 443.
- Verify that Satellite Server and vCenter can resolve each other’s host names.
Procedure
Add a VMware connection to Satellite:
$ hammer compute-resource create \ --datacenter "My_Data_Center" \ --description "vSphere server at vsphere.example.com" \ --locations "My_Location" \ --name "My_vSphere" \ --organizations "My_Organization" \ --password "My_Password" \ --provider "Vmware" \ --server "vsphere.example.com" \ --user "My_User" \ --uuid "My_Data_Center_UUID"
12.5. Adding VMware images to Satellite Server by using Satellite web UI Copy linkLink copied to clipboard!
VMware vSphere uses templates as images for creating new virtual machines. If using image-based provisioning to create new hosts, you need to add VMware template details to your Satellite Server. This includes access details and the template name.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources.
- Select your VMware compute resource.
- Click Create Image.
- In the Name field, enter a name for the image.
- From the Operating System list, select the base operating system of the image.
- From the Architecture list, select the operating system architecture.
-
In the Username field, enter the SSH user name for image access. By default, this is set to
root. -
If your image supports user data input such as
cloud-initdata, click the User data checkbox. - Optional: In the Password field, enter the SSH password to access the image.
- From the Image list, select an image from VMware.
- Click Submit to save the image details.
12.6. Adding VMware images to Satellite Server by using Hammer CLI Copy linkLink copied to clipboard!
VMware vSphere uses templates as images for creating virtual machines. If you use image-based provisioning to create hosts, you must add VMware template details to your Satellite Server. This includes access details and the template name.
Procedure
Create an image. Use the
--uuidfield to store the relative template path on the vSphere environment:$ hammer compute-resource image create \ --architecture "My_Architecture" \ --compute-resource "My_VMware" --name "My_Image" \ --operatingsystem "My_Operating_System" \ --username root \ --uuid "My_UUID"
12.7. Adding VMware details to a compute profile by using Satellite web UI Copy linkLink copied to clipboard!
You can predefine certain hardware settings for virtual machines on VMware vSphere. You achieve this through adding these hardware settings to a compute profile.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Profiles.
- Select a compute profile.
- Select a VMware compute resource.
- In the CPUs field, enter the number of CPUs to allocate to the host.
- In the Cores per socket field, enter the number of cores to allocate to each CPU.
- In the Memory field, enter the amount of memory in MiB to allocate to the host.
- In the Firmware field, select the firmware type for the host. By default, this is set to Automatic.
- In the Cluster list, select the name of the target host cluster on the VMware environment.
- From the Resource pool list, select an available resource allocations for the host.
- In the Folder list, select the folder to organize the host.
- From the Guest OS list, select the operating system you want to use in VMware vSphere.
- From the Virtual H/W version list, select the underlying VMware hardware abstraction to use for virtual machines.
- If you want to add more memory while the virtual machine is powered on, select the Memory hot add checkbox.
- If you want to add more CPUs while the virtual machine is powered on, select the CPU hot add checkbox.
- If you want to add a CD-ROM drive, select the CD-ROM drive checkbox.
- From the Boot order list, define the order in which the virtual machines tried to boot.
- Optional: In the Annotation Notes field, enter an arbitrary description.
- If you use image-based provisioning, select the image from the Image list.
- From the SCSI controller list, select the disk access method for the host.
- If you want to use eager zero thick provisioning, select the Eager zero checkbox. By default, the disk uses lazy zero thick provisioning.
- Optional: Select Virtual TPM if you want to add a Virtual Trusted Platform Module for enhanced security. This is compatible with UEFI firmware only.
- From the Network Interfaces list, select the network parameters for the host’s network interface. At least one interface must point to a Capsule-managed network.
- Optional: Click Add Interface to create another network interfaces.
- Click Submit to save the compute profile.
12.8. Adding VMware details to a compute profile by using Hammer CLI Copy linkLink copied to clipboard!
You can predefine certain hardware settings for virtual machines on VMware vSphere. You achieve this through adding these hardware settings to a compute profile.
Procedure
Create a compute profile:
$ hammer compute-profile create --name "My_Compute_Profile"Set VMware details to a compute profile:
$ hammer compute-profile values create \ --compute-attributes "cpus=1,corespersocket=2,memory_mb=1024,cluster=MyCluster,path=MyVMs,virtual_tpm=true,start=true" \ --compute-profile "My_Compute_Profile" \ --compute-resource "My_VMware" \ --interface "compute_type=VirtualE1000,compute_network=mynetwork \ --volume "size_gb=20G,datastore=Data,name=myharddisk,thin=true"
12.9. Creating hosts on VMware by using Satellite web UI Copy linkLink copied to clipboard!
The VMware vSphere provisioning process provides the option to create hosts over a network connection or using an existing image.
For network-based provisioning, you must create a host to access either Satellite Server or Capsule Servers on a VMware vSphere virtual network, so that the host has access to PXE provisioning services. The new host entry triggers the VMware vSphere server to create the virtual machine. If the virtual machine detects the defined Capsule through the virtual network, the virtual machine boots to PXE and begins to install the chosen operating system.
Prerequisites
- If you use a virtual network on the VMware vSphere server for provisioning, ensure that you select a virtual network that does not provide DHCP assignments. This causes DHCP conflicts with Satellite Server when booting new hosts.
- For image-based provisioning, use the pre-existing image as a basis for the new volume.
Procedure
- In the Satellite web UI, navigate to Hosts > Create Host.
- In the Name field, enter a name for the host.
- Optional: Click the Organization tab and change the organization context to match your requirement.
- Optional: Click the Location tab and change the location context to match your requirement.
- From the Host Group list, select a host group that you want to assign your host to. That host group will populate the form.
- From the Deploy on list, select the VMware vSphere connection.
- From the Compute Profile list, select a profile to use to automatically populate virtual machine-based settings.
- Click the Interfaces tab, and on the interface of the host, click Edit.
Verify that the fields are populated with values. Note in particular:
- Satellite automatically assigns an IP address for the new host.
- Ensure that the MAC address field is blank. VMware assigns a MAC address to the host during provisioning.
- The Name from the Host tab becomes the DNS name.
- Ensure that Satellite automatically selects the Managed, Primary, and Provision options for the first interface on the host. If not, select them.
- In the interface window, review the VMware-specific fields that are populated with settings from our compute profile. Modify these settings to suit your needs.
Click OK to save. To add another interface, click Add Interface. You can select only one interface for Provision and Primary.
For more information about network interfaces, see Configuring network interfaces in Managing hosts.
- Click the Operating System tab, and confirm that all fields automatically contain values.
Select the Provisioning Method that you want:
- For network-based provisioning, click Network Based.
- For image-based provisioning, click Image Based.
- For boot-disk provisioning, click Boot disk based.
- Click Resolve in Provisioning templates to check the new host can identify the right provisioning templates to use.
- Click the Virtual Machine tab and confirm that these settings are populated with details from the host group and compute profile. Modify these settings to suit your requirements.
-
On the Parameters tab, click Add parameter. Add a parameter named
kt_activation_keys, select the string type, and enter the name of the activation key as the value. The activation key has to belong to the same organization as your host. You can also enter a comma-separated list of multiple activation keys. - Click Submit to provision your host on VMware.
12.10. Creating hosts on VMware by using the Hammer CLI Copy linkLink copied to clipboard!
The VMware vSphere provisioning process provides the option to create hosts over a network connection or using an existing image.
For network-based provisioning, you must create a host to access either Satellite Server or Capsule Servers on a VMware vSphere virtual network, so that the host has access to PXE provisioning services. The new host entry triggers the VMware vSphere server to create the virtual machine. If the virtual machine detects the defined Capsule through the virtual network, the virtual machine boots to PXE and begins to install the chosen operating system.
For more information about additional host creation parameters for this compute resource, enter the hammer host create --help command.
Prerequisites
- If you use a virtual network on the VMware vSphere server for provisioning, ensure that you select a virtual network that does not provide DHCP assignments. This causes DHCP conflicts with Satellite Server when booting new hosts.
- For image-based provisioning, use the pre-existing image as a basis for the new volume.
Procedure
Create the host by using one of the following methods:
Create the host from a network with the
hammer host createcommand and include--provision-method buildto use network-based provisioning:$ hammer host create \ --build true \ --compute-attributes="cpus=1,corespersocket=2,memory_mb=1024,cluster=MyCluster,path=MyVMs,start=true" \ --compute-resource "My_VMware" \ --enabled true \ --hostgroup "My_Host_Group" \ --interface "managed=true,primary=true,provision=true,compute_type=VirtualE1000,compute_network=mynetwork" \ --location "My_Location" \ --managed true \ --name "My_Host" \ --organization "My_Organization" \ --provision-method build \ --volume="size_gb=20G,datastore=Data,name=myharddisk,thin=true"Create the host from an image with the
hammer host createcommand and include--provision-method imageto use image-based provisioning:$ hammer host create \ --compute-attributes="cpus=1,corespersocket=2,memory_mb=1024,cluster=MyCluster,path=MyVMs,start=true" \ --compute-resource "My_VMware" \ --enabled true \ --hostgroup "My_Host_Group" \ --image "My_VMware_Image" \ --interface "managed=true,primary=true,provision=true,compute_type=VirtualE1000,compute_network=mynetwork" \ --location "My_Location" \ --managed true \ --name "My_Host" \ --organization "My_Organization" \ --provision-method image \ --volume="size_gb=20G,datastore=Data,name=myharddisk,thin=true"
12.11. VMware cloud-init provisioning overview Copy linkLink copied to clipboard!
When you set up the compute resource and images for VMware provisioning in Satellite, the following sequence of provisioning events occurs.
VMware cloud-init performs the following provisioning sequence:
- The user provisions one or more virtual machines using the Satellite web UI, API, or Hammer
- Satellite calls the VMware vCenter to clone the virtual machine template
-
Satellite
userdataprovisioning template adds customized identity information -
When provisioning completes, the
Cloud-initprovisioning template instructs the virtual machine to call back to Capsule whencloud-initruns - VMware vCenter clones the template to the virtual machine
- VMware vCenter applies customization for the virtual machine’s identity, including the host name, IP, and DNS
-
The virtual machine builds,
cloud-initis invoked and calls back Satellite on port80, which then redirects to443
Figure 12.1. VMware cloud-init provisioning overview
12.12. Associating the userdata and cloud-init templates with the operating system Copy linkLink copied to clipboard!
Before you can use VMware cloud-init and userdata templates for provisioning, you must associate these templates with your operating system.
Procedure
- In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates.
- Search for the CloudInit default template and click its name.
- Click the Association tab.
- Select all operating systems to which the template applies and click Submit.
- Repeat the steps above for the UserData open-vm-tools template.
- Navigate to Hosts > Provisioning Setup > Operating Systems.
- Select the operating system that you want to use for provisioning.
- Click the Templates tab.
- From the Cloud-init template list, select CloudInit default.
- From the User data template list, select UserData open-vm-tools.
- Click Submit to save the changes.
12.13. Preparing an image to use the cloud-init template Copy linkLink copied to clipboard!
To prepare an image, you must first configure the settings that you require on a virtual machine that you can then save as an image to use in Satellite.
Procedure
-
To use the
cloud-inittemplate for provisioning, you must configure a virtual machine so thatcloud-initis installed, enabled, and configured to call back to Satellite Server. - For security purposes, you must install a CA certificate to use HTTPS for all communication. This procedure includes steps to clean the virtual machine so that no unwanted information transfers to the image you use for provisioning.
-
If you have an image with
cloud-init, you must still follow this procedure to enablecloud-initto communicate with Satellite becausecloud-initis disabled by default.
12.14. Using VMware cloud-init and userdata templates for provisioning Copy linkLink copied to clipboard!
You can use VMware with the Cloud-init and Userdata templates to insert user data into the new virtual machine, to make further VMware customization, and to enable the VMware-hosted virtual machine to call back to Satellite.
You can use the same procedures to set up a VMware compute resource within Satellite, with a few modifications to the workflow.
Prerequisites
- Associate the templates with your operating system. For more information, see Section 12.12, “Associating the userdata and cloud-init templates with the operating system”.
- Prepare an image. For more information, see Section 12.13, “Preparing an image to use the cloud-init template”.
-
Configure port and firewall settings to open any necessary connections. Because of the
cloud-initservice, the virtual machine always calls back to Satellite even if you register the virtual machine to Capsule. For more information, see Port and firewall requirements in Installing Satellite Server in a connected network environment and Port and firewall requirements in Installing Capsule Server. If you want to use Capsule Servers instead of your Satellite Server, ensure that you have configured your Capsule Servers accordingly.
ImportantIt is essential to add your Capsule Server to the list of trusted proxies on Satellite Server!
For more information, see Configuring Capsule for host registration and provisioning in Installing Capsule Server.
Back up the following configuration files:
-
/etc/cloud/cloud.cfg.d/01_network.cfg -
/etc/cloud/cloud.cfg.d/10_datasource.cfg -
/etc/cloud/cloud.cfg
-
Procedure
On the virtual machine that you use to create the image, install the required packages:
# dnf install cloud-init open-vm-tools perl-interpreter perl-File-TempOn Red Hat Enterprise Linux 9, you also require the
dbus-toolspackage for network connectivity.Disable network configuration by
cloud-init:# cat << EOM > /etc/cloud/cloud.cfg.d/01_network.cfg network: config: disabled EOMConfigure
cloud-initto fetch data from Satellite:# cat << EOM > /etc/cloud/cloud.cfg.d/10_datasource.cfg datasource_list: [NoCloud] datasource: NoCloud: seedfrom: https://satellite.example.com/userdata/ EOMIf you intend to provision through Capsule Server, use the URL of your Capsule Server in the
seedfromoption, such ashttps://capsule.example.com:9090/userdata/.Configure modules to use in
cloud-init:# cat << EOM > /etc/cloud/cloud.cfg cloud_init_modules: - bootcmd - ssh cloud_config_modules: - runcmd cloud_final_modules: - scripts-per-once - scripts-per-boot - scripts-per-instance - scripts-user - phone-home system_info: distro: rhel paths: cloud_dir: /var/lib/cloud templates_dir: /etc/cloud/templates ssh_svcname: sshd EOMDownload the
katello-server-ca.crtfile from Satellite Server:# wget -O /etc/pki/ca-trust/source/anchors/cloud-init-ca.crt https://satellite.example.com/pub/katello-server-ca.crtIf you intend to provision through Capsule Server, download the file from your Capsule Server, such as
https://capsule.example.com/pub/katello-server-ca.crt.Update the record of certificates:
# update-ca-trust extractStop the
rsyslogandauditdservices:# systemctl stop rsyslog # systemctl stop auditdClean packages on the image:
On Red Hat Enterprise Linux 8 and later:
# dnf remove --oldinstallonlyOn Red Hat Enterprise Linux 7 and earlier:
# package-cleanup --oldkernels --count=1 # dnf clean all
Reduce logspace, remove old logs, and truncate logs:
# logrotate -f /etc/logrotate.conf # rm -f /var/log/*-???????? /var/log/*.gz # rm -f /var/log/dmesg.old # rm -rf /var/log/anaconda # cat /dev/null > /var/log/audit/audit.log # cat /dev/null > /var/log/wtmp # cat /dev/null > /var/log/lastlog # cat /dev/null > /var/log/grubbyRemove
udevhardware rules:# rm -f /etc/udev/rules.d/70*Remove the
ifcfgscripts related to existing network configurations:# rm -f /etc/sysconfig/network-scripts/ifcfg-ens* # rm -f /etc/sysconfig/network-scripts/ifcfg-eth*Remove the SSH host keys:
# rm -f /etc/ssh/ssh_host_*Remove root user’s SSH history:
# rm -rf ~root/.ssh/known_hostsRemove root user’s shell history:
# rm -f ~root/.bash_history # unset HISTFILE- Create an image from this virtual machine.
- Add your image to Satellite.
12.15. Deleting a VM on VMware Copy linkLink copied to clipboard!
You can delete VMs running on VMware from within Satellite.
By default, deleting a host entry associated with a virtual machine does not destroy the virtual machine on the compute resource.
To change the default behavior, navigate to Administer > Settings > Provisioning and set Destroy associated VM on host delete to Yes.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources.
- Select your VMware provider.
- On the Virtual Machines tab, click Delete from the Actions menu. This deletes the virtual machine from the VMware compute resource while retaining any associated hosts within Satellite. If you want to delete the orphaned host, navigate to Hosts > All Hosts and delete the host manually.
12.16. Importing a virtual machine from VMware into Satellite Copy linkLink copied to clipboard!
You can import existing virtual machines running on VMware into Satellite.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources.
- Select your VMware compute resource.
- On the Virtual Machines tab, click Import as managed Host or Import as unmanaged Host from the Actions menu. The following page looks identical to creating a host with the compute resource being already selected.
- Click Submit to import the virtual machine into Satellite.
12.17. Caching of compute resources Copy linkLink copied to clipboard!
Caching of compute resources speeds up rendering of VMware information.
12.17.1. Enabling caching of compute resources Copy linkLink copied to clipboard!
You can enable and disable caching of compute resources in the Satellite web UI.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources.
- Click the Edit button to the right of the VMware server you want to update.
- Select the Enable caching checkbox.
12.17.2. Refreshing the compute resources cache by using Satellite web UI Copy linkLink copied to clipboard!
Refresh the cache of compute resources to update compute resources information.
Procedure
- In the Satellite web UI, navigate to Infrastructure > Compute Resources.
- Select a VMware server you want to refresh the compute resources cache for and click Refresh Cache.
12.17.3. Refreshing the compute resources cache by using Hammer CLI Copy linkLink copied to clipboard!
Refresh the cache of compute resources to update compute resources information.
Procedure
Use this API call to refresh the compute resources cache:
# curl -H "Accept:application/json" \ -H "Content-Type:application/json" -X PUT \ -u username:password -k \ https://satellite.example.com/api/compute_resources/compute_resource_id/refresh_cacheUse
hammer compute-resource listto determine the ID of the VMware server you want to refresh the compute resources cache for.