mirror of
https://github.com/zebrajr/ansible.git
synced 2025-12-06 00:19:48 +01:00
lookups, make file searching use better is_role (#82290)
* lookups, make file searching use better is_role The dwim function will internally try by detecting tasks/main['','.yml','.yaml] but this is far from optimial, the existince of role path in vars is much better indicator that we can use to pass a hint * updated test to avoid main.yml
This commit is contained in:
parent
5573d4cde9
commit
a9919dd7f6
2
changelogs/fragments/dwim_is_role_fix.yml
Normal file
2
changelogs/fragments/dwim_is_role_fix.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- dwim functions for lookups should be better at detectging role context even in abscense of tasks/main.
|
||||
|
|
@ -115,7 +115,7 @@ class LookupBase(AnsiblePlugin):
|
|||
|
||||
result = None
|
||||
try:
|
||||
result = self._loader.path_dwim_relative_stack(paths, subdir, needle)
|
||||
result = self._loader.path_dwim_relative_stack(paths, subdir, needle, is_role=bool('role_path' in myvars))
|
||||
except AnsibleFileNotFound:
|
||||
if not ignore_missing:
|
||||
self._display.warning("Unable to find '%s' in expected paths (use -vvvvv to see paths)" % needle)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
pre_tasks:
|
||||
- name: remove {{ remove }}
|
||||
file: path={{ playbook_dir }}/{{ remove }} state=absent
|
||||
roles:
|
||||
- showfile
|
||||
post_tasks:
|
||||
tasks:
|
||||
- import_role:
|
||||
name: showfile
|
||||
tasks_from: notmain.yml
|
||||
|
||||
- name: from play
|
||||
set_fact: play_result="{{lookup('file', 'testfile')}}"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user