3

We're building an environment in which VMs are automatically deployed. We need the VM its hostname to be identical to the VM name in vSphere (which is randomly being created). Is there a way to retrieve the vSphere/vCenter VM name from within the VM itself?

For now we're testing on Linux VMs, but eventually we'll also be deploying Windows Server VMs. VMwaretools is installed on the VMs.

tvlieg
  • 31
  • 2
  • 1
    I looked at this briefly and the answer I came up with was 'no', but I didn't put enough effort in to put that as a definitive answer. It seems daft that the Tools install doesn't create a environment variable called VMName or something equally soft that you could refer too but I couldn't find a way of doing it. The only alternative I could think of (that I didn't persue) was to work the other way; run a post deploy script in VMWare that identifies the machine IP and writes a simple text file to a standard location on the machine itself containing the VMWare name. – Patrick Oct 08 '15 at 14:47

1 Answers1

3

It depends on how your VM's are being deployed, but you can use a Customization Specification to automatically set many options, including the hostname. One of the options is to set the hostname equal to the VM name.

screenshot

D34DM347
  • 1,461
  • 2
  • 19
  • 32