# Issue with vmware\_guest\_snapshot module

**URL:** <https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494>\
**Category:** Ansible Project\
**Created:** [May 16, 2017, 1:19pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494 "2017-05-16T13:19:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![americanoz](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@americanoz](https://forum.ansible.com/u/americanoz)\
**Post date:** [May 16, 2017, 1:19pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/1 "2017-05-16T13:19:06Z")

</div>

Hi all,

I have been having an issue with trying to get this module working correctly. I believe it is the way I am laying out the code. I have seen some solutions from Kai and he seems to have a very good handle on it so hoping he will view this one.

here is my code I am running ansible 2.3.0 and Python 2.7.5 PyVmomi, ESX6.2

---

<div class="post-metadata">

**Author:** ![americanoz](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@americanoz](https://forum.ansible.com/u/americanoz)\
**Post date:** [May 16, 2017, 7:04pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/2 "2017-05-16T19:04:08Z")

</div>

I have an update I ran this code through [http://www.yamllint.com/](http://www.yamllint.com/) which verifies the code so here is the code

---

<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:** [May 17, 2017, 5:39pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/3 "2017-05-17T17:39:31Z")

</div>

> Hi all,
> 
> I have been having an issue with trying to get this module working  
> correctly. I believe it is the way I am laying out the code. I have seen  
> some solutions from Kai and he seems to have a very good handle on it so  
> hoping he will view this one.
> 
> here is my code I am running ansible 2.3.0 and Python 2.7.5 PyVmomi, ESX6.2
> 
> ---  
> &nbsp;&nbsp;&nbsp;- hosts: all  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: Create Snapshot  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vmware\_guest\_snapshot:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;datacenter: development  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hostname: vmwprtvcnp01.gartner.com  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username: joedoe  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password: xxxxxxxx  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: "{{ ansible\_hostname }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;uuid: "{{ ansible\_product\_uuid }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: present  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;snapshot\_name: test1  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;description: patch\_snapshot  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;validate\_certs: no  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: localhost

\<snip\>

> fatal: [crmdvtsrch01.gartner.com -\> localhost]: FAILED! =\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"changed": false,  
> &nbsp;&nbsp;&nbsp;&nbsp;"failed": true,  
> &nbsp;&nbsp;&nbsp;&nbsp;"invocation": {  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"module\_args": {  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"datacenter": "development",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"description": "patch\_snapshot",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"folder": "/vm",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"hostname": "vmwprtvcnp01.gartner.com",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"name": "crmdvtsrch01",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"name\_match": "first",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"password": "VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"snapshot\_name": "test1",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"state": "present",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"username": "gartner\\rgarrow-admin",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"uuid": "4232D73D-4FAC-38C0-2F29-75A2B1A478B8",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"validate\_certs": false  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
> &nbsp;&nbsp;&nbsp;&nbsp;}  
> }
> 
> MSG:
> 
> Unable to manage snapshots for non-existing VM crmdvtsrch01
> 
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to retry, use: --limit @/opt/app/ansible/takesnapshot.retry

It's nothing wrong with your Ansible syntax.  
The code runs and it clearly say it can't find the VM "crmdvtsrch01", does it exist?

---

<div class="post-metadata">

**Author:** ![americanoz](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@americanoz](https://forum.ansible.com/u/americanoz)\
**Post date:** [May 17, 2017, 6:25pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/4 "2017-05-17T18:25:35Z")

</div>

Hi Kai,

First thanks for taking the time to have a look at my issue.

Yes the server does exist I have tried various servers which are all located on the esx servers but they all give the same results…  
Richg

---

<div class="post-metadata">

**Author:** ![americanoz](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@americanoz](https://forum.ansible.com/u/americanoz)\
**Post date:** [May 17, 2017, 8:57pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/5 "2017-05-17T20:57:11Z")

</div>

Hi Kai,

Just to followup I have now tried different Datacenters, different Virtual Centers, and different users and I still get the same result. But vmware\_vm\_facts works fine. I trying the vmware mods to see if I can figure it out. Any suggestions or help would be really appreciated. thanks,

I am at a total loss… could it be a network or firewall or port issue. I can validate via ping to each VM Guest. But

---

<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:** [May 18, 2017, 8:09am UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/6 "2017-05-18T08:09:46Z")

</div>

It's most likely a wrong combination of datacenter:, name: and uuid: since it can't find the VM.

Is {{ ansible\_hostname }} the same name it's called in Vmware? Is the UUID correct?

Vmware is case sensitive, is the case correct in datacenter:, name: and uuid: ?

---

<div class="post-metadata">

**Author:** ![americanoz](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@americanoz](https://forum.ansible.com/u/americanoz)\
**Post date:** [May 18, 2017, 1:11pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/7 "2017-05-18T13:11:21Z")

</div>

Hi Kai,

Thank you for taking the time to review and reply. I thought the same thing yesterday and ran through every option I could think of. the funny part about the module is it states in the documentation that UUID is not required but if I run it with out the UUID I get a different result. I will run give it another try today. Not sure if you know much about the VC can there be a incompatibility with pyvmomi and the VC we are running 6.0 VC. I did check and pyvmomi will go back 4 version so that should be good. Sorry running through everything in my head…

Thanks again. I will update later today…  
richg

---

<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:** [May 18, 2017, 3:12pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/8 "2017-05-18T15:12:03Z")

</div>

Have you read this one?

"vmware\_guest\_snapshot don't find vm if not folder is specified"  
[https://github.com/ansible/ansible/issues/22644](https://github.com/ansible/ansible/issues/22644)

---

<div class="post-metadata">

**Author:** ![americanoz](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@americanoz](https://forum.ansible.com/u/americanoz)\
**Post date:** [May 18, 2017, 5:41pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/9 "2017-05-18T17:41:21Z")

</div>

Thank you sir that is the exact issue I am having. I wish folks would be more forth coming with issues with the modules it would make things a little easier.

I am trying to understand the folder structure of the VC as when I run the PB with folder I get back vm/foldername

---

<div class="post-metadata">

**Author:** ![americanoz](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@americanoz](https://forum.ansible.com/u/americanoz)\
**Post date:** [May 18, 2017, 7:50pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/10 "2017-05-18T19:50:48Z")

</div>

Hi all here is the solution to this issue I really hope this helps the next poor person who has to bang there head for weeks trying to figure this one out.

---

<div class="post-metadata">

**Author:** ![Jorg\_Kastning](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Jorg\_Kastning](https://forum.ansible.com/u/Jorg_Kastning)\
**Post date:** [May 31, 2017, 1:03pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/11 "2017-05-31T13:03:05Z")

</div>

Hi,

In your playbook you have specified:

`

name: “{{ ansible\_hostname }}”  
uuid: “{{ ansible\_product\_uuid | lower }}”

`

Did that mean, that you take a snapshot from all of your VMs in the specified folder?

Regards,  
Joerg

---

<div class="post-metadata">

**Author:** ![americanoz](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@americanoz](https://forum.ansible.com/u/americanoz)\
**Post date:** [May 31, 2017, 8:06pm UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/12 "2017-05-31T20:06:16Z")

</div>

Hi Joerg,

Yes if you have a list of servers in a host file then it will walk through each server and create a snap shot for you. I am using this for patching on my ESX host servers I find a folder to be a pain but have no other choice.

Let me know if you have any other issues

richg

---

<div class="post-metadata">

**Author:** ![Jorg\_Kastning](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Jorg\_Kastning](https://forum.ansible.com/u/Jorg_Kastning)\
**Post date:** [February 2, 2019, 10:54am UTC](https://forum.ansible.com/t/issue-with-vmware-guest-snapshot-module/24494/13 "2019-02-02T10:54:02Z")

</div>

Hello Richard,  
although this thread is somewhat old I hope you are still reading here and have some advise for me, because I’m going to accomplish the same task.

I’ll have some virtual machines in my vSphere environment which I like to:

1. Take a snapshot and if successful
2. Run task that installs updates on guest os
3. Reboot guest if necessary  
My problem is, that my VMs are not in the same folder. They are spread across the cluster in many different folders. But because they are not too many I would be able to specify them manually by name or uuid.

Looking around for someone who has already solved this I found your post and was hoping you could give me some advise here. Do you have for any chance a working solution you could share?

Best regards,  
Joerg
