community.openwrt.file module – Manage files and file properties 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.file.
Synopsis
The community.openwrt.file module sets attributes of files, symlinks, and directories.
It can also create or remove files, directories, and symbolic/hard links.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
|---|---|
Internal parameter for diff operations. |
|
Force creation of symlinks when the target does not exist. Force conversion between different link types. Choices:
|
|
Group name that should own the file or directory. Passed directly to the If not specified, group ownership is not changed. Not applied to symlinks when |
|
Permissions for the file or directory. Can be specified as an octal number (for example, When using octal notation, quote the value to ensure it is treated as a string. If not specified, permissions may be determined by the system default Not applied to symlinks when |
|
Original basename to use when |
|
User name that should own the file or directory. Passed directly to the If not specified, ownership is not changed. Not applied to symlinks when |
|
Path to the file being managed. |
|
Recursively set the specified file attributes on directory contents. Only works with Choices:
|
|
Path of the file to link to. Required for For symbolic links, if not specified, the realpath of |
|
Desired state of the file. If not specified, defaults to Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Can run in |
|
Support: full |
Returns details on what has changed (or possibly needs changing in |
|
Platform: OpenWrt |
Target platform for this module. |
|
Support: none This module uses basic shell commands for file operations and does not implement Ansible’s atomic file operation functions. |
Uses Ansible’s strict file operation functions to ensure proper permissions and avoid data corruption. |
Examples
- name: Create a directory
community.openwrt.file:
path: /etc/config/custom
state: directory
mode: '0755'
- name: Create a symbolic link
community.openwrt.file:
src: /etc/config/network
path: /tmp/network.link
state: link
- name: Remove a file
community.openwrt.file:
path: /tmp/tempfile
state: absent
- name: Touch a file
community.openwrt.file:
path: /tmp/touched
state: touch
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Path to the file or directory. Returned: always Sample: |
|
The state of the file or directory. Returned: always Sample: |