# VMWare based source gets wrong ansible\_host

**URL:** <https://forum.ansible.com/t/vmware-based-source-gets-wrong-ansible-host/25909>\
**Category:** AWX Project\
**Tags:** vmware\
**Created:** [November 2, 2017, 9:04pm UTC](https://forum.ansible.com/t/vmware-based-source-gets-wrong-ansible-host/25909 "2017-11-02T21:04:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [November 2, 2017, 9:04pm UTC](https://forum.ansible.com/t/vmware-based-source-gets-wrong-ansible-host/25909/1 "2017-11-02T21:04:50Z")

</div>

I have two nics on my vm. One for normal network operations, another dedicated to our SAN. When my VMWare source adds the vm to the inventory, the ansible\_host value is set to the ip of the SAN nic. As is ansible\_ssh\_host.

DNS is configured to use the normal network nic’s ip address.

Is there a way to fix that?

Thanks!

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [November 3, 2017, 3:44am UTC](https://forum.ansible.com/t/vmware-based-source-gets-wrong-ansible-host/25909/2 "2017-11-03T03:44:24Z")

</div>

We return what is emitted by the core ansible vmware inventory script (we call it behind the scenes):

[https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware\_inventory.py](https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware_inventory.py)

It looks like you can control this:

[https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware\_inventory.ini#L59-L61](https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware_inventory.ini#L59-L61)

We take some free-form configuration in the source\_vars section of the inventory source so if you can figure out what specific value is needed for host\_pattern to resolve what you want then you can put that in the “Source Vars” section of the Inventory Source when you are defining it.

Unfortunately I don’t use a lot of vmware so I can’t help you figure out exactly what you need but the ini file I linked to should provide a good starting place. The ansible vmware inventory module uses pyvmomi behind the scenes which is a python interface to the vmware soap interface.

---

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [November 3, 2017, 6:31pm UTC](https://forum.ansible.com/t/vmware-based-source-gets-wrong-ansible-host/25909/3 "2017-11-03T18:31:32Z")

</div>

> We take some free-form configuration in the source\_vars section of the inventory source so if you can figure out what specific value is needed for host\_pattern to resolve what you want then you can put that in the “Source Vars” section of the Inventory Source when you are defining it.

Ah, I hadn’t seen the host\_pattern key. Thanks.

Now, to figure out what to put there…

The correct ip isn’t even listed in the hosts variables section when I view that in the inventory. So, I somehow need to figure out a way to get info from both network cards into a place I can use it…

Is that even something that’s possible without modifying [https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware\_inventory.py](https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware_inventory.py) ?

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [November 3, 2017, 8:24pm UTC](https://forum.ansible.com/t/vmware-based-source-gets-wrong-ansible-host/25909/4 "2017-11-03T20:24:15Z")

</div>

It’s possible, I’m not sure though 😕

If you find it needs to be pushed into vmware\_inventory.py we can pull it in and then contribute it upstream to ansible.
