community.openwrt.find module – Return a list of files based on specific criteria on OpenWrt targets
Note
This module is part of the community.openwrt collection (version 1.12.0).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.openwrt.
To use it in a playbook, specify: community.openwrt.find.
New in community.openwrt 1.12.0
Synopsis
Return a list of files based on specific criteria. Multiple criteria are AND’d together.
This module loosely mimics ansible.builtin.find. It reads the filesystem directly and does not use the
findcommand.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
|---|---|
Select files 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 any of those words, for example |
|
Set the maximum number of levels to descend into. Setting Default is unlimited depth. |
|
Restrict mode matching to exact matches only, and not as a minimum set of permissions to match. Choices:
|
|
Type of file to select. Choices:
|
|
Set this to The paths in Choices:
|
|
Set this to When Choices:
|
|
Limit the maximum number of matching paths returned. After finding this many, the module stops looking. Default is unlimited. |
|
Choose objects matching a specified permission, as an octal string such as Symbolic modes are not supported. |
|
List of paths of directories to search. All paths must be absolute. |
|
One or more shell or regex patterns, which type is controlled by The patterns restrict the list of files to be returned to those whose basenames match at least one of the patterns specified. The pattern is matched against the file base name, excluding the directory. When using regular expressions, the pattern must match the entire file name, not just parts of it. 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. When empty, all names are selected. Default: |
|
If Choices:
|
|
Select files whose size is equal to or greater than the specified size. Use a negative size to find files equal to or less than the specified size. Unqualified values are in bytes but Size is only evaluated for regular files. |
|
If If Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full This action does not modify state. |
Can run in |
|
Support: N/A This action does not modify state. |
Returns details on what has changed (or possibly needs changing in |
|
Platform: OpenWrt |
Target platform for this module. |
See Also
See also
- ansible.builtin.find
The official documentation on the ansible.builtin.find module.
- community.openwrt.stat
Retrieve file or file system status on OpenWrt targets.
Examples
- name: Recursively find /tmp files older than 2 days
community.openwrt.find:
paths: /tmp
age: 2d
recurse: true
- name: Recursively find /tmp files older than 4 weeks and equal or greater than 1 megabyte
community.openwrt.find:
paths: /tmp
age: 4w
size: 1m
recurse: true
- name: Recursively find /tmp files with last access time greater than 3600 seconds
community.openwrt.find:
paths: /tmp
age: 3600
age_stamp: atime
recurse: true
- name: Find /etc/config files ending with .bak or -opkg
community.openwrt.find:
paths: /etc/config
patterns: '*.bak,*-opkg'
- name: Find the same files with a regular expression
community.openwrt.find:
paths: /etc/config
patterns: '.*(\.bak|-opkg)'
use_regex: true
- name: Find all directories in /etc, excluding init.d and rc.d
community.openwrt.find:
paths: /etc
file_type: directory
excludes: 'init.d,rc.d'
- name: Find executable scripts, stopping at the first one
community.openwrt.find:
paths: /usr/sbin
mode: "0755"
limit: 1
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Number of filesystem objects looked at. Returned: success Sample: |
|
All matches found with the specified criteria. Returned: success |
|
Last access time in seconds since epoch. Returned: success Sample: |
|
Last change time in seconds since epoch. Returned: success Sample: |
|
Numeric group ID of the owner. Returned: success Sample: |
|
Inode number of the file. Returned: success Sample: |
|
Whether the path is a block device. Returned: success Sample: |
|
Whether the path is a character device. Returned: success Sample: |
|
Whether the path is a directory. Returned: success Sample: |
|
Whether the path is a FIFO. Returned: success Sample: |
|
Whether the path is a symbolic link. Returned: success Sample: |
|
Whether the path is a regular file. Returned: success Sample: |
|
Whether the path is a socket. Returned: success Sample: |
|
Unix permissions of the file in octal. Returned: success Sample: |
|
Last modification time in seconds since epoch. Returned: success Sample: |
|
Number of hard links to the file. Returned: success Sample: |
|
The full path to the file. Returned: success Sample: |
|
Size of the file in bytes. Returned: success Sample: |
|
Numeric user ID of the owner. Returned: success Sample: |
|
Number of matches. Returned: success Sample: |
|
Skipped paths and reasons they were skipped. Returned: success Sample: |