# 'community.vmware.vmware\_guest module' does not set password

**URL:** <https://forum.ansible.com/t/community-vmware-vmware-guest-module-does-not-set-password/38221>\
**Category:** Ansible Project\
**Tags:** windows, vmware\
**Created:** [July 12, 2023, 4:46pm UTC](https://forum.ansible.com/t/community-vmware-vmware-guest-module-does-not-set-password/38221 "2023-07-12T16:46:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlemons](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@tlemons](https://forum.ansible.com/u/tlemons)\
**Post date:** [July 12, 2023, 4:46pm UTC](https://forum.ansible.com/t/community-vmware-vmware-guest-module-does-not-set-password/38221/1 "2023-07-12T16:46:06Z")

</div>

Hi

I want to use the community.vmware.vmware\_guest module to set the ‘administrator’ password of a deployed Windows VM.

My environment:

SLES 15 SP5 Docker image

python version = 3.11.3

Ansible Community Package 8.1.0, which includes:

ansible [core 2.15.1]

community.vmware 3.7.0

Here’s my coding of the module:

- name: “Set new administrator account password, then power on the VM”

community.vmware.vmware\_guest:

hostname: “{{ management\_vcenter\_ip }}”

username: “{{ management\_vcenter\_user }}”

password: “{{ management\_vcenter\_password }}”

name: “{{ vm\_name }}”

state: poweredon

validate\_certs: False

wait\_for\_customization: true

customization:

password: “{{ vm\_password }}”

delegate\_to: localhost

I know that the module is somewhat working correctly, in that the Windows VM is powered on when this code is executed. But the ‘administrator’ password is not being changed/set.

Here is the execution output:

TASK [deploy-windowssql : Set new administrator account password, then power on the VM] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

task path: /root/ecdm-ansible/ansible/roles/deploy-windowssql/tasks/main.yml:37

ESTABLISH LOCAL CONNECTION FOR USER: root

EXEC /bin/sh -c ‘echo ~root && sleep 0’

EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo /root/.ansible/tmp`”&& mkdir “`echo /root/.ansible/tmp/ansible-tmp-1689179340.0749025-2228-173707777433521`” && echo ansible-tmp-1689179340.0749025-2228-173707777433521=“`echo /root/.ansible/tmp/ansible-tmp-1689179340.0749025-2228-173707777433521`” ) && sleep 0’

Using module file /root/.local/lib/python3.11/site-packages/ansible\_collections/community/vmware/plugins/modules/vmware\_guest.py

PUT /root/.ansible/tmp/ansible-local-2050puzm93uc/tmp8zsqyt\_a TO /root/.ansible/tmp/ansible-tmp-1689179340.0749025-2228-173707777433521/AnsiballZ\_vmware\_guest.py

EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1689179340.0749025-2228-173707777433521/ /root/.ansible/tmp/ansible-tmp-1689179340.0749025-2228-173707777433521/AnsiballZ\_vmware\_guest.py && sleep 0’

EXEC /bin/sh -c ‘/usr/bin/python /root/.ansible/tmp/ansible-tmp-1689179340.0749025-2228-173707777433521/AnsiballZ\_vmware\_guest.py && sleep 0’

EXEC /bin/sh -c ‘rm -f -r /root/.ansible/tmp/ansible-tmp-1689179340.0749025-2228-173707777433521/ \> /dev/null 2\>&1 && sleep 0’

changed: [ldpdd192.xxx.xxx → localhost] =\> {

“changed”: true,

“instance”: {

“advanced\_settings”: {

“disk.EnableUUID”: “TRUE”,

“ethernet0.pciSlotNumber”: “192”,

“guestInfo.detailed.data”: “architecture=‘X86’ bitness=‘64’ buildNumber=‘20348’ distroVersion=‘Windows’ distroAddlVersion=‘10.0’ familyName=‘Windows’ kernelVersion=‘20348.1726’ prettyName=‘Windows Server 2022, 64-bit (Build 20348.1726)’”,

“guestinfo.ovfEnv”: “”,

“hpet0.present”: “TRUE”,

“migrate.hostLog”: “ldpdd192-4a20f22e.hlog”,

“migrate.hostLogState”: “none”,

“migrate.migrationId”: “5923936046434283652”,

“monitor.phys\_bits\_used”: “43”,

“numa.autosize.cookie”: “40001”,

“numa.autosize.vcpu.maxPerVirtualNode”: “4”,

“nvram”: “ldpdd192.nvram”,

“pciBridge0.pciSlotNumber”: “17”,

“pciBridge0.present”: “TRUE”,

“pciBridge4.functions”: “8”,

“pciBridge4.pciSlotNumber”: “21”,

“pciBridge4.present”: “TRUE”,

“pciBridge4.virtualDev”: “pcieRootPort”,

“pciBridge5.functions”: “8”,

“pciBridge5.pciSlotNumber”: “22”,

“pciBridge5.present”: “TRUE”,

“pciBridge5.virtualDev”: “pcieRootPort”,

“pciBridge6.functions”: “8”,

“pciBridge6.pciSlotNumber”: “23”,

“pciBridge6.present”: “TRUE”,

“pciBridge6.virtualDev”: “pcieRootPort”,

“pciBridge7.functions”: “8”,

“pciBridge7.pciSlotNumber”: “24”,

“pciBridge7.present”: “TRUE”,

“pciBridge7.virtualDev”: “pcieRootPort”,

“sched.swap.derivedName”: “/vmfs/volumes/5ea09c34-9c2c5469-e8f8-1866dafabeba/ldpdd192/ldpdd192-cc9a4b50.vswp”,

“scsi0.pciSlotNumber”: “160”,

“scsi0.sasWWID”: “50 05 05 62 de e1 b9 20”,

“scsi0:0.redo”: “”,

“scsi1.pciSlotNumber”: “224”,

“scsi1.sasWWID”: “50 05 05 62 de e1 b8 20”,

“softPowerOff”: “FALSE”,

“svga.guestBackedPrimaryAware”: “TRUE”,

“svga.present”: “TRUE”,

“viv.moid”: “8764ba7d-9522-4857-825a-47e74fc5fc94:vm-19798:HeJ1jJrEyPdgB+iQU1Un7tqEDwpEUgYLRmMVZdar5TE=”,

“vm.genid”: “6628295188012277178”,

“vm.genidX”: “-8723771621121363354”,

“vmotion.checkpointFBSize”: “4194304”,

“vmotion.checkpointSVGAPrimarySize”: “4194304”,

“vmware.tools.internalversion”: “12352”,

“vmware.tools.requiredversion”: “12320”

},

“annotation”: “xxx”,

“current\_snapshot”: null,

“customvalues”: {},

“guest\_consolidation\_needed”: false,

“guest\_question”: null,

“guest\_tools\_status”: “guestToolsNotRunning”,

“guest\_tools\_version”: “12352”,

“hw\_cluster”: “DpcCluster”,

“hw\_cores\_per\_socket”: 1,

“hw\_datastores”: [

“dpc\_ride\_6”

],

“hw\_esxi\_host”: “ldpdc023.xxx.xxx”,

“hw\_eth0”: {

“addresstype”: “assigned”,

“ipaddresses”: null,

“label”: “Network adapter 1”,

“macaddress”: “00:50:56:87:7d:7b”,

“macaddress\_dash”: “00-50-56-87-7d-7b”,

“portgroup\_key”: “dvportgroup-1087”,

“portgroup\_portkey”: “49”,

“summary”: “DVSwitch: 50 07 d6 62 2a 0e d8 f5-0e d0 df 88 ea d0 31 ce”

},

“hw\_files”: [

“[dpc\_ride\_6] ldpdd192/ldpdd192.vmx”,

“[dpc\_ride\_6] ldpdd192/ldpdd192.vmxf”,

“[dpc\_ride\_6] ldpdd192/ldpdd192.nvram”,

“[dpc\_ride\_6] ldpdd192/ldpdd192.vmsd”,

“[dpc\_ride\_6] ldpdd192/vmware-3.log”,

“[dpc\_ride\_6] ldpdd192/vmware-2.log”,

“[dpc\_ride\_6] ldpdd192/vmware-1.log”,

“[dpc\_ride\_6] ldpdd192/vmware.log”,

“[dpc\_ride\_6] ldpdd192/vmware-4.log”,

“[dpc\_ride\_6] ldpdd192/ldpdd192.vmdk”

],

“hw\_folder”: “/xxx/vm”,

“hw\_guest\_full\_name”: null,

“hw\_guest\_ha\_state”: false,

“hw\_guest\_id”: null,

“hw\_interfaces”: [

“eth0”

],

“hw\_is\_template”: false,

“hw\_memtotal\_mb”: 6144,

“hw\_name”: “ldpdd192”,

“hw\_power\_status”: “poweredOn”,

“hw\_processor\_count”: 4,

“hw\_product\_uuid”: “42070532-dee1-b925-e5c2-5be4873fefda”,

“hw\_version”: “vmx-13”,

“instance\_uuid”: “5007de96-fe50-cd63-bcf6-4fc3f5ea7494”,

“ipv4”: null,

“ipv6”: null,

“module\_hw”: true,

“moid”: “vm-19798”,

“snapshots”: ,

“tpm\_info”: {

“provider\_id”: null,

“tpm\_present”: false

},

“vimref”: “vim.VirtualMachine:vm-19798”,

“vnc”: {}

},

“invocation”: {

“module\_args”: {

“advanced\_settings”: ,

“annotation”: null,

“cdrom”: ,

“cluster”: null,

“convert”: null,

“customization”: {

“autologon”: null,

“autologoncount”: null,

“dns\_servers”: null,

“dns\_suffix”: null,

“domain”: null,

“domainadmin”: null,

“domainadminpassword”: null,

“existing\_vm”: null,

“fullname”: null,

“hostname”: null,

“hwclockUTC”: null,

“joindomain”: null,

“joinworkgroup”: null,

“orgname”: null,

“password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,

“productid”: null,

“runonce”: null,

“script\_text”: null,

“timezone”: null

},

“customization\_spec”: null,

“customvalues”: ,

“datacenter”: “ha-datacenter”,

“datastore”: null,

“delete\_from\_inventory”: false,

“disk”: ,

“esxi\_hostname”: null,

“folder”: null,

“force”: false,

“guest\_id”: null,

“hardware”: {

“boot\_firmware”: null,

“cpu\_limit”: null,

“cpu\_reservation”: null,

“cpu\_shares”: null,

“cpu\_shares\_level”: null,

“hotadd\_cpu”: null,

“hotadd\_memory”: null,

“hotremove\_cpu”: null,

“iommu”: null,

“max\_connections”: null,

“mem\_limit”: null,

“mem\_reservation”: null,

“mem\_shares”: null,

“mem\_shares\_level”: null,

“memory\_mb”: null,

“memory\_reservation\_lock”: null,

“nested\_virt”: null,

“num\_cpu\_cores\_per\_socket”: null,

“num\_cpus”: null,

“scsi”: null,

“secure\_boot”: null,

“version”: null,

“virt\_based\_security”: null,

“vpmc\_enabled”: null

},

“hostname”: “ldpdc211.xxx.xxx”,

“is\_template”: false,

“linked\_clone”: false,

“name”: “ldpdd192”,

“name\_match”: “first”,

“networks”: ,

“nvdimm”: {

“label”: null,

“size\_mb”: 1024,

“state”: null

},

“password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,

“port”: 443,

“proxy\_host”: null,

“proxy\_port”: null,

“resource\_pool”: null,

“snapshot\_src”: null,

“state”: “poweredon”,

“state\_change\_timeout”: 0,

“template”: null,

“use\_instance\_uuid”: false,

“username”: [administrator@vsphere.local](mailto:administrator@vsphere.local),

“uuid”: null,

“validate\_certs”: false,

“vapp\_properties”: ,

“wait\_for\_customization”: true,

“wait\_for\_customization\_timeout”: 3600,

“wait\_for\_ip\_address”: false,

“wait\_for\_ip\_address\_timeout”: 300

}

}

}

I looked in [https://github.com/ansible-collections/community.vmware/issues?page=3&q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+vmware\_guest](https://github.com/ansible-collections/community.vmware/issues?page=3&q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+vmware_guest), and didn’t see this issue.

Thoughts, please.

Thanks

tl

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@atul\_mohan](https://forum.ansible.com/u/atul_mohan)\
**Post date:** [August 19, 2023, 6:06pm UTC](https://forum.ansible.com/t/community-vmware-vmware-guest-module-does-not-set-password/38221/2 "2023-08-19T18:06:04Z")

</div>

The module you’re using, community.vmware.vmware\_guest, is not designed to directly change the password of an existing guest VM. Instead, it’s intended for tasks like deploying and managing virtual machines. Changing the password of an existing guest VM requires interacting with the guest OS, which is outside the scope of the vmware\_guest module.

---

<div class="post-metadata">

**Author:** ![tlemons](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@tlemons](https://forum.ansible.com/u/tlemons)\
**Post date:** [August 22, 2023, 8:06pm UTC](https://forum.ansible.com/t/community-vmware-vmware-guest-module-does-not-set-password/38221/3 "2023-08-22T20:06:46Z")

</div>

Hi Atul

Thank you for this guidance. A colleague found that it’s possible to set the password of a Windows system’s ‘administrator’ account where the account is set for change-on-first-logon by taking advantage of the ‘customization’ facility in ‘vmware\_guest’:

- name: “Set a new administrator account password and power on the VM”  
community.vmware.vmware\_guest:  
hostname: “{{ management\_vcenter\_ip }}”  
username: “{{ management\_vcenter\_user }}”  
password: “{{ management\_vcenter\_password }}”  
datacenter: “{{ datacenter }}”  
cluster: “{{ cluster }}”  
name: “{{ vm\_name }}”  
state: present  
networks:
- name: “{{ vm\_network }}”  
validate\_certs: False  
wait\_for\_customization: true  
wait\_for\_ip\_address: true  
customization:  
password: “{{ vm\_password }}”  
existing\_vm: True  
delegate\_to: localhost

For setting the password of the ‘root’ account on a Linux system where the password was set for change-on-first-login, this logic worked:

- name: “Set root password”  
delegate\_to: localhost  
ansible.builtin.expect:  
echo: true  
command: “ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@{{ vm\_ip }} echo ‘Success’”  
responses:  
"Password: ": “{{ vm\_original\_password }}”  
"Current password: ": “{{ vm\_original\_password }}”  
"New password: ": “{{ vm\_password }}”  
"Retype new password: ": “{{ vm\_password }}”
