Hello,
I mentioned on “ansible project” that I had difficulties with the performance of ansible on my “network”. In fact, I try to use ansible on a set of remote machines that are not hosted by the same provider.
The ssh round trip time is not very good.
- my playbook of ~170 tasks was taking more than 20 minutes with paramiko
- between 6 and 8 minutes with ssh + control persist, approximately the same with accelerate.
I drilled down (-vvv) to understand why it was still taking this long. I use a lot of sudo_user != root so for every command I have a minimum of :
- one ssh roundtrip to create tmp directories
- one ssh roundtrip to put the command file
- one ssh roundtrip to chmod the file (sudo_user != root)
- one ssh roundtrip to execute the command with the sudo_user
- one ssh roundtrip to remove the tmp directories (sudo_user != root)
I have a working prototype that fully works on my playbook where this is minimized to one roundtrip instead of five ; my playbook now takes between 2-4 minutes (I’d say 2x gain over controlpersist in my slow network use case)
Basically for the modified “connection_plugin/ssh.py” :
- no tmp files are created in the main case
- the module is compressed on-the-fly (zlib) instead of written on the remote via scp/sftp
- the compressed module is piped over ssh to the remote sudo_user (directly to the sudo_user, no need to chmod)
- the remote sudo_user decompresses the module on-the-fly and pipes it to the extracted shebang
It is still a prototype and I had to take some shortcuts to make a proof of concept (only ‘new’ modules, only tested with ssh keys and not with password, …).
Do you think the speed boost and the lowering of the # of ssh roundtrips are sufficient to find room in the already busy ansible roadmap ?
I would really like if we could work on at least making it possible to use this as an alternative connection_plugin.
This would certainly mean a few additional features in the connection_plugin API, but the difference can be very light.
Tell me what you think. I’ll clean up the code in the next few days and send a github link with the diff.