Hi
I am sure this have been asked before…
I am trying to use ansible to provision new VMWare guests on my ESXi cluster.So far I have a kickstart custom iso image which can build a base working operation system.
I have an ansible playbook which can turns this base system into a patched and fully configuration application server. Those individual parts work.
What I cannot seem to get around is to get the base system a known IP address. The plan is to provide and IP address that is defined int he ansible inventory. At the moment, set that IP address manually - which is annoying.
I have looked tat vsphere_guest but do not see a way of doing this.
Any ideas?
Regards
Gerhard
Hi Gerhard,
We do have an inventory script for VMware (plugins/inventory/vmware.py) in the source repository, however it does not currently return any network information regarding the guest VM’s which are running. Could you open an issue on GitHub for this, and we’ll see if we can expand that inventory script to return more info regarding the guests.
Thanks!
Hi
Thanks for the reply. I actually need this before I run the VM.
What I have done so far:
- Using the vsphere_guest module, create a VM, in the “present” state. The vmware_guest_facts seem to gather some information which includes a MAC address.
I use this mac address to setup a a static IP in the dnsmasq DHCP.
Once the VM starts up, installs via kickstart, I now have a known IP address and can run up in second ansible playbook against the new machine.
The bit I am still working out is to extract the MAC address in a loop and add it to the DNS server.
So far, I found that if I use register function in the task the gather the vmware_guest_facts, the MAC address is in the registered variable somewhere.
Finding a simple elegant way to get to this variable seem a bit of a challenge.
BTW I think the only way to get the guest IP address from a running system is if vmtools is installed - not sure…
Regards
Gerhard
Has a solution ever been found for this ??
Thx
There are a few of ways around this, you can use the 'boot script'
feature and pass it a script that sets the IP, use a dhcp server or
logon using the template IP and update the networking config, restart
it and now connect with the new info (this last ones limits you to
only provisioning one server from each template at a time).
Well, that’s unfortunate.
But thanks for the response and the ideas.
Hi Gerhard,
There are Customization Specifications in Vsphere. When you deploying VM, you can use your specification with pre-configured IP (not only IP but full static network config). It works if Vmware tools installed in the template.
You can deploy VM with necessary specification directly from pysphere, here is example http://ljuu.blogspot.com/2014/04/pysphere-deploy-vms-from-vm-template.html
But I’m not sure that Ansible has the ability to work with vsphere customization specifications at this moment. I did not found this in Ansible Vmware cloud modules