community.openwrt.stat module – Retrieve file or file system status on OpenWrt targets
Note
This module is part of the community.openwrt collection (version 0.5.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.stat.
Synopsis
The community.openwrt.stat module retrieves facts about files similar to the Linux
statcommand.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
|---|---|
Algorithm to use for checksumming the file. Choices:
|
|
Whether to follow symlinks. Choices:
|
|
Whether to get the checksum of the file. Uses the algorithm specified in Choices:
|
|
Whether to get the MD5 checksum of the file. Choices:
|
|
Whether to get the MIME type of the file. Note that this is not fully implemented and returns Choices:
|
|
The full path of the file/directory to get the facts of. |
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. |
Examples
- name: Get stats of a file
community.openwrt.stat:
path: /etc/config/network
register: network_stat
- name: Check if file exists
community.openwrt.stat:
path: /tmp/myfile
register: file_check
- name: Get file checksum
community.openwrt.stat:
path: /etc/config/system
checksum_algorithm: sha256
register: file_hash
- name: Fail if path does not exist
community.openwrt.stat:
path: /etc/important_file
register: stat_result
failed_when: not stat_result.stat.exists
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Dictionary containing all file stat information. Returned: always |
|
Character set of the file. Returned: when file exists Sample: |
|
Hash of the file using the specified algorithm. Returned: when Sample: |
|
Last change time in seconds since epoch. Returned: when file exists Sample: |
|
Device identifier. Returned: when file exists |
|
Whether the file is executable by the current user. Returned: when file exists Sample: |
|
Whether the file exists. Returned: always Sample: |
|
Numeric group ID of the owner. Returned: when file exists Sample: |
|
Group name of the owner. Returned: when file exists Sample: |
|
Inode number of the file. Returned: when file exists Sample: |
|
Whether the path is a block device. Returned: when file exists Sample: |
|
Whether the path is a character device. Returned: when file exists Sample: |
|
Whether the path is a directory. Returned: when file exists Sample: |
|
Whether the path is a FIFO. Returned: when file exists Sample: |
|
Whether the file is owned by the current group. Returned: when file exists Sample: |
|
Whether the path is a symbolic link. Returned: when file exists Sample: |
|
Whether the path is a regular file. Returned: when file exists Sample: |
|
Whether the path is a socket. Returned: when file exists Sample: |
|
Whether the file is owned by the current user. Returned: when file exists Sample: |
|
Original path when Returned: when following a symlink Sample: |
|
MD5 hash of the file. Returned: when Sample: |
|
MIME type of the file. Returned: when file exists Sample: |
|
Unix permissions of the file in octal. Returned: when file exists Sample: |
|
Last modification time in seconds since epoch. Returned: when file exists Sample: |
|
Number of hard links to the file. Returned: when file exists Sample: |
|
The full path to the file. Returned: always Sample: |
|
User name of the owner. Returned: when file exists Sample: |
|
Whether the file is readable by the current user. Returned: when file exists Sample: |
|
Whether the group has read permission. Returned: when file exists Sample: |
|
Whether others have read permission. Returned: when file exists Sample: |
|
Whether the owner has read permission. Returned: when file exists Sample: |
|
Size of the file in bytes. Returned: when file exists Sample: |
|
Numeric user ID of the owner. Returned: when file exists Sample: |
|
Whether the group has write permission. Returned: when file exists Sample: |
|
Whether others have write permission. Returned: when file exists Sample: |
|
Whether the file is writeable by the current user. Returned: when file exists Sample: |
|
Whether the owner has write permission. Returned: when file exists Sample: |
|
Whether the group has execute permission. Returned: when file exists Sample: |
|
Whether others have execute permission. Returned: when file exists Sample: |
|
Whether the owner has execute permission. Returned: when file exists Sample: |