summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag Wieers <dag@wieers.com>2016-09-09 15:37:29 +0200
committerBrian Coca <bcoca@users.noreply.github.com>2016-09-09 09:37:29 -0400
commit2daf527e63bb96ac3c46d3ecdb48723606c4e947 (patch)
treeae50e7df4c83bc87ec2d33506a7c9e4aa562fc68
parentd52a9cee46553dc461a0bc69bb0459d5f2eb6765 (diff)
downloadansible-2daf527e63bb96ac3c46d3ecdb48723606c4e947.tar.gz
Fix fileglob filter to work just like fileglob lookup plugin (#17480)
The fileglob lookup plugin only returns files, not directories. This is to be expected, as a mixed list would not be very useful in with_fileglob. However the fileglob filter does return anything glob.glob() returns. This change fixes this, so that fileglob returns files (as the name indicates). PS We could also offer a glob filter for thos that would need it ? This relates to comments in issue #17136 and fixes confusion in #17269.
-rw-r--r--lib/ansible/plugins/filter/core.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py
index 8bf829afcb..2ec50f4980 100644
--- a/lib/ansible/plugins/filter/core.py
+++ b/lib/ansible/plugins/filter/core.py
@@ -126,8 +126,8 @@ def quote(a):
return pipes.quote(a)
def fileglob(pathname):
- ''' return list of matched files for glob '''
- return glob.glob(pathname)
+ ''' return list of matched regular files for glob '''
+ return [ g for g in glob.glob(pathname) if os.path.isfile(g) ]
def regex_replace(value='', pattern='', replacement='', ignorecase=False):
''' Perform a `re.sub` returning a string '''