Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore previous behavior of with_fileglob ignoring missing files #17053

Merged
merged 1 commit into from
Aug 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/ansible/plugins/lookup/fileglob.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import glob

from ansible.plugins.lookup import LookupBase
from ansible.errors import AnsibleFileNotFound

class LookupModule(LookupBase):

Expand All @@ -29,7 +30,11 @@ def run(self, terms, variables=None, **kwargs):
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tempted to add a warning 'path not found'

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