What can I do with guestinfo.cloud-init?

I’m testing the new Vmware guestinfo functionality in v1.1.0 but it’s a bit unclear to me what I’m actually capable to do with it.

My dream is to run RancherOS on disk less virtual machines, booting the rancheros.iso. I would also prefer to have only one cloud config to administer. It could be a shell script that behaves differently depending on the machine running it. Putting such config in guestinfo.cloud-init.config.url were my initial idea, but since no network device has been configured at this point in the boot process this won’t work. My next alternative would be to put it in guestinfo.cloud-init.config.data. But then it would need some meta data to be able to differentiate our machines. Do you have any suggestion of accessible meta data one could use? My next obstacle would be the file system. My cloud-init script seems unable to write to the file system. Is a guestinfo.cloud-init.config.data script executed before even the file system has been created?

Please enlighten me.

Hi,

I don’t have any answers for you yet, and I have a different use case I’m trying to work through.

I want to use RancherOS as the base operating system for a product shipped as a virtual appliance on VMware.

I need someway to configure the appliance at deployment not install time - I’m currently thinking that using the ovf properties and cloud configuration is the way to go, but I’m still working out what needs to be done in the os to extract the data into application / environment configuration for my software to “see”.

Richard

I have a couple of things in one of my repos that uses VMWare guestinfo

the most “together” example is: https://github.com/SvenDowideit/bin-dir/blob/master/cloud-configs/airgap/create-node

that script uses machine to set the guestinfo IP and cloud-init, and then is the same script that is the guestinfo cloud-init.

note that there is a bug in docker-machine where it seems to only manage to send the cloud-init as an encoded text if its specified as a relative path - and ~ doesn’t work either.

I’ve seen that the cloud-init file could be a bash script (using #! /bin/sh rather than #cloud-config as the first line).

Are there are examples/gists that use this model to create the configuration needed…

I think this might be the way to implement what I was looking for

I’ll still need a way to get properties out of the OVFEnv - but I have a very short GO program that is heading in the right direction…

I accomplished what I wanted by adding the guestinfo hostname+interface+dns settings in Vmware Vsphere, and putting the following script (encoded to base64) in guestinfo.cloud-init.config.data.

#!/bin/sh -e

# Mount persistent configuration directory
# ----------------------------------------
  mkdir /home/rancher/conf
  chmod u=rwXt,go= /home/rancher/conf
  hostname=`hostname`
  mount -t nfs -o nfsvers=3,nolock,ro 10.10.33.20:/rancher-host_configs/$hostname /home/rancher/conf

# Execute persistent configuration
# --------------------------------
  exec /home/rancher/conf/cloud-config.sh 

Then I put all host-specific configuration in sub-folders, named after the rancher hosts, on a NFS-share.