Hello,
You can't do that with only ansible modules
Here is the solution we have found to do this :
- Convert template to VM : use ansible to execute a powercli script to do that. (even more easy now with Linux powercli)
- Power on the VM with module vsphere_guest (yes, old module but working really fine)
- Get VMfacts with module vsphere_guest (need that to get the IP of the VM - assumption : that the VM has a network cardwith either a fixed IP or in DHCP)
- Put VM info in in-memory inventory (espcially the IP)
- Log to the VM and update it through standard ansible modules (you can do either linux or windows VMs like that)
- Shut down the VM with a powercli script with a Stop-VMGuest cmdlet (and in this script loop until you get the VM state as powered off) -- use of vpshere_guest is not recommanded to stop the VM because it's not doing a proper shutdown at OS level
- Convert back the VM to template with a powercli script
It may be a little complexe but it's working fine.
Maybe some of this can be done with vmware_guest and vmware_guest_facts, but I don't like the current version of those modules. I had too many bugs with them.
Best Regards,
Sebastien