vmware_guest: fails with 'incorrect username or password' error

ANSIBLE VERSION

ansible-2.2.1.0-1.el6.noarch

OS ENVIRONMENT

`
Red Hat Enterprise Linux Server release 6.8 (Santiago)

vCenter 6.0
`

While using the correct credentials for the account being used to complete the steps in playbook, a fail is returned stating the credentials are incorrect.

STEPS TO REPRODUCE

Run the following playbook

`

Create a new VM

  • name: create new vm…
    hosts: 127.0.0.1
    connection: local
    tasks:
  • vmware_guest:
    hostname: xxx.xxx.local
    username: user@xxx.local
    password: password
    validate_certs: False
    esxi_hostname: hostname
    datacenter: datacenter
    folder: designated folder
    name: newvm
    state: poweredoff
    disk:
  • size_gb: 10
    type: thin
    datastore: datastore
    hardware:
    memory_mb: 8192
    num_cpus: 2
    wait_for_ip_address: False
    delegate_to: 127.0.0.1

`

EXPECTED RESULTS

VM creation as specified in the playbook

ACTUAL RESULTS

`

fatal: [127.0.0.1 → 127.0.0.1]: FAILED! => {
“apierror”: “(vim.fault.InvalidLogin) {\n dynamicType = ,\n dynamicProperty = (vmodl.DynamicProperty) ,\n msg = ‘Cannot complete login due to an incorrect user name or password.’,\n faultCause = ,\n faultMessage = (vmodl.LocalizableMessage) \n}”,
“changed”: false,
“failed”: true,
“invocation”: {
“module_args”: {
“datacenter”: “datacenter”,
“disk”: [
{
“datastore”: “datastore”,
“size_gb”: 10,
“type”: “thin”
}
],
“esxi_hostname”: “hostname”,
“folder”: “designated folder”,
“force”: false,
“hardware”: {
“memory_mb”: 8192,
“num_cpus”: 2
},
“hostname”: “xxx.xxx.local”,
“name”: “newvm”,
“name_match”: “first”,
“nic”: null,
“password”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“state”: “poweredoff”,
“template_src”: null,
“username”: “user@xxx.local”,
“uuid”: null,
“validate_certs”: false,
“wait_for_ip_address”: false
},
“module_name”: “vmware_guest”
},
“msg”: “Cannot complete login due to an incorrect user name or password.”
}

`

One thing to note: there are a couple special characters in the password of the account being used to connect. I’m not certain if these special characters could be the hangup.

I am able to log into the vSphere appliance via three methods with the credentials provided in the playbook:

  • via vSphere Web Client
  • via vSphere Client ( thick )
  • via ssh

I am relatively new to Ansible configuration / use. Any insight is appreciated.

I resolved my initial issue but have run into a new one. The playbook has not changed but now I am getting the following:

`

An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible_ynl6yO/ansible_module_vmware_guest.py”, line 959, in
main()
File “/tmp/ansible_ynl6yO/ansible_module_vmware_guest.py”, line 937, in main
wait_for_ip=module.params[‘wait_for_ip_address’]
File “/tmp/ansible_ynl6yO/ansible_module_vmware_guest.py”, line 494, in deploy_template
template = get_obj(self.content, [vim.VirtualMachine], self.params[‘template’])
KeyError: ‘template’

fatal: [127.0.0.1 → 127.0.0.1]: FAILED! => {
“changed”: false,
“failed”: true,
“invocation”: {
“module_name”: “vmware_guest”
},
“module_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible_ynl6yO/ansible_module_vmware_guest.py", line 959, in \n main()\n File "/tmp/ansible_ynl6yO/ansible_module_vmware_guest.py", line 937, in main\n wait_for_ip=module.params[‘wait_for_ip_address’]\n File "/tmp/ansible_ynl6yO/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”
}

`