From aafb5bb1688fee2861e8712d89cca509d1500329 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Wed, 22 Mar 2017 12:46:04 +0100 Subject: [PATCH] synchronize: explicitly set the executable for localhost Otherwise the executable for the destination is also used on the local machine and this might not exist. Fixes: #22867 (cherry picked from commit 7a00f28804450cd01600d9dc9ad22428996bc06b) --- lib/ansible/plugins/action/synchronize.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py index 61d78571ca7..1a849f25726 100644 --- a/lib/ansible/plugins/action/synchronize.py +++ b/lib/ansible/plugins/action/synchronize.py @@ -273,6 +273,20 @@ class ActionModule(ActionBase): localhost_shell = os.path.basename(C.DEFAULT_EXECUTABLE) self._play_context.shell = localhost_shell + # Unike port, there can be only one executable + localhost_executable = None + for host in C.LOCALHOST: + localhost_vars = task_vars['hostvars'].get(host, {}) + for executable_var in MAGIC_VARIABLE_MAPPING['executable']: + localhost_executable = localhost_vars.get(executable_var, None) + if localhost_executable: + break + if localhost_executable: + break + else: + localhost_executable = C.DEFAULT_EXECUTABLE + self._play_context.executable = localhost_executable + new_connection = connection_loader.get('local', self._play_context, new_stdin) self._connection = new_connection self._override_module_replaced_vars(task_vars)