VMWare based source gets wrong ansible_host

320 views
Skip to first unread message

David Reagan

unread,
Nov 2, 2017, 5:04:51 PM11/2/17
to AWX Project

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!

Matthew Jones

unread,
Nov 2, 2017, 11:44:26 PM11/2/17
to David Reagan, AWX Project
We return what is emitted by the core ansible vmware inventory script (we call it behind the scenes):


It looks like you can control this:


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.

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project+unsubscribe@googlegroups.com.
To post to this group, send email to awx-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/1dab2730-3052-4c09-9708-f79208d1f98a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Jones
Principal Software Engineer
Ansible Tower

David Reagan

unread,
Nov 3, 2017, 2:31:33 PM11/3/17
to AWX Project
> 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 ?



On Thursday, November 2, 2017 at 8:44:26 PM UTC-7, Matthew Jones wrote:
We return what is emitted by the core ansible vmware inventory script (we call it behind the scenes):


It looks like you can control this:


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.
On Thu, Nov 2, 2017 at 5:04 PM, David Reagan <jer...@gmail.com> wrote:

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!

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.

To post to this group, send email to awx-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/1dab2730-3052-4c09-9708-f79208d1f98a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Jones

unread,
Nov 3, 2017, 4:24:17 PM11/3/17
to David Reagan, AWX Project
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.

To unsubscribe from this group and stop receiving emails from it, send an email to awx-project+unsubscribe@googlegroups.com.

To post to this group, send email to awx-p...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages