I'm seeing some very inconsistent results when trying to run a Powershell script. through the script module. I can't quite pinpoint it yet but I think it has to do when I run an external application, through Powershell. To be specific I am running an unattended dcpromo command. My playbook appears to be correct because if I run it 3 to 4 times it will eventually complete and everything will work. However during various runs it often gets hung up with either errors in powershell, which often don't get reported back or what seems to be winrm not responding anymore. Possibly a loss connection from pywinrm. I really don't know. I've been attempting to debug and troubleshoot it, however the results are not consistent enough for me to determine where to start looking.
The first question is, are there some specific rules to running a powershell script with the script module. Do I need to exit a certain way? Or is there a timeout feature for an ansible task where it will just continue with the playbook? Often times the powershell script completes correctly its just ansible gets hung and does not continue.
I do feel like this has something to do with pywinrm since many many times the script will complete it's just ansible doesen't know about it. How can I debug pywinrm while in an ansible run. I've tried -vvvvv(5x, I think that's the max) and really it just stalls more often then not at the WinRM EXEC call. Is there anything I can do in the ansible playbook or the powershell script that will create a consistent result or are there some steps that I can take to try and debug pywinrm?
Nic