From c1493945565dfc3b77175abd17ddf3bf44bc8d5d Mon Sep 17 00:00:00 2001 From: Mike Graves Date: Mon, 2 May 2022 13:41:21 -0400 Subject: [PATCH] k8s_cp - fix issue when using local_path (#422) (#442) [backport/2.3] k8s_cp - fix issue when using local_path (#422) Depends-On: #446 k8s_cp - fix issue when using local_path SUMMARY When copying from local path to pod, the file is found on the controller node instead of the managed node. This PR aims to resolve this issue. Fixes #421 ISSUE TYPE Bugfix Pull Request COMPONENT NAME k8s_cp Reviewed-by: Abhijeet Kasurde Reviewed-by: Mike Graves mgraves@redhat.com (cherry picked from commit 1d05cf5) --- .../fragments/422-k8s_cp-fix-issue-when-issue-local_path.yaml | 2 ++ plugins/action/k8s_info.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/422-k8s_cp-fix-issue-when-issue-local_path.yaml diff --git a/changelogs/fragments/422-k8s_cp-fix-issue-when-issue-local_path.yaml b/changelogs/fragments/422-k8s_cp-fix-issue-when-issue-local_path.yaml new file mode 100644 index 0000000000..5677ff8c77 --- /dev/null +++ b/changelogs/fragments/422-k8s_cp-fix-issue-when-issue-local_path.yaml @@ -0,0 +1,2 @@ +bugfixes: + - k8s_cp - fix issue when using parameter local_path with file on managed node. (https://github.com/ansible-collections/kubernetes.core/issues/421). diff --git a/plugins/action/k8s_info.py b/plugins/action/k8s_info.py index 674ebcb906..cfcbb28d14 100644 --- a/plugins/action/k8s_info.py +++ b/plugins/action/k8s_info.py @@ -380,7 +380,7 @@ def run(self, tmp=None, task_vars=None): local_path = self._task.args.get("local_path") state = self._task.args.get("state", None) - if local_path and state == "to_pod": + if local_path and state == "to_pod" and not remote_transport: new_module_args["local_path"] = self.get_file_realpath(local_path) # Execute the k8s_* module.