# Ansible - "pyvmomi module required" error

**URL:** <https://forum.ansible.com/t/ansible-pyvmomi-module-required-error/26493>\
**Category:** Ansible Project\
**Created:** [January 16, 2018, 7:29pm UTC](https://forum.ansible.com/t/ansible-pyvmomi-module-required-error/26493 "2018-01-16T19:29:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludmilmm](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@ludmilmm](https://forum.ansible.com/u/ludmilmm)\
**Post date:** [January 16, 2018, 7:29pm UTC](https://forum.ansible.com/t/ansible-pyvmomi-module-required-error/26493/1 "2018-01-16T19:29:43Z")

</div>

When I add the following section to otherwise working ansible playbook:

`

- name: Revert to a snapshot  
vmware\_guest\_snapshot:  
hostname: myvcenter  
username: myusername  
password: mypassword  
datacenter: myvcenter  
folder: myfolder  
name: guestname  
state: revert  
snapshot\_name: snapshotname  
`

and run:

`ansible-playbook myplaybook`

I get the following error:

`  
TASK [Revert to a snapshot] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [x.x.x.x]: FAILED! =\> {“changed”: false, “msg”: “pyvmomi module required”}

`

I was referencing the ansible documentation, linked below:

[http://docs.ansible.com/ansible/latest/vmware\_guest\_snapshot\_module.html](http://docs.ansible.com/ansible/latest/vmware_guest_snapshot_module.html)

Here’s some info about my ansible server:

`  
[root@ansible ansible]# uname -a  
Linux ansible 2.6.32-696.6.3.el6.x86\_64 #1 SMP Wed Jul 12 14:17:22 UTC 2017 x86\_64 x86\_64 x86\_64 GNU/Linux

[root@ansible ansible]# cat /etc/\*release  
CentOS release 6.9 (Final)

[root@ansible ansible]# ansible --version  
ansible 2.4.2.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.6/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

[root@ansible ansible]# pip list | grep pyvmomi  
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6  
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.  
pyvmomi (6.5.0.2017.5.post1)  
`

I tried googling for the error, but wasn’t able to find any solutions so far. I would appreciate any help, regarding this issue.

Thank you!

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 16, 2018, 7:35pm UTC](https://forum.ansible.com/t/ansible-pyvmomi-module-required-error/26493/2 "2018-01-16T19:35:05Z")

</div>

pyvmomi needs to be installed where the module is executing, per your output, it is failing to import pyvmomi on `x.x.x.x` (which is of course some obscured host)

You likely want to use `delegate_to: localhost` on that task to have ansible execute the module locally, instead of on a remote host.

---

<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:** [January 16, 2018, 7:35pm UTC](https://forum.ansible.com/t/ansible-pyvmomi-module-required-error/26493/3 "2018-01-16T19:35:48Z")

</div>

> When I add the following section to otherwise working ansible playbook:
> 
> - name: Revert to a snapshot  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vmware\_guest\_snapshot:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hostname: myvcenter  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username: myusername  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password: mypassword  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;datacenter: myvcenter  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;folder: myfolder  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: guestname  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: revert  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;snapshot\_name: snapshotname
> 
> and run:
> 
> ansible-playbook myplaybook
> 
> I get the following error:
> 
> TASK [Revert to a snapshot]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> fatal: [x.x.x.x]: FAILED! =\> {"changed": false, "msg": "pyvmomi module  
> required"}
> 
> I was referencing the ansible documentation, linked below:
> 
> [http://docs.ansible.com/ansible/latest/vmware\_guest\_snapshot\_module.html](http://docs.ansible.com/ansible/latest/vmware_guest_snapshot_module.html)

As the documentation say  
"Requirements (on host that executes module)"

Task "Revert to a snapshot" is run on "fatal: [x.x.x.x]" so x.x.x.x need pyvmomi module installed.

> Here's some info about my ansible server:
> 
> [root@ansible ansible]# pip list | grep pyvmomi  
> pyvmomi (6.5.0.2017.5.post1)

If you intended to run the task on the Ansible contol machine you are missing a delegate\_to: localhost

---

<div class="post-metadata">

**Author:** ![ludmilmm](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@ludmilmm](https://forum.ansible.com/u/ludmilmm)\
**Post date:** [January 16, 2018, 8:58pm UTC](https://forum.ansible.com/t/ansible-pyvmomi-module-required-error/26493/4 "2018-01-16T20:58:38Z")

</div>

Thanks, Matt! I will give it a try.

---

<div class="post-metadata">

**Author:** ![user38](https://avatars.discourse-cdn.com/v4/letter/u/ba8739/32.png) [@user38](https://forum.ansible.com/u/user38)\
**Post date:** [August 16, 2018, 8:53am UTC](https://forum.ansible.com/t/ansible-pyvmomi-module-required-error/26493/5 "2018-08-16T08:53:38Z")

</div>

Hi, i meet the same issue, are you how to solved ?

PLAY [Revert the given snapshot for virtual machines] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [get vm state] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“changed”: false, “msg”: “PyVmomi Python module required. Install using "pip install PyVmomi"”}  
to retry, use: --limit @/etc/ansible/Vm\_rollback\_snapshost.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=1 changed=0 unreachable=0 failed=1

Gathering Facts --------------------------------------------------------- 2.76s  
get vm state ------------------------------------------------------------ 1.30s

Playbook finished: Thu Aug 16 16:41:51 2018, 2 total tasks. 0:00:04 elapsed.

[root@Georgeoelv1 ansible]# pip list | grep pyvmomi  
pyvmomi 6.7.0  
[root@Georgeoelv1 ansible]#

在 2018年1月17日星期三 UTC+8上午3:29:43，ludm…@gmail.com写道：

> When I add the following section to otherwise working ansible playbook:
> 
> `
> 
> - name: Revert to a snapshot  
> vmware\_guest\_snapshot:  
> hostname: myvcenter  
> username: myusername  
> password: mypassword  
> datacenter: myvcenter  
> folder: myfolder  
> name: guestname  
> state: revert  
> snapshot\_name: snapshotname  
> `
> 
> and run:
> 
> `ansible-playbook myplaybook`
> 
> I get the following error:
> 
> `  
> TASK [Revert to a snapshot] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> fatal: [x.x.x.x]: FAILED! =\> {“changed”: false, “msg”: “pyvmomi module required”}
> 
> `
> 
> I was referencing the ansible documentation, linked below:
> 
> [http://docs.ansible.com/ansible/latest/vmware\_guest\_snapshot\_module.html](http://docs.ansible.com/ansible/latest/vmware_guest_snapshot_module.html)
> 
> Here’s some info about my ansible server:
> 
> `  
> [root@ansible ansible]# uname -a  
> Linux ansible 2.6.32-696.6.3.el6.x86\_64 #1 SMP Wed Jul 12 14:17:22 UTC 2017 x86\_64 x86\_64 x86\_64 GNU/Linux
> 
> [root@ansible ansible]# cat /etc/\*release  
> CentOS release 6.9 (Final)
> 
> [root@ansible ansible]# ansible --version  
> ansible 2.4.2.0  
> config file = /etc/ansible/ansible.cfg  
> configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
> ansible python module location = /usr/lib/python2.6/site-packages/ansible  
> executable location = /usr/bin/ansible  
> python version = 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
> 
> [root@ansible ansible]# pip list | grep pyvmomi  
> DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6  
> DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.  
> pyvmomi (6.5.0.2017.5.post1)  
> `
> 
> I tried googling for the error, but wasn’t able to find any solutions so far. I would appreciate any help, regarding this issue.
> 
> Thank you!

在 2018年1月17日星期三 UTC+8上午3:29:43，ludm…@gmail.com写道：
