My corporate firewall policy allows only 20 connections per minute 60 seconds between the same source and destinations.
Owing to this the ansible play hangs after a while.
I would like multiple tasks to use the same ssh session rather than creating new sessions. For this purpose i set the below pipelining = True in the local folder ansible.cfg as well as in the command line.
The playbook is too big to be shared here but it is this task which loops and this is where it hangs due to more than 20 ssh connections in 60 seconds.
I agree. This would cause problems just for a large number of standard
websites, unless your IT networking people are relying on browsers using
persistent connections, and even then, static content, images, and dynamic
content are often going to be supplied by different parts of a CDN.
I don’t think pipelining will actually result in reusing the same SSH session across the play. It will reduce the number of SSH sessions per task, but I think it will still result in many new SSH sessions.
I can’t figure out how to reuse sessions for a non-SSH connector.
A few things:
- pipelining is not about connection reuse but about writing to disk
- for ssh connection plugin, the control persist settings are what
reuse connections/authentication, but not sessions
- the synchronize action does it's own connection handling
Kind of, there is ansible-connection but it can be complicated. I've
been toying around with the idea of a 'persistent: no|yes' keyword to
allow for the use/reuse of persistent sessions. This would first look
at the connection plugin for support and fallback to a connection
manager+ansible-connection on controller otherwise.
Why would you need to check whether the connection plugin supports such a new feature? ConnectionBase already has methods for _connect, connected, reset and close, separate from exec_command, put_file and fetch_file
So wouldn’t this work for all connection plugins if Ansible just starts calling exec_command and put_file multiple times per connection?
Ansible already does this per per task, this still just uses 'shared
auth' in the case of ssh, not full session (unlike winrm/prsp). In any
case this feature would be 'across tasks' or block of tasks.