1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Support using paramiko to set up accelerate connection

Adds original_transport attribute to Runner to track what the original
transport was before it is changed to 'accelerate'.
If using paramiko in original_transport, uses ParamikoConnection.  If
not, falls back to SSHConnection like before.
This commit is contained in:
Stephen Fromm 2013-09-04 13:50:53 -07:00
parent 7b13b1e03e
commit d704b55860
2 changed files with 20 additions and 8 deletions

View file

@ -185,6 +185,7 @@ class Runner(object):
self.accelerate = accelerate self.accelerate = accelerate
self.accelerate_port = accelerate_port self.accelerate_port = accelerate_port
self.callbacks.runner = self self.callbacks.runner = self
self.original_transport = self.transport
if self.accelerate: if self.accelerate:
# if we're using accelerated mode, force the local # if we're using accelerated mode, force the local

View file

@ -23,6 +23,7 @@ import struct
import time import time
from ansible.callbacks import vvv from ansible.callbacks import vvv
from ansible.runner.connection_plugins.ssh import Connection as SSHConnection from ansible.runner.connection_plugins.ssh import Connection as SSHConnection
from ansible.runner.connection_plugins.paramiko_ssh import Connection as ParamikoConnection
from ansible import utils from ansible import utils
from ansible import errors from ansible import errors
from ansible import constants from ansible import constants
@ -49,6 +50,16 @@ class Connection(object):
self.fbport = port[1] self.fbport = port[1]
self.is_connected = False self.is_connected = False
if self.runner.original_transport == "paramiko":
self.ssh = ParamikoConnection(
runner=self.runner,
host=self.host,
port=self.port,
user=self.user,
password=password,
private_key_file=private_key_file
)
else:
self.ssh = SSHConnection( self.ssh = SSHConnection(
runner=self.runner, runner=self.runner,
host=self.host, host=self.host,