Cloud-init and OVA
For VMWare’s vSphere the userdata is injected into the VM as an ISO via the cdrom. This can be done using the vSphere dashboard by connecting an ISO image to the CD/DVD drive.
To pass this example script to cloud-init running in a vSphere VM set the CD/DVD drive when creating the vSphere VM to point to an ISO on the data store.
Note: The ISO must contain the user data.
For example, to pass the same simple_script.bash to vSphere:
Create the ISO
% mkdir my-iso
NOTE: The file name on the ISO must be: user-data.txt
% cp simple_scirpt.bash my-iso/user-data.txt
% genisoimage -o user-data.iso -r my-iso
Verify the ISO
% sudo mkdir /media/vsphere_iso
% sudo mount -o loop JoeV_CI_02.iso /media/vsphere_iso
% cat /media/vsphere_iso/user-data.txt
% sudo umount /media/vsphere_iso
Then, launch the vSphere VM the ISO user-data.iso attached as a CDROM.
It is also possible to launch a vSphere VM and pass optional user data to it using the Delta Cloud.
For more information on Delta Cloud see: http://deltacloud.apache.org
Related videos on Youtube
Dinko Ivanov
Updated on September 18, 2022Comments
-
Dinko Ivanov almost 2 years
I've been here many times searching and finding great solutions for my work. Thanks! Now I'm asking my first question here:
I have an OVA file (tar with OVF and VMDK files - https://en.wikipedia.org/wiki/Open_Virtualization_Format) containing an Ubuntu VM that I'll be deploying on ESXi using vSphere client. I also have a shell script that I'd like to be executed on first boot of the VM.
What would be the proper way to do this using cloud-init? Is there a special place where cloud-init would be looking for such a script?
Thanks and regards! Dinko
-
Dinko Ivanov over 7 yearsThanks ddlingo. The shell script is already contained in the VM? Is there a way to go without the addition ISO? Regards, Dinko
-
ddlingo over 7 yearsNo its not already contained in the VM. Cloud-init is actually meant for the cloud platforms like AWS and Openstack. This is a work around to get it to work with vmware. Essentially, this is like creating a boot disk that will run some commands on your VM for you. Using this method, you will have to use the ISO. You can also use tools like Chef or Ansible to do the same thing, but that may take you down a path you really don't want to go and add more complexity to your project. Let me know if Ic an help further.