mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Search path (#16387)
* smarter function to figure out relative paths takes list of paths in order of relevance to current task and does the dwim magic on them * shared function for action plugins using new dwim unify path construction and error info/messaging made include and role non exclusive corrected order and now smarter about tasks includes inside roles are currently broken as they don't provide the correct role data make dirname full match to avoid corner cases * migrated action plugins to new dwim function reported plugins to use exceptions instead of info * clarified needle
This commit is contained in:
parent
e04d552bc6
commit
2bb7feec6d
9 changed files with 150 additions and 65 deletions
|
@ -22,7 +22,8 @@ import os
|
|||
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.utils.unicode import to_str
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
|
@ -66,10 +67,13 @@ class ActionModule(ActionBase):
|
|||
source = os.path.expanduser(source)
|
||||
|
||||
if copy:
|
||||
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_relative(self._loader.get_basedir(), 'files', source)
|
||||
try:
|
||||
source = self._find_needle('files', source)
|
||||
except AnsibleError as e:
|
||||
result['failed'] = True
|
||||
result['msg'] = to_str(e)
|
||||
self._remove_tmp_path(tmp)
|
||||
return result
|
||||
|
||||
remote_checksum = self._remote_checksum(dest, all_vars=task_vars, follow=True)
|
||||
if remote_checksum == '4':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue