We have an ansible pipeline that connects to a windows system. After it runs, there are many “Host process for WinRM plug-ins” processes still hanging there and eating memory. We have to end the tasks manually or reboot the system.
We connect to the system via psrp with these settings:
ansible_psrp_auth: basic
ansible_psrp_configuration_name: switchUserSession
ansible_psrp_cert_validation: ignore
ansible_psrp_read_timeout: 60
ansible_psrp_connection_timeout: 60
wsman_idletimeout: 60000
The switchUserSession is a saved PowerShell session we register with register-pssessionconfiguration to run as a different user. Our connecting user doesn’t have administrative privileges.
In this example we see that the ansible process was done in 2 seconds, but the shell stayed on (ShellRunTime and ShellInactivity).
PS C:\WINDOWS\system32> Get-WSManInstance -ResourceURI `
>> http://schemas.microsoft.com/wbem/wsman/1/windows/shell `
>> -Enumerate
rsp : http://schemas.microsoft.com/wbem/wsman/1/windows/shell
lang : en-US
ShellId : 7208E7C0-B308-4FEE-BE0C-8D84223BCAC3
ResourceUri : http://schemas.microsoft.com/powershell/switchUserSession
Owner : ansibleUser
ClientIP : 192.168.1.1
ProcessId : 7624
IdleTimeOut : PT300.000S
InputStreams : stdin pr
OutputStreams : stdout
MaxIdleTimeOut : PT2147483.647S
Locale : en-US
DataLocale : en-US
CompressionMode : NoCompression
ProfileLoaded : Yes
Encoding : UTF8
BufferMode : Block
State : Disconnected
ShellRunTime : P0DT0H5M57S
ShellInactivity : P0DT0H5M55S
MemoryUsed : 128MB
ChildProcesses : 0
We already set out IdleTimeout for WinRM to 5 minutes, this helped. We would still like to figure out why those sessions are not being cleared on disconnect. This sometimes leads to failures in our tasks, because there isn’t enough RAM left on the system to start processes.