From ade7b47f2897d373f36c970230630bd2d82026ad Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Mon, 21 Nov 2016 15:20:53 -0700 Subject: [PATCH] Be able to find all contents of a directory (#3711) --- lib/ansible/modules/files/find.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/files/find.py b/lib/ansible/modules/files/find.py index 2a7c6b6d824..f11a68cf584 100644 --- a/lib/ansible/modules/files/find.py +++ b/lib/ansible/modules/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))