From 867ad75cf5dd9b1eabea79be3170cab6538420df Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 19 Mar 2021 11:19:04 -0400 Subject: [PATCH] moved change to new location --- lib/ansible/modules/find.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/find.py b/lib/ansible/modules/find.py index 323d0223f26917..4ad1f057a01b94 100644 --- a/lib/ansible/modules/find.py +++ b/lib/ansible/modules/find.py @@ -29,7 +29,7 @@ first letter of any of those words (e.g., "1w"). type: str patterns: - default: '*' + default: [] description: - One or more (shell or regex) patterns, which type is controlled by C(use_regex) option. - The patterns restrict the list of files to be returned to those whose basenames match at @@ -41,6 +41,7 @@ - This parameter expects a list, which can be either comma separated or YAML. If any of the patterns contain a comma, make sure to put them in a list to avoid splitting the patterns in undesirable ways. + - Defaults to '*', or '.*' when use_regex enabled type: list aliases: [ pattern ] elements: str @@ -375,7 +376,7 @@ def main(): module = AnsibleModule( argument_spec=dict( paths=dict(type='list', required=True, aliases=['name', 'path'], elements='str'), - patterns=dict(type='list', default=['*'], aliases=['pattern'], elements='str'), + patterns=dict(type='list', default=[], aliases=['pattern'], elements='str'), excludes=dict(type='list', aliases=['exclude'], elements='str'), contains=dict(type='str'), read_whole_file=dict(type='bool', default=False), @@ -395,6 +396,16 @@ def main(): params = module.params + # Set the default match pattern to either a match-all glob or + # regex depending on use_regex being set. This makes sure if you + # set excludes: without a pattern pfilter gets something it can + # handle. + if not params['patterns']: + if params['use_regex']: + params['patterns'] = ['.*'] + else: + params['patterns'] = ['*'] + filelist = [] if params['age'] is None: