New set mode: set path=config match={} values={}
Find uci sections based on path and match, modify their
properties according to values.
# Modify settings for pre-existing wireless interface with device radio0.
- name: configure wireless
uci:
path: wireless
match:
device: radio0
type: wifi-iface
values:
ssid: myssid
encryption: psk2
key: "secret passphrase"
New op: get path=config[.section] [type=t] [match=m]
Used with register var x, outputs to x.result['values']
(x.result.values won't work.) This can be used for conditions
in subsequent tasks.
# See if there already exists a forwarding config with dest=myvpn and src=lan
- name: Get myvpn zone forwarding
uci: op=get path=firewall type=forwarding match="dest=myvpn src=lan"
register: myvpnfw
# Create the section if it doesn't exist
- name: Add myvpn zone forwarding
uci: autocommit=false path=firewall type=forwarding
when: not myvpnfw.result['values']
# Populate the section if it didn't exist
- name: Setup myvpn zone forwarding
uci: autocommit=false path=firewall.@forwarding[-1].{{ item.key }} value={{ item.value}}
with_dict:
dest: myvpn
src: lan
when: not myvpnfw.result['values']