use just 'remote_user' as user for the docker connection

This commit is contained in:
Thomas Steinbach 2015-12-20 18:18:29 +01:00 committed by Toshio Kuratomi
parent 4ac49ed4a8
commit 14dfad730e

View file

@ -121,9 +121,8 @@ class Connection(ConnectionBase):
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
executable = C.DEFAULT_EXECUTABLE.split()[0] if C.DEFAULT_EXECUTABLE else '/bin/sh'
exec_user = self._play_context.become_user if self._play_context.become else self._play_context.remote_user
# -i is needed to keep stdin open which allows pipelining to work
local_cmd = [self.docker_cmd, "exec", '-u', exec_user, '-i', self._play_context.remote_addr, executable, '-c', cmd]
local_cmd = [self.docker_cmd, "exec", '-u', self._play_context.remote_user, '-i', self._play_context.remote_addr, executable, '-c', cmd]
display.vvv("EXEC %s" % (local_cmd,), host=self._play_context.remote_addr)
local_cmd = [to_bytes(i, errors='strict') for i in local_cmd]
@ -170,8 +169,7 @@ class Connection(ConnectionBase):
# Older docker doesn't have native support for copying files into
# running containers, so we use docker exec to implement this
executable = C.DEFAULT_EXECUTABLE.split()[0] if C.DEFAULT_EXECUTABLE else '/bin/sh'
exec_user = self._play_context.become_user if self._play_context.become else self._play_context.remote_user
args = [self.docker_cmd, "exec", "-u", exec_user, "-i", self._play_context.remote_addr, executable, "-c",
args = [self.docker_cmd, "exec", '-u', self._play_context.remote_user, "-i", self._play_context.remote_addr, executable, "-c",
"dd of=%s bs=%s" % (out_path, BUFSIZE)]
args = [to_bytes(i, errors='strict') for i in args]
with open(to_bytes(in_path, errors='strict'), 'rb') as in_file: