Redhat Enterprise Linux 9 Template Fails to Retain Hostname
search cancel

Redhat Enterprise Linux 9 Template Fails to Retain Hostname

book

Article ID: 379575

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • When deploying a RHEL9 virtual machine from a template, a computer name is specified in Cloud Director to match the desired name. However, after deployment, the RHEL9 virtual machine does not reflect the specified computer name. 
  • Instead, the VM shows the template's raw image name as the hostname rather then the intended name.

Environment

Cloud Director 10.3.3.4

Resolution

Steps to Check Configuration in Cloud Director 10.3 and RHEL9

To resolve the issue of the hostname not being retained, follow these steps to verify both the VCD configuration and the RHEL9 VM settings:

 

1. Verify the VM customization in VCD 10.3

  • Log into the Cloud Director portal
  • Navigate to the affected VM
  • Go to Actions > Guest OS Customization
  • Ensure that Enable Guest Customization is enabled.
  • Confirm that the specified names are correct in the settings.
  • If changes are made, save the settings and redeploy the VM.

 

2. Check the cloud-init Configuration on the RHEL9 VM.

  • Access the RHEL9 VM via SSH or console.
  • Verify that cloud-init is installed and running by executing:
systemctl status cloud-init
  • Check the cloud-init logs for any errors related to hostname configuration:
less /var/log/cloud-init.log
less /var/log/cloud-init-output.log
  • Ensure that the cloud-init configuration file includes the correct settings for hostname customization:
cat /etc/cloud/cloud.cfg
  • Look for the following line and amend accordingly:
preserve_hostname: false

 

3. Validate the Network Configuration on RHEL9

  • Verify the current hostname of the VM by running:
hostnamectl
  • Confirm that the /etc/hostname file contains the correct hostname:
cat /etc/hostname

 

4. Reapply Customization

  • If any settings are incorrect or missing, update the VCD settings and restart the VM to apply the hostname.
  • You can also manually set the hostname on the VM using:
sudo hostnamectl set-hostname <hostname here>

 

5. Confirm Hostname Persistence

  • Restart the VM and verify that the hostname persists across reboots:
reboot
  • After the VM restarts, check the hostname again using:
hostnamectl

Additional Information

If the above steps do not resolve the issue, please reach out to Redhat Support.