vmware_guest module error: Failed to find a matching datastore

351 views
Skip to first unread message

DSS

unread,
Feb 6, 2017, 9:41:41 AM2/6/17
to Ansible Project
Hello,

I am testing the vmware_guest module to snapshot a VM but it returns an error message with any invocation of module. According to the documentation (https://docs.ansible.com/ansible/vmware_guest_module.html), i'm using ansible development version (ansible 2.3.0 (devel 86db15b105)) and the required parameters of module for vcenter connection.

The error message is 
"msg": "Failed to find a matching datastore"

Removing the snapshot part and testing with ansible 2.2, the error is diferent: KeyError: 'template'

The task involved:

- vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter.ip }}"
    username: "{{ vcenter.username }}"
    password: "{{ vcenter.password }}"
    datacenter: "{{ vcenter.datacenter }}"
    name: "{{ vm2snap | upper }}"
    state: poweredoff
    #snapshot_op:
    #  op_type: create
    #  name: snap_osp
    #  description: {{ vm2snap }} snapshot.

===========
== Output with ansible 2.3
====

$ ansible --version
ansible 2.3.0 (devel 86db15b105) last updated 2017/02/01 21:10:20 (GMT +200)
  config file = /home/xxxxx/.ansible.cfg
  configured module search path = Default w/o overrides

$ ansible-playbook site.yml -vvv
TASK [vmware_snapshot : vmware_guest] ***************************************************************************************************************************************************************
task path: /home/xxxxx/gitlab/ansible_roles/roles/vmware_snapshot/tasks/main.yml:6
Using module file /home/xxxxx/ansible/ansible/lib/ansible/modules/cloud/vmware/vmware_guest.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: xxxxx
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/xxxxx/.ansible/tmp/ansible-tmp-1485981908.67-176971169417275 `" && echo ansible-tmp-1485981908.67-176971169417275="` echo /home/xxxxx/.ansible/tmp/ansible-tmp-1485981908.67-176971169417275 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmpaNIslW TO /home/xxxxx/.ansible/tmp/ansible-tmp-1485981908.67-176971169417275/vmware_guest.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/xxxxx/.ansible/tmp/ansible-tmp-1485981908.67-176971169417275/ /home/xxxxx/.ansible/tmp/ansible-tmp-1485981908.67-176971169417275/vmware_guest.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/xxxxx/ansible/ansible-dev/bin/python /home/xxxxx/.ansible/tmp/ansible-tmp-1485981908.67-176971169417275/vmware_guest.py; rm -rf "/home/xxxxx/.ansible/tmp/ansible-tmp-1485981908.67-176971169417275/" > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "annotation": null,
            "cluster": null,
            "customization": {},
            "customvalues": [],
            "datacenter": "IAAS",
            "disk": [],
            "esxi_hostname": null,
            "folder": "/vm",
            "force": false,
            "guest_id": null,
            "hardware": {},
            "hostname": "10.37.18.31",
            "is_template": false,
            "name": "VMTEST",
            "name_match": "first",
            "networks": [],
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "resource_pool": null,
            "snapshot_op": {},
            "state": "poweredoff",
            "template_src": null,
            "username": "root",
            "uuid": null,
            "validate_certs": false,
            "wait_for_ip_address": true
        },
        "module_name": "vmware_guest"
    },
    "msg": "Failed to find a matching datastore"
}
    to retry, use: --limit @/home/xxxxx/gitlab/ansible_roles/site.retry

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


===========
== Output with ansible 2.2
====

$ ansible --version
ansible 2.2.1.0
  config file = /home/xxxxx/.ansible.cfg
  configured module search path = Default w/o overrides

TASK [vmware_snapshot : vmware_guest] ******************************************
task path: /home/xxxxx/gitlab/ansible_roles/roles/vmware_snapshot/tasks/main.yml:6
Using module file /usr/lib/python2.7/site-packages/ansible/modules/extras/cloud/vmware/vmware_guest.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: xxxxx
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1485982270.51-232973015238685 `" && echo ansible-tmp-1485982270.51-232973015238685="` echo ~/.ansible/tmp/ansible-tmp-1485982270.51-232973015238685 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmp1N9UWl TO /home/xxxxx/.ansible/tmp/ansible-tmp-1485982270.51-232973015238685/vmware_guest.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/xxxxx/.ansible/tmp/ansible-tmp-1485982270.51-232973015238685/ /home/xxxxx/.ansible/tmp/ansible-tmp-1485982270.51-232973015238685/vmware_guest.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /home/xxxxxx/.ansible/tmp/ansible-tmp-1485982270.51-232973015238685/vmware_guest.py; rm -rf "/home/xxxxx/.ansible/tmp/ansible-tmp-1485982270.51-232973015238685/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_PeHVLt/ansible_module_vmware_guest.py", line 959, in <module>
    main()
  File "/tmp/ansible_PeHVLt/ansible_module_vmware_guest.py", line 937, in main
    wait_for_ip=module.params['wait_for_ip_address']
  File "/tmp/ansible_PeHVLt/ansible_module_vmware_guest.py", line 494, in deploy_template
    template = get_obj(self.content, [vim.VirtualMachine], self.params['template'])
KeyError: 'template'

fatal: [localhost]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_name": "vmware_guest"
    },
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_PeHVLt/ansible_module_vmware_guest.py\", line 959, in <module>\n    main()\n  File \"/tmp/ansible_PeHVLt/ansible_module_vmware_guest.py\", line 937, in main\n    wait_for_ip=module.params['wait_for_ip_address']\n  File \"/tmp/ansible_PeHVLt/ansible_module_vmware_guest.py\", line 494, in deploy_template\n    template = get_obj(self.content, [vim.VirtualMachine], self.params['template'])\nKeyError: 'template'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE"
}
    to retry, use: --limit @/home/xxxxx/gitlab/ansible_roles/site.retry

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




Any idea what the problem could be?

Thank you very much and regards,
Reply all
Reply to author
Forward
0 new messages