From 2cbf28385a8f3574212651996dbdd240db031880 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 5 Sep 2013 20:20:25 -0500 Subject: [PATCH] Move check for accelerate mode deeper to account for ansible_connection Fixes #4045 --- lib/ansible/runner/__init__.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 439bd86cbb0..6d98588a76f 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -186,13 +186,7 @@ class Runner(object): self.accelerate_port = accelerate_port self.callbacks.runner = self - if self.accelerate and self.transport != 'local': - # if we're using accelerated mode, force the - # transport to accelerate - self.transport = "accelerate" - if not self.accelerate_port: - self.accelerate_port = C.ACCELERATE_PORT - elif self.transport == 'smart': + if self.transport == 'smart': # if the transport is 'smart' see if SSH can support ControlPersist if not use paramiko # 'smart' is the default since 1.2.1/1.3 cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -579,6 +573,14 @@ class Runner(object): actual_pass = inject.get('ansible_ssh_pass', self.remote_pass) actual_transport = inject.get('ansible_connection', self.transport) actual_private_key_file = inject.get('ansible_ssh_private_key_file', self.private_key_file) + + if self.accelerate and actual_transport != 'local': + # if we're using accelerated mode, force the + # transport to accelerate + actual_transport = "accelerate" + if not self.accelerate_port: + self.accelerate_port = C.ACCELERATE_PORT + if actual_transport in [ 'paramiko', 'ssh', 'accelerate' ]: actual_port = inject.get('ansible_ssh_port', port) @@ -620,7 +622,7 @@ class Runner(object): inject['ansible_ssh_user'] = actual_user try: - if self.transport == 'accelerate': + if actual_transport == 'accelerate': # for accelerate, we stuff both ports into a single # variable so that we don't have to mangle other function # calls just to accomodate this one case