Don't use rsync-path in synchronize with docker

When you become: with synchronize and docker it sets the rsync-path to
"sudo rsync" to launch rsync on the server as root. Unfortunately due to
docker exec doing stricter argument parsing than ssh this fails to
launch rsync on the server and the sync fails.

For docker though we don't need to launch rsync with sudo we can simply
docker exec -u <user> and rsync as normal to get around the problem.

Closes #20117
pull/20158/head^2
Jamie Lennox 8 years ago committed by Toshio Kuratomi
parent a94a48f85f
commit 27d218f85d

@ -331,8 +331,13 @@ class ActionModule(ActionBase):
# Allow custom rsync path argument
rsync_path = _tmp_args.get('rsync_path', None)
# backup original become as we are probably about to unset it
become = self._play_context.become
if not dest_is_local:
if self._play_context.become and not rsync_path:
# don't escalate for docker. doing --rsync-path with docker exec fails
# and we can switch directly to the user via docker arguments
if self._play_context.become and not rsync_path and self._remote_transport != 'docker':
# If no rsync_path is set, become was originally set, and dest is
# remote then add privilege escalation here.
if self._play_context.become_method == 'sudo':
@ -363,7 +368,9 @@ class ActionModule(ActionBase):
_tmp_args['rsync_opts'] = self._task.args.get('rsync_opts', '').split(' ')
if '--blocking-io' not in _tmp_args['rsync_opts']:
_tmp_args['rsync_opts'].append('--blocking-io')
if user is not None:
if become and self._play_context.become_user:
_tmp_args['rsync_opts'].append("--rsh='%s exec -u %s -i'" % (self._docker_cmd, self._play_context.become_user))
elif user is not None:
_tmp_args['rsync_opts'].append("--rsh='%s exec -u %s -i'" % (self._docker_cmd, user))
else:
_tmp_args['rsync_opts'].append("--rsh='%s exec -i'" % self._docker_cmd)

Loading…
Cancel
Save