From 11afd84d32b58a4f4a03a1e16a79c1b1a2805aa6 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Sun, 18 Nov 2012 00:25:38 +0100 Subject: [PATCH] Drop dwim prefix from returned items in fileglob Fixes #1618. --- lib/ansible/runner/lookup_plugins/fileglob.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/runner/lookup_plugins/fileglob.py b/lib/ansible/runner/lookup_plugins/fileglob.py index 456ca4ed1f..6711ccc84d 100644 --- a/lib/ansible/runner/lookup_plugins/fileglob.py +++ b/lib/ansible/runner/lookup_plugins/fileglob.py @@ -25,7 +25,10 @@ class LookupModule(object): self.basedir = basedir def run(self, terms, **kwargs): - return [ f for f in glob.glob(utils.path_dwim(self.basedir, terms)) if os.path.isfile(f) ] + dwimterms = utils.path_dwim(self.basedir, terms) + # This skips whatever prefix the dwim added, leaving just the filename for the item + dwim_prefix_len = len(dwimterms) - len(terms) + return [ f[dwim_prefix_len:] for f in glob.glob(dwimterms) if os.path.isfile(f) ]