# vmware modules

**URL:** <https://forum.ansible.com/t/vmware-modules/26228>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [December 8, 2017, 12:55pm UTC](https://forum.ansible.com/t/vmware-modules/26228 "2017-12-08T12:55:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrantic7](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@phrantic7](https://forum.ansible.com/u/phrantic7)\
**Post date:** [December 8, 2017, 12:55pm UTC](https://forum.ansible.com/t/vmware-modules/26228/1 "2017-12-08T12:55:56Z")

</div>

Hello Guys,

I am new in Ansible but I like and I am eager to dig deeper in it.

Anyway, I am trying to use vmware\_vm\_facts module in order get any VM list from vCenter however I got “Failed to connect to the host via ssh:…”

Why does vmware module try ssh connection to vCenter ? I was thinking that API should be used. What am I missing…?

If it matters

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [December 8, 2017, 2:28pm UTC](https://forum.ansible.com/t/vmware-modules/26228/2 "2017-12-08T14:28:36Z")

</div>

> Hello Guys,
> 
> I am new in Ansible but I like and I am eager to dig deeper in it.
> 
> Anyway, I am trying to use vmware\_vm\_facts module in order get any VM list  
> from vCenter however I got "Failed to connect to the host via ssh:..."

Is always better if you can show the hole error message of the run.  
Even run it with -vvvv

> Why does vmware module try ssh connection to vCenter ? I was thinking that  
> API should be used. What am I missing...?

Maybe because you have changed localhost in your inventory?

> If it matters  
> ---  
> - host: vcenter  
> &nbsp;&nbsp;task:  
> &nbsp;&nbsp;- name: registered vms  
> &nbsp;&nbsp;&nbsp;&nbsp;vmware\_vm\_facts:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hostname: vcenter  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username: test  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password: \*\*\*\*\*\*\*\*  
> &nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: localhost  
> &nbsp;&nbsp;&nbsp;&nbsp;register: vmfacts
> 
> &nbsp;&nbsp;- debug:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: vmfacts.virtual\_machines

It always matter, the more relevant information the better or else we are bling.

You haven't told us your Ansible version, but if it's 2.4 run this

ANSIBLE\_STDOUT\_CALLBACK=debug ansible-playbook -vvvv playbook.yml

---

<div class="post-metadata">

**Author:** ![phrantic7](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@phrantic7](https://forum.ansible.com/u/phrantic7)\
**Post date:** [December 8, 2017, 2:57pm UTC](https://forum.ansible.com/t/vmware-modules/26228/3 "2017-12-08T14:57:11Z")

</div>

Thanks for your prompt response !

I have just found out that I need to add “connection: local” and that fixed the issue.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [December 8, 2017, 3:06pm UTC](https://forum.ansible.com/t/vmware-modules/26228/4 "2017-12-08T15:06:24Z")

</div>

Since you are using delegate\_to: localhost you shouldn't need that.  
The connection for localhost default to local, so unless you have changed it, it should have worked.
