mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
correct, cleanup & simplify dwim stack (#25956)
* correct, cleanup & simplify dwim stack latlh chIS logh HeS qar wej chel laD better errors update find_file to new exception * addressed latest comments * test should not use realpath as it follows symlink this fails when on OS X as /var is now a symlink to /private/var but first_found was not supposed to follow symlinks
This commit is contained in:
parent
272f5fd03a
commit
8f758204cf
7 changed files with 81 additions and 52 deletions
|
@ -22,6 +22,7 @@ __metaclass__ = type
|
|||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from ansible.module_utils.six import with_metaclass
|
||||
from ansible.errors import AnsibleFileNotFound
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
|
@ -112,8 +113,11 @@ class LookupBase(with_metaclass(ABCMeta, object)):
|
|||
else:
|
||||
paths = self.get_basedir(myvars)
|
||||
|
||||
result = self._loader.path_dwim_relative_stack(paths, subdir, needle)
|
||||
if result is None and not ignore_missing:
|
||||
self._display.warning("Unable to find '%s' in expected paths." % needle)
|
||||
result = None
|
||||
try:
|
||||
result = self._loader.path_dwim_relative_stack(paths, subdir, needle)
|
||||
except AnsibleFileNotFound:
|
||||
if not ignore_missing:
|
||||
self._display.warning("Unable to find '%s' in expected paths." % needle)
|
||||
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue