vmware modules

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

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
  task:
  - name: registered vms
    vmware_vm_facts:
       hostname: vcenter
       username: test
       password: ********
    delegate_to: localhost
    register: vmfacts

  - debug:
       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

Thanks for your prompt response !

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

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.