# Vmware Esxi with Ansible

**URL:** <https://forum.ansible.com/t/vmware-esxi-with-ansible/28445>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [August 28, 2018, 2:09pm UTC](https://forum.ansible.com/t/vmware-esxi-with-ansible/28445 "2018-08-28T14:09:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bishwajit\_Samanta](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@Bishwajit\_Samanta](https://forum.ansible.com/u/Bishwajit_Samanta)\
**Post date:** [August 28, 2018, 2:09pm UTC](https://forum.ansible.com/t/vmware-esxi-with-ansible/28445/1 "2018-08-28T14:09:58Z")

</div>

Hi,

I am trying to connect esxi 6.5 with ansible. I have copied ssh keys using ssh-copy-id to root id of the esxi server but when i am executing ansible -m ping vmware(ip) it says permission denied. Any idea how to make it work out ?

192.168.119.129 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh: Permission denied (publickey,keyboard-interactive).\r\n”,  
“unreachable”: true  
}

Sudoers is not there in esxi servers… am i missing any point

---

<div class="post-metadata">

**Author:** ![Greg\_Porter](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@Greg\_Porter](https://forum.ansible.com/u/Greg_Porter)\
**Post date:** [August 28, 2018, 11:07pm UTC](https://forum.ansible.com/t/vmware-esxi-with-ansible/28445/2 "2018-08-28T23:07:08Z")

</div>

Hmm. Well, by default ESXi hypervisors have ssh turned off. You need to manually go turn it on. Make sure ssh is running on the host. [https://pubs.vmware.com/vsphere-6-5/index.jsp?topic=%2Fcom.vmware.vcli.getstart.doc%2FGUID-C3A44A30-EEA5-4359-A248-D13927A94CCE.html](https://pubs.vmware.com/vsphere-6-5/index.jsp?topic=%2Fcom.vmware.vcli.getstart.doc%2FGUID-C3A44A30-EEA5-4359-A248-D13927A94CCE.html)

HTH

Greg

---

<div class="post-metadata">

**Author:** ![Greg\_Porter](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@Greg\_Porter](https://forum.ansible.com/u/Greg_Porter)\
**Post date:** [August 28, 2018, 11:16pm UTC](https://forum.ansible.com/t/vmware-esxi-with-ansible/28445/3 "2018-08-28T23:16:32Z")

</div>

Well. after further thought…

When I did this, I used the VMware modules, like those at [https://docs.ansible.com/ansible/latest/modules/list\_of\_cloud\_modules.html#vmware](https://docs.ansible.com/ansible/latest/modules/list_of_cloud_modules.html#vmware)

These require use of the VMware vSphere API Python Bindings , pyvmomi. [https://github.com/vmware/pyvmomi](https://github.com/vmware/pyvmomi)

You install pyvmomi on the machine you are running the Ansible playbooks from.

Then when you run a playbook that uses a VMware module, the playbook uses pyvmomi to connect directly to the ESXi hypervisor (or vCenter) using the VMware API. Not ssh.

The machine you run playbooks from has to have network access to the ESXi hypervisor or vCenter on the various ports that the vSphere API requires.

HTH some more.

Greg

---

<div class="post-metadata">

**Author:** ![Bishwajit\_Samanta](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@Bishwajit\_Samanta](https://forum.ansible.com/u/Bishwajit_Samanta)\
**Post date:** [August 29, 2018, 10:40am UTC](https://forum.ansible.com/t/vmware-esxi-with-ansible/28445/4 "2018-08-29T10:40:39Z")

</div>

Hi,

I am having below things in my Vm’s (Vmware free license)

pyvmomi installed in Ubuntu 16 where ansible also installed (192.168.119.131)  
ansible 2.7  
Esxi 6.5(192.168.119.129)  
1 VM (Ubuntu) in vmware named as Test (192.168.119.130) whose vmware guest\_facts i am finding out through UUID

My host file (Ansible)

[vmware]  
192.168.119.129

My Playbook:

---

<div class="post-metadata">

**Author:** ![Greg\_Porter](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@Greg\_Porter](https://forum.ansible.com/u/Greg_Porter)\
**Post date:** [August 29, 2018, 5:55pm UTC](https://forum.ansible.com/t/vmware-esxi-with-ansible/28445/5 "2018-08-29T17:55:43Z")

</div>

I’m new at this too. I just got my first ever playbook to run the other day.

So this is what my playbook looks like. Note that I keep my credentials for vCenter in a vault, which is NOT required.

[glporter@montara 29Aug1743Z ansible]$  
rToShowSnapshots.ymlAug1743Z ansible]$cat playbooks/vmware/testPlaybookForVcenterToShowSnapshots.yml

---

<div class="post-metadata">

**Author:** ![Greg\_Porter](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@Greg\_Porter](https://forum.ansible.com/u/Greg_Porter)\
**Post date:** [August 29, 2018, 5:58pm UTC](https://forum.ansible.com/t/vmware-esxi-with-ansible/28445/6 "2018-08-29T17:58:42Z")

</div>

So I think to answer your question, look at the top of the playbook
