Ansible: vmware_module does not work and flashes the error "Failed to find a matching datastore"

140 views
Skip to first unread message

Vijay Misra

unread,
Sep 27, 2017, 9:44:32 PM9/27/17
to ansible...@googlegroups.com
Hi , 
 
 I have upgraded to ansible 2.4 and using vmware_guest module to create a VM. I am getting "Failed to find a matching datastore".
same code works fine in ansiblke 2.3.

is this a known issue or am i missing something?

Thanks,
Vijay




  msg": "Failed to find a matching datastore"

Here is my ansible snippet:

    - name: Create a virtual machine from the datastore VM ( Using vGPU VM)
        local_action:
           module: vmware_guest
           hostname: '{{ hostname }}'
           username: '{{ username }}'
           password: '{{ password }}'
           name: '{{ guest_name}}'
           esxi_hostname:   '{{ esxi_hostname1 }}'
#           template: ''
           is_template: no
           datacenter: '{{ datacenter_name }}'
           state: poweredon
           validate_certs: False
        register: taskresult
        ignore_errors: True

when i run with -vvvv option i see following parameters are passed:

fatal: [xxxxxxxx -> localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "annotation": null, 
            "cluster": null, 
            "customization": {}, 
            "customvalues": [], 
            "datacenter": "Datacenter", 
            "disk": [], 
            "esxi_hostname": "10..x.x.x", 
            "folder": "/vm", 
            "force": false, 
            "guest_id": null, 
            "hardware": {}, 
            "hostname": "10.x.x.x", 
            "is_template": false, 
            "name": "myvgpu_clone2", 
            "name_match": "first", 
            "networks": [], 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "resource_pool": null, 
            "state": "poweredon", 
            "template_src": null, 
            "username": "admini...@vsphere.local", 
            "uuid": null, 
            "validate_certs": false, 
            "wait_for_ip_address": false
        }
    }, 
    "msg": "Failed to find a matching datastore"
}
...ignoring


I would appreciate your help if you could please help me in resolving this issue.

Sebastien Desbois

unread,
Sep 28, 2017, 11:23:22 AM9/28/17
to Ansible Project
Hello,

when you don't specify a datastore, ansible will use an autoselect_datastore function to find a datastore for your VM.
In this function, there is a check to see if there is enough space in the datastores list for your new VM.
If not, no datastore is return by this function and you get the "Failed to find a matching datastore" message.

I think you need to check first if you have enough space in your datastores to host this new VM.

Vijay Misra

unread,
Sep 28, 2017, 3:08:44 PM9/28/17
to Ansible Project
Thanks for your response !

I checked and Yes I do have enough space on my datastore.

-Vijay

Sebastien Desbois

unread,
Oct 2, 2017, 10:55:59 AM10/2/17
to Ansible Project
Hello,

I did some tests  with your snippet.
This is not working and it's normal.

Either you create the VM based on a template, and the result will be by default in the same datastore as the the template, or you create a VM from scratch and you specifu the disk parameters (size, type, autoselect_datastore: true if you don't want to specify the datastore) and all other required parameters.
This is very strange because you are getting the "Failed to find a matching datastore" message first when you are missing 50 to 60% of the parameters needed to create a VM from scratch.

Either fill the template parameter or all the necessary parameters.

Regards,
Reply all
Reply to author
Forward
0 new messages