# vmware\_guest -customization block not being executed

**URL:** <https://forum.ansible.com/t/vmware-guest-customization-block-not-being-executed/37061>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [September 2, 2022, 8:14pm UTC](https://forum.ansible.com/t/vmware-guest-customization-block-not-being-executed/37061 "2022-09-02T20:14:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Bachmeyer](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Chris\_Bachmeyer](https://forum.ansible.com/u/Chris_Bachmeyer)\
**Post date:** [September 2, 2022, 8:14pm UTC](https://forum.ansible.com/t/vmware-guest-customization-block-not-being-executed/37061/1 "2022-09-02T20:14:36Z")

</div>

hello all,

I am using the vmware\_guest module to deploy vms to our vsphere environment and everything is working well. Now there is a requirement to handle post-processing of the vms once they are deployed which requires WinRM on Windows. The goal is to use vmware\_guest module to use the “runonce:” param in order to configure WinRM using the ConfigureRemotingForAnsible.ps1 script and then to join the win system to the domain with using the “joindomain:” parameter.

The issue I am running into is that it appears the “runonce:” parameter is executed after the system is joined to the domain. Once the system is joined, it autologons to the domain but there is a Cyber banner pop-up and have to hit “OK” to continue the login process. This interferes with the running of pwsh script so I decided to try to break up the two items.

My thoughts were to create two vmware\_guest Ansible tasks, the first one to create the vm and run the script to configure WinRM and the second vmware\_guest task to join the system automatically to AD.

The first customization block works well and looks like …

customization:  
autologon: yes  
autologoncount: 8  
password: “{{ local\_pass }}”  
existing\_vm: false  
hostname: “{{ vm\_name }}”  
dns\_servers:

- “{{ dns\_ns1 }}”
- “{{ dns\_ns2 }}”  
runonce:
- powershell.exe -ExecutionPolicy Unrestricted -File C:\Windows\Temp\ConfigureRemotingForAnsible.ps1 -ForceNewSSLCert  
wait\_for\_customization: yes

The second customization block in the second Ansible task looks like …

customization:  
autologon: yes  
autologoncount: 8  
password: “{{ local\_pass }}”  
existing\_vm: true  
domainadmin: “{{ elevated }}”  
domainadminpassword: “{{ elevated\_pass }}”  
joindomain: my-domain  
wait\_for\_customization: yes

No errors are produced but the second customization block in the second Ansible task doesn’t seem to be executed. The first task is marked as “changed” while the second task is marked as “ok.”

Any ideas?

Thanks!
