From 4efdb43ccd1a576e829212657441de540a206135 Mon Sep 17 00:00:00 2001 From: k3it Date: Sat, 14 May 2022 15:16:03 -0400 Subject: [PATCH] maintain proper formating of the remote paths when defined as user@host:/... or host:/... * fixes #360 --- .../361_maintain_proper_formating_remote_paths.yml | 3 +++ plugins/action/synchronize.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/361_maintain_proper_formating_remote_paths.yml diff --git a/changelogs/fragments/361_maintain_proper_formating_remote_paths.yml b/changelogs/fragments/361_maintain_proper_formating_remote_paths.yml new file mode 100644 index 0000000..f370821 --- /dev/null +++ b/changelogs/fragments/361_maintain_proper_formating_remote_paths.yml @@ -0,0 +1,3 @@ +--- +bugfixes: +- synchronize - maintain proper formatting of the remote paths (https://github.com/ansible-collections/ansible.posix/pull/361). diff --git a/plugins/action/synchronize.py b/plugins/action/synchronize.py index a5752b9..9d48e65 100644 --- a/plugins/action/synchronize.py +++ b/plugins/action/synchronize.py @@ -77,7 +77,14 @@ class ActionModule(ActionBase): if self._host_is_ipv6_address(host): return '[%s%s]:%s' % (user_prefix, host, path) - return '%s%s:%s' % (user_prefix, host, path) + + # preserve formatting of remote paths if host or user@host is explicitly defined in the path + if ':' not in path: + return '%s%s:%s' % (user_prefix, host, path) + elif '@' not in path: + return '%s%s' % (user_prefix, path) + else: + return path def _process_origin(self, host, path, user):