From 950622cebd18160d796397b4a17ddcbc341e7117 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Sun, 16 Aug 2015 02:36:49 -0400 Subject: [PATCH] made sure they all look in files/vars/template dirs also when executed in play and not only from task --- lib/ansible/plugins/action/assemble.py | 3 +-- lib/ansible/plugins/action/copy.py | 2 +- lib/ansible/plugins/action/include_vars.py | 2 +- lib/ansible/plugins/action/patch.py | 2 +- lib/ansible/plugins/action/script.py | 2 +- lib/ansible/plugins/action/synchronize.py | 7 ++++++- lib/ansible/plugins/action/template.py | 2 +- lib/ansible/plugins/action/unarchive.py | 2 +- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/ansible/plugins/action/assemble.py b/lib/ansible/plugins/action/assemble.py index 3269c6e01e9..1f74ffe7bcd 100644 --- a/lib/ansible/plugins/action/assemble.py +++ b/lib/ansible/plugins/action/assemble.py @@ -96,8 +96,7 @@ class ActionModule(ActionBase): elif self._task._role is not None: src = self._loader.path_dwim_relative(self._task._role._role_path, 'files', src) else: - # the source is local, so expand it here - src = self._loader.path_dwim(os.path.expanduser(src)) + src = self._loader.path_dwim_relative(self._loader.get_basedir(), 'files', src) _re = None if regexp is not None: diff --git a/lib/ansible/plugins/action/copy.py b/lib/ansible/plugins/action/copy.py index e18f6d754da..8178d7eb0b2 100644 --- a/lib/ansible/plugins/action/copy.py +++ b/lib/ansible/plugins/action/copy.py @@ -88,7 +88,7 @@ class ActionModule(ActionBase): if self._task._role is not None: source = self._loader.path_dwim_relative(self._task._role._role_path, 'files', source) else: - source = self._loader.path_dwim(source) + source = self._loader.path_dwim_relative(self._loader.get_basedir(), 'files', source) # A list of source file tuples (full_path, relative_path) which will try to copy to the destination source_files = [] diff --git a/lib/ansible/plugins/action/include_vars.py b/lib/ansible/plugins/action/include_vars.py index 37b4bff1d3e..31d93e7acc2 100644 --- a/lib/ansible/plugins/action/include_vars.py +++ b/lib/ansible/plugins/action/include_vars.py @@ -36,7 +36,7 @@ class ActionModule(ActionBase): if self._task._role: source = self._loader.path_dwim_relative(self._task._role._role_path, 'vars', source) else: - source = self._loader.path_dwim(source) + source = self._loader.path_dwim_relative(self._loader.get_basedir(), 'vars', source) if os.path.exists(source): (data, show_content) = self._loader._get_file_contents(source) diff --git a/lib/ansible/plugins/action/patch.py b/lib/ansible/plugins/action/patch.py index 65417e50c3a..5355ad68231 100644 --- a/lib/ansible/plugins/action/patch.py +++ b/lib/ansible/plugins/action/patch.py @@ -41,7 +41,7 @@ class ActionModule(ActionBase): if self._task._role is not None: src = self._loader.path_dwim_relative(self._task._role._role_path, 'files', src) else: - src = self._loader.path_dwim(src) + src = self._loader.path_dwim_relative(self._loader.get_basedir(), 'files', src) # create the remote tmp dir if needed, and put the source file there if tmp is None or "-tmp-" not in tmp: diff --git a/lib/ansible/plugins/action/script.py b/lib/ansible/plugins/action/script.py index e157ddce06e..d2fbf21cf01 100644 --- a/lib/ansible/plugins/action/script.py +++ b/lib/ansible/plugins/action/script.py @@ -65,7 +65,7 @@ class ActionModule(ActionBase): if self._task._role is not None: source = self._loader.path_dwim_relative(self._task._role._role_path, 'files', source) else: - source = self._loader.path_dwim(source) + source = self._loader.path_dwim_relative(self._loader.get_basedir(), 'files', source) # transfer the file to a remote tmp location tmp_src = self._connection._shell.join_path(tmp, os.path.basename(source)) diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py index d9d14681190..26deb9ecc45 100644 --- a/lib/ansible/plugins/action/synchronize.py +++ b/lib/ansible/plugins/action/synchronize.py @@ -31,7 +31,12 @@ class ActionModule(ActionBase): def _get_absolute_path(self, path): if self._task._role is not None: original_path = path - path = self._loader.path_dwim_relative(self._task._role._role_path, 'files', 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) + if original_path and original_path[-1] == '/' and path[-1] != '/': # make sure the dwim'd path ends in a trailing "/" # if the original path did diff --git a/lib/ansible/plugins/action/template.py b/lib/ansible/plugins/action/template.py index 095a90f90e3..7a68375a447 100644 --- a/lib/ansible/plugins/action/template.py +++ b/lib/ansible/plugins/action/template.py @@ -71,7 +71,7 @@ class ActionModule(ActionBase): if self._task._role is not None: source = self._loader.path_dwim_relative(self._task._role._role_path, 'templates', source) else: - source = self._loader.path_dwim(source) + source = self._loader.path_dwim_relative(self._loader.get_basedir(), 'templates', source) # Expand any user home dir specification dest = self._remote_expand_user(dest, tmp) diff --git a/lib/ansible/plugins/action/unarchive.py b/lib/ansible/plugins/action/unarchive.py index d2b158021db..b5be23069a8 100644 --- a/lib/ansible/plugins/action/unarchive.py +++ b/lib/ansible/plugins/action/unarchive.py @@ -64,7 +64,7 @@ class ActionModule(ActionBase): if self._task._role is not None: source = self._loader.path_dwim_relative(self._task._role._role_path, 'files', source) else: - source = self._loader.path_dwim(source) + source = self._loader.path_dwim_relative(tself._loader.get_basedir(), 'files', source) remote_checksum = self._remote_checksum(tmp, dest, all_vars=task_vars) if remote_checksum != '3':