Is there a way to get metadata (i.e. VM Name, Annotations, etc.) from within the Guest OS? I'm using a Ubuntu JeOS template and want to run a script on startup which configures new VMs according to the metadata. This is on VMWare ESX.
Is there a way to get metadata (i.e. VM Name, Annotations, etc.) from within the Guest OS? I'm using a Ubuntu JeOS template and want to run a script on startup which configures new VMs according to the metadata. This is on VMWare ESX.
I imagine you could use the vSphere SDK for Perl inside your VM to query those items:
http://www.vmware.com/support/developer/viperltoolkit/
You could ask here:
You can set a VM's
guestinfo
property from the outside (e.g. withgovc
) and query it from the inside (requiring open-vm-tools):Outside:
Inside:
Source: https://www.virtuallyghetto.com/2011/01/how-to-extract-host-information-from.html, RedHat's OpenShift on vSphere Installation Guide
You can obtain some information (most importan, the VM UUID) by running
dmidecode
from inside the Guest OS. For example:I'm not aware of any published APIs that allow you to do this with ESX but I am also aware that VMWare have private APIs - fingers crossed they open them up soon.
You can install ansible & pyvmomi & then use module vsphere_guest or community.vmware.vmware_guest ( preferred )
https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_guest_module.html
or
https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_vm_info_module.html
Adding to Fuero's answer, I've used ansible and rc.local previously to configure VMs via guestfacts
ansible vm config
rc.local
Nowadays instead of vSphere SDK for Perl there is PowerCLI, based on MS's Powershell. You can get any kind of information and change settings regarding VMs, hosts, clusters, and eveything else VMware related.
PowerCLI's VM cmdlets