Skip to content

Commit

Permalink
moved change to new location
Browse files Browse the repository at this point in the history
added changelog
  • Loading branch information
bcoca committed Mar 19, 2021
1 parent 87b0513 commit 8a46adc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/fix_find_default.yml
@@ -0,0 +1,2 @@
bugfixes:
- find module, fix default pattern when use_regex is true.
15 changes: 13 additions & 2 deletions lib/ansible/modules/find.py
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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:
Expand Down

0 comments on commit 8a46adc

Please sign in to comment.