diff --git a/changelogs/fragments/synchronize.yml b/changelogs/fragments/synchronize.yml new file mode 100644 index 0000000000..d49e6f1e38 --- /dev/null +++ b/changelogs/fragments/synchronize.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - synchronize - use _find_needle to find the file in path (https://github.com/ansible-collections/ansible.posix/issues/381). diff --git a/plugins/action/synchronize.py b/plugins/action/synchronize.py index 34c9015952..61fe3fd593 100644 --- a/plugins/action/synchronize.py +++ b/plugins/action/synchronize.py @@ -48,10 +48,7 @@ def _get_absolute_path(self, path): if ':' in path or path.startswith('/'): return path - if self._task._role is not None: - path = self._loader.path_dwim_relative(self._task._role._role_path, 'files', path) - else: - path = self._loader.path_dwim_relative(self._loader.get_basedir(), 'files', path) + path = self._find_needle('files', path) if original_path and original_path[-1] == '/' and path[-1] != '/': # make sure the dwim'd path ends in a trailing "/"