This article provides information on creating guest customization scripts for Linux virtual machines that will be applied before and after customization.
VMware vSphere ESXi 7.x
VMware vSphere ESXi 8.0.x
The customization script could be defined in “Customization script” page of a customization specification for Linux, the script:
Sample customization scripts for Linux virtual machines:
A Linux sample Shell script
#!/bin/sh
if [ x$1 = x"precustomization" ]; then
echo "Do Precustomization tasks"
elif [ x$1 = x"postcustomization" ]; then
echo "Do Postcustomization tasks"
fi
A Linux sample Python script
#!/usr/bin/env python
import sys
if sys.argv[1] == "precustomization":
print "Do Precustomization tasks"
elif sys.argv[1] == "postcustomization":
print "Do Postcustomization tasks"
A Linux sample Perl script
#!/usr/bin/perl
if ($ARGV[0] eq "precustomization") {
print "Do Precustomization tasks";
}
elsif ($ARGV[0] eq "postcustomization") {
print "Do Postcustomization tasks";
}
Note:
1. The length of customization script cannot be greater than 1500 characters in vSphere 7.x, this length
limitation has been increased to 65536 characters in vSphere 8.x.
2. The error in customization script can cause the customization failure, so please verify your customization
script in your VM before using it to customize the VM. Follow below steps as root to do the verification.
2.1 Save your script in a text, e.g. customization_script
2.2 Add execute permission for customization_script
chmod +x customization_script
2.3 Verify the script by below commands
./customization_script precustomization
./customization_script postcustomization