community.openwrt.uci module – Controls OpenWrt UCI
Note
This module is part of the community.openwrt collection (version 1.11.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.uci.
Synopsis
The community.openwrt.uci module controls OpenWrt UCI through the native
ucodeUCI bindings.It supports all the command line functionality plus some extra commands.
Note
This module has a corresponding action plugin.
Parameters
Parameter |
Comments |
|---|---|
Whether to automatically commit changes. Choices:
|
|
The default is The Choices:
|
|
Value(s) to match sections against. Option value to find if Dict of options/values if Lists are compared in order. Required when |
|
Space separated list or list of keys not in |
|
New name when Desired name when |
|
A list of UCI operations to execute in order using one UCI cursor. Each entry accepts the same options as a standalone invocation except Per-operation results are returned in An empty list performs no operations and reports no change. Set top-level |
|
Whether to commit the changes of this operation right after it runs. See Choices:
|
|
See Choices:
|
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
UCI option names whose values must be hidden in the diff of this operation. When set, replaces the top-level See |
|
See |
|
See |
|
See |
|
UCI option names whose values must be hidden in diff output. Changed values are represented by A value set on an individual This only affects diffs. |
|
When Choices:
|
|
When Choices:
|
|
Section type for If not specified, defaults to the value of |
|
When Choices:
|
|
The value for various commands. |
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. |
Notes
Note
Since version 1.8.0,
command=set,command=ensureandcommand=sectioncompare the stored value before writing, and reportchanged=trueonly when it differs. Earlier versions reportedchanged=trueon every run.Starting with version 1.9.0 of this collection, this module is implemented in
ucode.
Examples
# Find a section of type wifi-iface with matching name or matching attributes.
# If not found create it and set the attributes from find.
# Unconditionally set the attributes from value and delete all other options.
- community.openwrt.uci:
command: section
config: wireless
type: wifi-iface
name: ap0
find:
device: radio0
ssid: My SSID
value:
encryption: none
replace: true
# Find a matching wifi-iface and delete it.
- community.openwrt.uci:
command: absent
config: wireless
type: wifi-iface
find:
ssid: My SSID broken
# Find a matching wifi-iface and delete the options key and encryption.
- community.openwrt.uci:
command: absent
config: wireless
type: wifi-iface
find:
ssid: My SSID public
value:
- key
- encryption
# Commit changes and notify.
- community.openwrt.uci:
cmd: commit
notify: restart wifi
# Apply several changes through one UCI cursor and commit once at the end.
- community.openwrt.uci:
autocommit: true
operations:
- command: set
key: system.@system[0].hostname
value: my-router
- command: set
key: network.lan.ipaddr
value: 192.168.1.1
# Hide a password in the before/after diff.
- community.openwrt.uci:
command: set
key: wireless.default_radio0.key
value: top-secret
redact_keys:
- key
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Pending UCI changes. Returned: when |
|
Command executed. Returned: always Sample: |
|
UCI state before and after each changed operation, with options from Returned: in diff mode when a supported operation changes state |
|
Result of each entry passed through Returned: when |
|
Output of the Returned: always Sample: |
|
The list form of For Returned: when Sample: |
|