From 077a8b489852ceb7fc3ca6b00d52d369f46256a7 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Fri, 17 Jan 2020 15:41:10 -0600 Subject: [PATCH] podman - fix rootless container copy no pause (#66583) Fixes #66263 Signed-off-by: Adam Miller --- .../66263-podman-connection-no-pause-rootless.yml | 2 ++ lib/ansible/plugins/connection/podman.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/66263-podman-connection-no-pause-rootless.yml diff --git a/changelogs/fragments/66263-podman-connection-no-pause-rootless.yml b/changelogs/fragments/66263-podman-connection-no-pause-rootless.yml new file mode 100644 index 00000000000..2bd691de011 --- /dev/null +++ b/changelogs/fragments/66263-podman-connection-no-pause-rootless.yml @@ -0,0 +1,2 @@ +bugfixes: + - podman connection plugin - fix to handle the new default copy pause rootless containers from upstream (https://github.com/ansible/ansible/issues/66263) diff --git a/lib/ansible/plugins/connection/podman.py b/lib/ansible/plugins/connection/podman.py index cc166d0b163..ea974dae14f 100644 --- a/lib/ansible/plugins/connection/podman.py +++ b/lib/ansible/plugins/connection/podman.py @@ -163,10 +163,18 @@ class Connection(ConnectionBase): display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._container_id) if not self._mount_point: rc, stdout, stderr = self._podman( - "cp", [in_path, self._container_id + ":" + out_path], use_container_id=False) + "cp", [in_path, self._container_id + ":" + out_path], use_container_id=False + ) if rc != 0: - raise AnsibleError("Failed to copy file from %s to %s in container %s\n%s" % ( - in_path, out_path, self._container_id, stderr)) + if 'cannot copy into running rootless container with pause set' in to_native(stderr): + rc, stdout, stderr = self._podman( + "cp", ["--pause=false", in_path, self._container_id + ":" + out_path], use_container_id=False + ) + if rc != 0: + raise AnsibleError( + "Failed to copy file from %s to %s in container %s\n%s" % ( + in_path, out_path, self._container_id, stderr) + ) else: real_out_path = self._mount_point + to_bytes(out_path, errors='surrogate_or_strict') shutil.copyfile(