From 39d764c7adef870847755941f8308b6bd854def6 Mon Sep 17 00:00:00 2001 From: jctanner Date: Thu, 11 Aug 2016 19:55:21 -0400 Subject: [PATCH] Restore previous behavior of ignoring missing files via with_fileglob (#17053) Fixes #16801 --- lib/ansible/plugins/lookup/fileglob.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/lookup/fileglob.py b/lib/ansible/plugins/lookup/fileglob.py index 2f4ece02dac..8315e0dbc0f 100644 --- a/lib/ansible/plugins/lookup/fileglob.py +++ b/lib/ansible/plugins/lookup/fileglob.py @@ -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