New in version 2.3.
parameter | required | default | choices | comments |
---|---|---|---|---|
age | no | Select files or folders whose age is equal to or greater than the specified time. Use a negative age to find files equal to or less than the specified time. You can choose seconds, minutes, hours, days or weeks by specifying the first letter of an of those words (e.g., "2s", "10d", 1w"). | ||
age_stamp | no | mtime |
| Choose the file property against which we compare age . The default attribute we compare with is the last modification time. |
checksum_algorithm | no | sha1 |
| Algorithm to determine the checksum of a file. Will throw an error if the host is unable to use specified algorithm. |
file_type | no | file |
| Type of file to search for |
follow | no |
| Set this to true to follow symlinks in the path. This needs to be used in conjunction with recurse . | |
get_checksum | no | True |
| Whether to return a checksum of the file in the return info (default sha1), use checksum_algorithm to change from the default. |
hidden | no |
| Set this to include hidden files or folders | |
paths | yes | List of paths of directories to search for files or folders in. This can be supplied as a single path or a list of paths. | ||
patterns | no | One or more (powershell or regex) patterns to compare filenames with. The type of pattern matching is controlled by use_regex option. The patterns retrict the list of files or folders to be returned based on the filenames. For a file to be matched it only has to match with one pattern in a list provided. | ||
recurse | no |
| Will recursively descend into the directory looking for files or folders | |
size | no | Select files or folders whose size is equal to or greater than the specified size. Use a negative value to find files equal to or less than the specified size. You can specify the size with a suffix of the byte type i.e. kilo = k, mega = m... Size is not evaluated for symbolic links. | ||
use_regex | no |
| Will set patterns to run as a regex check if true |
# Find files in path - win_find: paths: D:\temp # Find hidden files in path - win_find: paths: D:\temp hidden: True # Find files in multiple paths - win_find: paths: ['C:\temp', 'D:\temp'] # Find files in directory while searching recursively - win_find: paths: D:\temp recurse: True # Find files in directory while following symlinks - win_find: paths: D:\temp recurse: True follow: True # Find files with .log and .out extension using powershell wildcards - win_find: paths: D:\temp patterns: ['*.log', '*.out'] # Find files in path based on regex pattern - win_find: paths: D:\temp patterns: 'out_\d{8}-\d{6}.log' # Find files older than 1 day - win_find: paths: D:\temp age: 86400 # Find files older than 1 day based on create time - win_find: paths: D:\temp age: 86400 age_stamp: ctime # Find files older than 1 day with unit syntax - win_find: paths: D:\temp age: 1d # Find files newer than 1 hour - win_find: paths: D:\temp age: -3600 # Find files newer than 1 hour with unit syntax - win_find: paths: D:\temp age: -1h # Find files larger than 1MB - win_find: paths: D:\temp size: 1048576 # Find files larger than 1GB with unit syntax - win_find: paths: D:\temp size: 1g # Find files smaller than 1MB - win_find: paths: D:\temp size: -1048576 # Find files smaller than 1GB with unit syntax - win_find: paths: D:\temp size: -1g # Find folders/symlinks in multiple paths - win_find: paths: ['C:\temp', 'D:\temp'] file_type: directory # Find files and return SHA256 checksum of files found - win_find: paths: C:\temp get_checksum: True checksum_algorithm: sha256 # Find files and do not return the checksum - win_find: path: C:\temp get_checksum: False
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
files | Information on the files/folders that match the criteria returned as a list of dictionary elements for each file matched | success | complex | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
contains: |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
changed | Whether anything was chagned | always | boolean | True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
examined | The number of files/folders that was checked | always | int | 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
matched | The number of files/folders that match the criteria | always | int | 2 |
Note
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/win_find_module.html