mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 23:25:28 +01:00
Synchronize plugin: Do not turn an SSH path into an absolute path
SSH paths of the form user@host:/remote/path can be used as either src or dest with rsync. As the synchronize module already uses the presence of ':' to detect a source/destination over SSH, this commit updates the action plugin accordingly. Without this commit, the path is turned into /local/path/user@host:/remote/path, which is not a valid syntax for rsync.
This commit is contained in:
parent
74c8ca58e2
commit
ebb4d94da8
1 changed files with 5 additions and 9 deletions
|
|
@ -33,7 +33,7 @@ class ActionModule(ActionBase):
|
|||
def _get_absolute_path(self, path):
|
||||
original_path = path
|
||||
|
||||
if path.startswith('rsync://'):
|
||||
if path.startswith('rsync://') or path.startswith('/') or ':' in path:
|
||||
return path
|
||||
|
||||
if self._task._role is not None:
|
||||
|
|
@ -73,7 +73,6 @@ class ActionModule(ActionBase):
|
|||
if host not in C.LOCALHOST:
|
||||
return self._format_rsync_rsh_target(host, path, user)
|
||||
|
||||
if ':' not in path and not path.startswith('/'):
|
||||
path = self._get_absolute_path(path=path)
|
||||
return path
|
||||
|
||||
|
|
@ -103,7 +102,6 @@ class ActionModule(ActionBase):
|
|||
task_args['_substitute_controller'] = True
|
||||
return self._format_rsync_rsh_target(host, path, user)
|
||||
|
||||
if ':' not in path and not path.startswith('/'):
|
||||
path = self._get_absolute_path(path=path)
|
||||
return path
|
||||
|
||||
|
|
@ -350,9 +348,7 @@ class ActionModule(ActionBase):
|
|||
else:
|
||||
# Still need to munge paths (to account for roles) even if we aren't
|
||||
# copying files between hosts
|
||||
if not src.startswith('/'):
|
||||
src = self._get_absolute_path(path=src)
|
||||
if not dest.startswith('/'):
|
||||
dest = self._get_absolute_path(path=dest)
|
||||
|
||||
_tmp_args['src'] = src
|
||||
|
|
|
|||
Loading…
Reference in a new issue