Ansible Windows Connections - 4 second initialization? Pipelining?

Hi guys,

I’m doing a POC of Ansible for my company. We have a mixture of Linux and Windows servers.While playing around with windows i found that just running a simple powershell script which does “exit 0” will take about 4 seconds every time.

I am not sure why this is the case, i tried to enable Pipelining but it seems that this is for SSH connections only and not for windows Powershell connections.

here is an example run i did:

PLAY RECAP ********************************************************************
base | Unzip Package --------------------------------------------------- 24.62s
Update Web.Config2 ------------------------------------------------------ 3.85s
Update Web.Config1 ------------------------------------------------------ 3.82s
Update Web.Config3 ------------------------------------------------------ 3.78s

The “Update Web.Config” tasks just run the simple powershell script which basically does nothing.

Since we are testing Ansible as a viable CI component I will need to solve this or else Ansible will not be viable for our usages due to the overkill of 4 seconds per task.

Can anyone please assist?

Hi Amir,

The biggest issue here is that the pywinrm library uses urllib2, which doesn’t natively support keep-alive connections. Due to the way PowerShell remoting works, each command requires at least 4 HTTP requests and must make a new connection for each one.

I have a fork of pywinrm using requests instead, which seems to help significantly with performance. I need to find time to finish up a few parts of it, but you’re welcome to try and see how it works for you.