summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrion Poplawski <orion@cora.nwra.com>2016-11-21 15:20:53 -0700
committerBrian Coca <bcoca@users.noreply.github.com>2016-11-21 17:20:53 -0500
commit1074586ac71d8d03b6b1f488aa96ee472024b3fa (patch)
tree7673349e5c4bc4c5d1c9024d9bd214bad47f7422
parent7903b39fc0c1e7559c98b838e4da5bc157a24412 (diff)
downloadansible-modules-core-1074586ac71d8d03b6b1f488aa96ee472024b3fa.tar.gz
Be able to find all contents of a directory (#3711)
-rw-r--r--files/find.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/files/find.py b/files/find.py
index 2a7c6b6d..f11a68cf 100644
--- a/files/find.py
+++ b/files/find.py
@@ -66,7 +66,7 @@ options:
required: false
description:
- Type of file to select
- choices: [ "file", "directory", "link" ]
+ choices: [ "file", "directory", "link", "any" ]
default: "file"
recurse:
required: false
@@ -275,7 +275,7 @@ def main():
paths = dict(required=True, aliases=['name','path'], type='list'),
patterns = dict(default=['*'], type='list', aliases=['pattern']),
contains = dict(default=None, type='str'),
- file_type = dict(default="file", choices=['file', 'directory', 'link'], type='str'),
+ file_type = dict(default="file", choices=['file', 'directory', 'link', 'any'], type='str'),
age = dict(default=None, type='str'),
age_stamp = dict(default="mtime", choices=['atime','mtime','ctime'], type='str'),
size = dict(default=None, type='str'),
@@ -337,7 +337,11 @@ def main():
continue
r = {'path': fsname}
- if stat.S_ISDIR(st.st_mode) and params['file_type'] == 'directory':
+ if params['file_type'] == 'any':
+ if pfilter(fsobj, params['patterns'], params['use_regex']) and agefilter(st, now, age, params['age_stamp']):
+ r.update(statinfo(st))
+ filelist.append(r)
+ elif stat.S_ISDIR(st.st_mode) and params['file_type'] == 'directory':
if pfilter(fsobj, params['patterns'], params['use_regex']) and agefilter(st, now, age, params['age_stamp']):
r.update(statinfo(st))