Post-provisioning script


#1

Hello,

I am working on Vsphere post-provisioning script that modifies Windows Server via Winrm.
It works well for me if I specify Static IP address in a service dialog. I would need to be able to run post-provisioning script to VM provisioned with DHCP IP. Is there a way how to get the information about assigned VM IP address and use it in post-provisioning script.

Thanks,
Karel


#2

Hi

Yes there is, if your VM will be running VMware Tools. You need to put something like this in your post-provision method, to check to see if the IP address had been detected by the tools and reported back to ManageIQ:

prov = $evm.root['miq_provision']
vm = prov.destination    
if vm.ipaddresses.length.zero?
  $evm.log(:info, "VM doesnt have an IP address yet - retrying in 1 minute")
  $evm.root['ae_result'] = 'retry'
  $evm.root['ae_retry_interval'] = '1.minute'
  exit MIQ_OK
end
ip_address = vm.ipaddresses[0]
$evm.log(:info, "IP Address is: #{ip_address}")

Hope this helps,
pemcg


#3

It is exactly what I need and it works well for me.

Many thanks,

Karel


#4

@pemcg thanks for assisting other community members! :smiley: