PSRemoting from the Ansible controller to a Windows host was working fine and then one day failed with:
…
WINRM CONNECTION ERROR: 500 WinRMTransport. [Errno 104] Connection reset by peer
…
After some investigation, I was able to determine that SSL had become broken on the Windows host.
I was able to resolve this by debugging the Ansible Windows prep script, removing the apparently faulty SSL Listener from the WSUS replica and re-running the prep script.
The prep script is supposed to create a self-signed certificate* to enable PSRemoting over SSL. However, it does not do that if it detects that an SSL listener is already configured for the server and in this case, the WSUS server was reporting that it had one. This was not consistent with what it told me when I viewed the WSUS servers SSL configuration through the IIS GUI, however. There, it was reporting this:
“The site does not have a secure binding (HTTPS) and cannot accept SSL connections”
After stepping through the script with the ISE debugger, I was able to view the listeners after it executes line 134 and from there, I could see the following:
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Listener
Type Keys Name
---- ---- ----
Container {Transport=HTTPS, Address=} Listener_1305953032
Container {Transport=HTTP, Address=} Listener_1084132640
I guessed that something was faulty with the HTTPS listener: Listener_1305953032 and executed this command to remove it:
Remove-Item WSMan:\localhost\Listener\Listener_1305953032
Then, I re-ran the prep script and it successfully created a new self-signed certificate for the server. After that, I was able to securely PSRemote to the WSUS server from the Ansible Controller.
Does the community have a recommendation to prevent this from happening again?
Is a pull request in order?
- Side note: Even though the Windows error message states that the certificate cannot be self-signed, this is apparently not true as the prep script has always created self-signed certs and we’ve been using them successfully