VMware vSphere has a guest customization feature to change some guest OS setting for VMs that are cloned of deployed from template. For example to change the computer name, network settings, or timezone settings.
Customizing guest operating systems helps prevent conflicts that occur if virtual machines with identical settings are deployed, for example conflicts due to duplicate computer names.
For Linux based VM there are two diffent type of guest OS customization engines:
- Perl based customization engine (the initial engine)
- cloud-init based customization engine (introduced in vSphere 7.0.3 and in the vSphere Client GUI in vSphere 8)
But which one is used and which could be preferred?
See KB 59557 on how to switch between these two engines, and vSphere Guest OS Customization has also added native support for using cloud-init since vSphere version 7.0 Update 3.
Note that there is also an option in the vSphere Client 8 to choose the type of customization:
To verify customization support for Windows operating systems or Linux distributions and compatible ESXi hosts, see the VMware Compatibility Guide at http://www.vmware.com/resources/compatibility.
Perl based customization engine
This engine can be used also with old OS or when cloud-init tool is not installed in the guest OS.
The possible customization parameters are limited to: hostname, DNS domain name, timezone, network settings, DNS settings.
You can also run an ad-hoc customization script that can have a pre-customization part and also a post-customization part, as provided in the the following example:
Prerequisites:
- Ensure that VMware Tools is installed
- Ensure that Perl is installed
- The guest operating system being customized must be installed on a disk attached as SCSI node 0:0 in the virtual machine configuration
- Customization of Windows guest operating systems requires the virtual machine to be running on an ESXi host running version 3.5 or later
Perl based customization engine is the default engine when cloud-init is not installed.
If cloud-init is installed, please follow below steps to make sure Perl based customization engine is used:
- Power-on and login to Linux virtual machine.
- Edit cloud-init configuration file /etc/cloud/cloud.cfg to remove below entry if it exists:
disable_vmware_customization: false
- Ensure that network configuration is disabled by creating file /etc/cloud/cloud.cfg.d/80_disable_network.cfg with below content:
network:
config: disabled
- Power-off Linux virtual machine.
cloud-init based customization engine
cloud-init supports different transports on VMware platform, this means that there are multiple ways to provide data to cloud-init, vSphere Guest OS Customization(cloud-init based customization and native cloud-init customization) is one of these ways, the other common ways are: seed ISO, Guestinfo OVF and Guestinfo Keys.
Is the most powerful and flexible way to customize a Linux based VM.
Solution 1:
Using cloud-init based customization
Prerequisites:
• Ensure that cloud-init based customization is used, see KB KB 59557.
• Ensure that VMware Tools version 10.3.5 or later is installed.
• Ensure that cloud-init version 18.4 or later is installed.
• Ensure that Datasource OVF (cloud-init ver < 23.1) or Datasource VMware (cloud-init ver >= 23.1) is included in cloud-init Datasource search list.
• Ensure that the virtual machine is a clean cloud-init instance by running “sudo cloud-init clean –seed”.
The cloud-init based customization converts Guest OS Customization Specification to metadata and provides it to cloud-init. If there was data provided by other transports at the same time, cloud-init will decide which transport shall be used so that only the data from that transport will be loaded. Please remove data from any other transports if metadata from Guest OS Customization Specification is not applied to virtual machine correctly.
Solution 2:
Using native cloud-init customization
Prerequisites:
• Ensure that vSphere version is 7.0 Update 3 or later.
• Ensure that VMware Tools version 11.3.0 or later is installed.
• Ensure that cloud-init version 21.1 or later is installed.
• Ensure that Datasource OVF (cloud-init ver < 23.1) or Datasource VMware (cloud-init ver >= 23.1) is included in cloud-init Datasource search list.
• Ensure that the virtual machine is a clean cloud-init instance by running “sudo cloud-init clean –seed”.
The native cloud-init customization is available since vSphere version 7.0 Update 3, both metadata and user data can be added to Guest OS Customization Specification and provided to cloud-init. If there was data provided by other transports at the same time, cloud-init will decide which transport shall be used so that only the data from that transport will be loaded. Please remove data from any other transports if metadata and user data from Guest OS Customization Specification are not applied to virtual machine correctly.
Steps:
- Power-on and login to Linux virtual machine.
- Edit cloud-init configuration file /etc/cloud/cloud.cfg to insert below entry at the bottom line:
disable_vmware_customization: false
- Ensure that network configuration is not disabled in cloud-init configuration files located at /etc/cloud/cloud.cfg or /etc/cloud/cloud.cfg.d/*.cfg.
For example, below configuration disables network configuration by cloud-init.
network:
config: disabled
Please comment out these 2 lines to enable network configuration by cloud-init.
#network:
#config: disabled
- Execute command ‘sudo cloud-init clean –seed’ to make sure virtual machine becomes a clean cloud-init instance.
- Power-off Linux virtual machine