1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Restore previous behavior of ignoring missing files via with_fileglob (#17053)

Fixes #16801
This commit is contained in:
jctanner 2016-08-11 19:55:21 -04:00 committed by GitHub
parent 901042f458
commit 39d764c7ad

View file

@ -21,6 +21,7 @@ import os
import glob
from ansible.plugins.lookup import LookupBase
from ansible.errors import AnsibleFileNotFound
class LookupModule(LookupBase):
@ -29,7 +30,11 @@ class LookupModule(LookupBase):
ret = []
for term in terms:
term_file = os.path.basename(term)
dwimmed_path = self.find_file_in_search_path(variables, 'files', os.path.dirname(term))
globbed = glob.glob(os.path.join(dwimmed_path, term_file))
ret.extend(g for g in globbed if os.path.isfile(g))
try:
dwimmed_path = self.find_file_in_search_path(variables, 'files', os.path.dirname(term))
except AnsibleFileNotFound:
dwimmed_path = None
if dwimmed_path:
globbed = glob.glob(os.path.join(dwimmed_path, term_file))
ret.extend(g for g in globbed if os.path.isfile(g))
return ret