# vmware\_guest: fails with 'incorrect username or password' error

**URL:** <https://forum.ansible.com/t/vmware-guest-fails-with-incorrect-username-or-password-error/25211>\
**Category:** Ansible Project\
**Created:** [August 9, 2017, 6:54pm UTC](https://forum.ansible.com/t/vmware-guest-fails-with-incorrect-username-or-password-error/25211 "2017-08-09T18:54:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skagnatti](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@Skagnatti](https://forum.ansible.com/u/Skagnatti)\
**Post date:** [August 9, 2017, 6:54pm UTC](https://forum.ansible.com/t/vmware-guest-fails-with-incorrect-username-or-password-error/25211/1 "2017-08-09T18:54:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Skagnatti](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@Skagnatti](https://forum.ansible.com/u/Skagnatti)\
**Post date:** [August 10, 2017, 8:40pm UTC](https://forum.ansible.com/t/vmware-guest-fails-with-incorrect-username-or-password-error/25211/2 "2017-08-10T20:40:26Z")

</div>

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”  
}

`
