ansible/ansible — pull request #5226 by jeromew (2013-12-09 19:34:00+00:00)
Title: Ansible ssh alt

This is a PR for an alternate ssh connection_plugin following a discussion on devel ML :
* https://groups.google.com/forum/#!topic/ansible-devel/vCEZOmcLipU
* https://groups.google.com/forum/#!topic/ansible-devel/67ltJ2OGlLc

Use with -c ssh_alt

The objective is to minimize the number of ssh roundtrips for each command/module execution.
Currently when sudo'ing we often have up to 5 ssh round trips :
* make tmp dir
* change rights
* move module code
* execute module
* remove tmp dir

The new plugin brings this down to one round-trip in most cases when a tmp directory is not necessary (by piping the module source code directly over ssh to the extracted module shebang).

This implementation needs to be tested but is believed to hopefully handle most of the cases.

It should work in these cases :
* when -k and -K are needed
* old style & new style modules
* specific modules needing tmp dir (for example copy)

Implementation details :
* during the early decision to create a tmp dir or not, a hardcoded list of module needing a tmp path: 'assemble', 'copy', 'script', 'template', 'unarchive'. This list can easily be removed by adding NEEDS_TMPPATH = True in the respective modules. I did not do it to minimize the footprint of the PR and draw attention to these early/late scenarios.