# ESX Setting Guest IP address

**URL:** <https://forum.ansible.com/t/esx-setting-guest-ip-address/16273>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [September 18, 2014, 2:10pm UTC](https://forum.ansible.com/t/esx-setting-guest-ip-address/16273 "2014-09-18T14:10:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerhard\_Hannemann](https://avatars.discourse-cdn.com/v4/letter/g/9e8a1a/32.png) [@Gerhard\_Hannemann](https://forum.ansible.com/u/Gerhard_Hannemann)\
**Post date:** [September 18, 2014, 2:10pm UTC](https://forum.ansible.com/t/esx-setting-guest-ip-address/16273/1 "2014-09-18T14:10:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [September 18, 2014, 4:02pm UTC](https://forum.ansible.com/t/esx-setting-guest-ip-address/16273/2 "2014-09-18T16:02:36Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Gerhard\_Hannemann](https://avatars.discourse-cdn.com/v4/letter/g/9e8a1a/32.png) [@Gerhard\_Hannemann](https://forum.ansible.com/u/Gerhard_Hannemann)\
**Post date:** [September 23, 2014, 12:19pm UTC](https://forum.ansible.com/t/esx-setting-guest-ip-address/16273/3 "2014-09-23T12:19:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Seth\_Reinoso](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Seth\_Reinoso](https://forum.ansible.com/u/Seth_Reinoso)\
**Post date:** [June 24, 2015, 7:46pm UTC](https://forum.ansible.com/t/esx-setting-guest-ip-address/16273/4 "2015-06-24T19:46:10Z")

</div>

Has a solution ever been found for this ??  
Thx

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 26, 2015, 4:39pm UTC](https://forum.ansible.com/t/esx-setting-guest-ip-address/16273/5 "2015-06-26T16:39:40Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Seth\_Reinoso](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Seth\_Reinoso](https://forum.ansible.com/u/Seth_Reinoso)\
**Post date:** [June 28, 2015, 7:22am UTC](https://forum.ansible.com/t/esx-setting-guest-ip-address/16273/6 "2015-06-28T07:22:30Z")

</div>

Well, that’s unfortunate.  
But thanks for the response and the ideas.

---

<div class="post-metadata">

**Author:** ![tsdrach](https://avatars.discourse-cdn.com/v4/letter/t/ad7895/32.png) [@tsdrach](https://forum.ansible.com/u/tsdrach)\
**Post date:** [March 16, 2016, 10:27pm UTC](https://forum.ansible.com/t/esx-setting-guest-ip-address/16273/7 "2016-03-16T22:27:54Z")

</div>

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](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
