summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2016-01-28 16:02:57 -0800
committerToshio Kuratomi <toshio@fedoraproject.org>2016-01-28 16:02:57 -0800
commit2c825539ffb737051add23dbb9f16a5fef24e469 (patch)
tree0fe733918898921a41dfe293e162cf0b94c0ca65
parent4b1d6214428e48283fb0571f38093c95481aa01c (diff)
downloadansible-synchronize-set-shell.tar.gz
When setting up the local connection for the rsync we need to set the shell as well.synchronize-set-shell
Fixes #13490
-rw-r--r--lib/ansible/plugins/action/synchronize.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py
index bbd67dffec..9b267844b8 100644
--- a/lib/ansible/plugins/action/synchronize.py
+++ b/lib/ansible/plugins/action/synchronize.py
@@ -20,6 +20,7 @@ __metaclass__ = type
import os.path
+from ansible.playbook.play_context import MAGIC_VARIABLE_MAPPING
from ansible.plugins.action import ActionBase
from ansible.plugins import connection_loader
from ansible.utils.boolean import boolean
@@ -185,7 +186,7 @@ class ActionModule(ActionBase):
localhost_ports = set()
for host in C.LOCALHOST:
localhost_vars = task_vars['hostvars'].get(host, {})
- for port_var in ('ansible_port', 'ansible_ssh_port'):
+ for port_var in MAGIC_VARIABLE_MAPPING['port']:
port = localhost_vars.get(port_var, None)
if port:
break
@@ -228,6 +229,21 @@ class ActionModule(ActionBase):
if not use_delegate and remote_transport:
# Create a connection to localhost to run rsync on
new_stdin = self._connection._new_stdin
+
+ # Unike port, there can be only one shell
+ localhost_shell = None
+ for host in C.LOCALHOST:
+ localhost_vars = task_vars['hostvars'].get(host, {})
+ for shell_var in MAGIC_VARIABLE_MAPPING['shell']:
+ localhost_shell = localhost_vars.get(shell_var, None)
+ if localhost_shell:
+ break
+ if localhost_shell:
+ break
+ else:
+ localhost_shell = os.path.basename(C.DEFAULT_EXECUTABLE)
+ self._play_context.shell = localhost_shell
+
new_connection = connection_loader.get('local', self._play_context, new_stdin)
self._connection = new_connection
self._override_module_replaced_vars(task_vars)