This is the 18th day of my participation in the August Genwen Challenge.More challenges in August
Introduction to the
Unlock the features of vsphere’s custom specification manager today:
The vcenter custom specification manager allows you to customize vm template configuration information, such as the host name, IP address, gateway, and DOMAIN Name System (DNS), to facilitate vm installation.
The vsphere custom specification manager can be implemented in two ways. One is on the vsphere Client interface. The other is code level manipulation through the PyVmomi module.
We will first introduce the vsphere Client implementation today, and the PyVmomi method will be introduced later.
Environment to prepare
This article focuses on the customization of Cento7.5.
component | version | note |
---|---|---|
vCenter | 5.5.0-218311. | VCenter Server 5.5 Update 2b |
Centos | 7.5 | 192.168.3.253 |
Centos7.5 is a basic template that has been prepared in advance. The custom management specification is a custom modification to this template.
Reference links:
-
VCenter corresponds to the customized version of the operating system
Partnerweb.vmware.com/programs/gu…
-
Centos7 Installation Guide
Partnerweb.vmware.com/GOSIG/CentO…
Vsphere Client
1. Create a custom specification manager
The domain name localhost refers to the search for the domain name in the local hosts.
2. Customize Settings
The default gateway and subnet mask have been set. The time zone and DNS Settings can be configured according to actual conditions.
3. Deploy the VM from the template
1. Enter the VM name and select a folder, cluster, host, and storage
2. Select the custom specification Centos7.5 that we created
3. Enter the hostname (hostname). Enter a new IP address.
The VMS are cloned, customized, and restarted in sequence.
At this point, you might think that the hot custom virtual machine is complete, but the result is very disappointing:
- Hostname not set successfully;
- The IP address is not set successfully, but the nic configuration is OK (in some cases, the nic configuration of ifcfg-ether is added).
Why does this happen?
Let’s analyze it according to official data:
1. VCenter corresponds to the customized version of the operating system
The vCenter in the current test environment is 5.5U2 and supports centos6.x customization. So I used a Centos6.5 template for cloning, and the custom specification worked.
2. Log analysis
View the new vm log /var/log/vmware-imc/ toolsdeploypkg. log and the warning fails to identify the Centos7 OS version
From the above two points, vCenter5.5u2 can support rhel7, so can we change the version number of Centos7.5 to rhel7?
3. Modify the operating system version
We converted the template to a virtual machine and modified the Centos7.5 version information to convert it to a template:
rm -f /etc/redhat-release && touch /etc/redhat-release && echo Red Hat Enterprise Linux Server Release 7.0 (Maipo) > /etc/redhat-release
Copy the code
After the modification, clone the VM from the template to customize the host name and IP address. The customization process takes about 1 minute and 6 seconds.
4. Verify
(1) Operating system version information
The version information has been changed to RHEL7.
(2) Change the host name to we123 and automatically add it to the local hosts
Note at this point:
-
Three names are involved in template cloning: VM name, domain name, and computer name.
-
The vm name we set here is the same as the computer name, but if the domain name is set to test, the search domain name in hosts will be we123.test
(3) The IP address of the template has been changed from 192.168.3.253 to 192.168.3.254
conclusion
If we only occasionally mount the VM, the custom specification manager may not be useful, but if we automate the vm mount process, this feature can be a shortcut.
In the subsequent articles on operation and maintenance automation, we will introduce it in succession to give full play to the biggest advantages of this function.