Issue with vmware_guest_snapshot module

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

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

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

---
   - hosts: all
     tasks:
     - name: Create Snapshot
       vmware_guest_snapshot:
         datacenter: development
         hostname: vmwprtvcnp01.gartner.com
         username: joedoe
         password: xxxxxxxx
         name: "{{ ansible_hostname }}"
         uuid: "{{ ansible_product_uuid }}"
         state: present
         snapshot_name: test1
         description: patch_snapshot
         validate_certs: no
       delegate_to: localhost

<snip>

fatal: [crmdvtsrch01.gartner.com -> localhost]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "datacenter": "development",
            "description": "patch_snapshot",
            "folder": "/vm",
            "hostname": "vmwprtvcnp01.gartner.com",
            "name": "crmdvtsrch01",
            "name_match": "first",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "snapshot_name": "test1",
            "state": "present",
            "username": "gartner\\rgarrow-admin",
            "uuid": "4232D73D-4FAC-38C0-2F29-75A2B1A478B8",
            "validate_certs": false
        }
    }
}

MSG:

Unable to manage snapshots for non-existing VM crmdvtsrch01

        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?

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

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

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

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

Have you read this one?

"vmware_guest_snapshot don't find vm if not folder is specified"
https://github.com/ansible/ansible/issues/22644

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

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.

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

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

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