vSphere 5.5 CentOS 7 Template Deployment: Fixing Failed Guest Customization for Network/Hostname Settings


2 views

When deploying CentOS 7 VMs from templates in vSphere 5.5 (pre-u3 builds), administrators frequently encounter a frustrating behavior where the guest customization appears to execute successfully on first boot, but then reverts to template settings after reboot. The most visible symptoms are:

  • Hostname reverting to original template value
  • Network interface configurations not persisting (despite correct settings in ifcfg-ether)
  • Missing expected ifcfg-e* files for the assigned NIC

The root cause lies in how vSphere 5.5's customization engine interacts with systemd-networkd in CentOS 7. The customization scripts execute properly, but the network manager service overwrites changes during subsequent boots.

Key technical background:

# Systemd behavior that interferes with customizations
systemctl status NetworkManager
systemctl status network

Here are three effective workarounds, depending on your environment constraints:

Option 1: Upgrade vSphere

VMware fixed this in:

  • vSphere 5.5 Update 3 (build 3000241+)
  • All vSphere 6.0+ releases

Option 2: Manual Post-Deployment Fix

For environments that can't upgrade immediately, add this to your templatize script:

#!/bin/bash
# Disable NetworkManager persistence
systemctl disable NetworkManager
systemctl enable network

# Ensure legacy network service starts first
ln -sf /lib/systemd/system/network.service \
       /etc/systemd/system/multi-user.target.wants/network.service

Option 3: Cloud-Init Alternative

For modern environments, consider replacing vSphere customization with cloud-init:

# Install cloud-init
yum install -y cloud-init

# Configure datasources
echo "datasource_list: [ VMware ]" > /etc/cloud/cloud.cfg.d/90_dpkg.cfg

Here's an enhanced version of the templatize script that handles these edge cases:

#!/bin/bash
# Network config cleanup
sed -i '/^$HWADDR\|UUID$=/d' /etc/sysconfig/network-scripts/ifcfg-*
rm -f /etc/udev/rules.d/70-persistent-net.rules

# Critical for vSphere customization
yum install -y net-tools open-vm-tools perl

# Host identification cleanup
>&2 echo "Removing SSH host keys"
rm -f /etc/ssh/ssh_host_*

# Log cleanup
logrotate -f /etc/logrotate.conf
journalctl --vacuum-time=1s

# Prepare for cloning
waagent -deprovision+user -force

After deployment, verify these critical items:

# Check hostname persistence
hostnamectl status

# Verify network config
ls -l /etc/sysconfig/network-scripts/ifcfg-e*
ip addr show

# Check customization log
grep -i custom /var/log/messages

When deploying CentOS 7 VMs from templates in vSphere 5.5 (pre-update 3), administrators frequently encounter a frustrating issue where customization appears to partially succeed but then reverts after reboot. The symptoms typically manifest as:

  • Correct hostname appears briefly during first boot
  • Customization scripts execute but don't persist
  • System reverts to template's original hostname after reboot
  • Network interface configurations (/etc/sysconfig/network-scripts/ifcfg-eth*) fail to apply properly

The core issue stems from vSphere 5.5's incomplete integration with systemd and NetworkManager in CentOS 7. The customization agent (vmware-guestd) attempts to:

1. Set hostname via traditional methods (/etc/hostname)
2. Configure network interfaces using legacy ifcfg-eth* files
3. Trigger network service restart

However, CentOS 7's systemd expects hostname changes through hostnamectl, and NetworkManager often overwrites manual ifcfg-eth* configurations during reboot.

Option 1: Upgrade Your vSphere

VMware officially fixed these issues in:

  • vSphere 5.5 Update 3 (build 3000241+)
  • vSphere 6.0 and later

Option 2: Manual Workaround Script

For environments stuck on older vSphere versions, add this to your template preparation script:

#!/bin/bash
# Force systemd to recognize hostname changes
echo "PreserveHostname=yes" >> /etc/cloud/cloud.cfg

# Disable NetworkManager interference
sed -i 's/NM_CONTROLLED=.*/NM_CONTROLLED=no/' /etc/sysconfig/network-scripts/ifcfg-*

# Ensure traditional networking
systemctl disable NetworkManager
systemctl enable network

Option 3: Post-Deployment Automation

Create a first-boot script in your template's /etc/rc.local:

#!/bin/bash
# Wait for customization to complete
while [ ! -f /tmp/.vmware_guest_customization ]; do
    sleep 5
done

# Apply persistent hostname
hostnamectl set-hostname $(cat /etc/hostname)

# Rebuild network config
for iface in $(ls /sys/class/net/ | grep -v lo); do
    mac=$(cat /sys/class/net/$iface/address)
    cat > /etc/sysconfig/network-scripts/ifcfg-$iface <

Building on VMware's CentOS 7 guidelines, ensure your template includes:

yum install -y open-vm-tools net-tools
systemctl enable vmtoolsd
echo -n > /etc/machine-id
rm -f /etc/ssh/ssh_host_*
rm -f /etc/udev/rules.d/70*
sed -i '/^(HWADDR|UUID)=/d' /etc/sysconfig/network-scripts/ifcfg-eth0
cloud-init clean

Always verify network configurations persist through multiple reboots before finalizing the template.