mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Add user flags before container id in podman exec (#19)
* Add user flags before container id in podman exec When user provides an ansible_ssh_user, podman connection plugin includes this values as `--user` flag. This patch fixes the location of this flag according to podman exec command help. Fixes: ansible/ansible#65220 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com> * Don't use mount in case of specified user Co-authored-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
3d1c38c3c2
commit
cc8d4bb451
1 changed files with 9 additions and 4 deletions
|
|
@ -109,7 +109,11 @@ class Connection(ConnectionBase):
|
|||
to_native(
|
||||
self.get_option('podman_extra_args'),
|
||||
errors='surrogate_or_strict'))
|
||||
local_cmd.append(cmd)
|
||||
if isinstance(cmd, str):
|
||||
local_cmd.append(cmd)
|
||||
else:
|
||||
local_cmd.extend(cmd)
|
||||
|
||||
if use_container_id:
|
||||
local_cmd.append(self._container_id)
|
||||
if cmd_args:
|
||||
|
|
@ -149,10 +153,11 @@ class Connection(ConnectionBase):
|
|||
|
||||
# shlex.split has a bug with text strings on Python-2.6 and can only handle text strings on Python-3
|
||||
cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict'))
|
||||
exec_args_list = ["exec"]
|
||||
if self.user:
|
||||
cmd_args_list += ["--user", self.user]
|
||||
exec_args_list.extend(("--user", self.user))
|
||||
|
||||
rc, stdout, stderr = self._podman("exec", cmd_args_list, in_data)
|
||||
rc, stdout, stderr = self._podman(exec_args_list, cmd_args_list, in_data)
|
||||
|
||||
display.vvvvv("STDOUT %r STDERR %r" % (stderr, stderr))
|
||||
return rc, stdout, stderr
|
||||
|
|
@ -161,7 +166,7 @@ class Connection(ConnectionBase):
|
|||
""" Place a local file located in 'in_path' inside container at 'out_path' """
|
||||
super(Connection, self).put_file(in_path, out_path)
|
||||
display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._container_id)
|
||||
if not self._mount_point:
|
||||
if not self._mount_point or self.user:
|
||||
rc, stdout, stderr = self._podman(
|
||||
"cp", [in_path, self._container_id + ":" + out_path], use_container_id=False
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue