gekmihesg/ansible-openwrt

Wireless setup doesn't work with multiple SSIDs on one radio

jasmir opened this issue · 4 comments

It's not an issue, but more a "help wanted":

I try to get a idempotent play which configure more than one SSID on a radio:

- name: configure wifi device radio0
  uci:
    command: set
    key: wireless.radio0
    value:
      type: mac80211
      hwmode: 11a
      country: DE
      channel: "{{ hostvars[inventory_hostname].channel_5G }}"
      legacy_rates: 0
      htmode: "{{ hostvars[inventory_hostname].htmode_5G }}"
      disabled: 0

- name: configure wifi device radio1
  uci:
    command: set
    key: wireless.radio1
    value:
      type: mac80211
      hwmode: 11g
      country: DE
      channel: "{{ hostvars[inventory_hostname].channel_2G4 }}"
      legacy_rates: 0
      htmode: "{{ hostvars[inventory_hostname].htmode_2G4 }}"
      disabled: 0

- name: configure 5G wifi interface
  uci:
    command: section
    config: wireless
    type: wifi-iface 'network1_radio0'
    find_by:
      device: radio0
      mode: ap
    value:
      ssid: ssid_12345
      network: lan
      encryption: psk2+ccmp
      key: geheim
      ieee80211r: 1
      mobility_domain: abcd
      ft_over_ds: 1
      ft_psk_generate_local: 1
      isolate: 1

- name: configure 2.4G wifi interface
  uci:
    command: section
    config: wireless
    type: wifi-iface 'network1_radio1'
    find_by:
      device: radio1
      mode: ap
    value:
      ssid: ssid_12345
      network: lan
      encryption: psk2+ccmp
      key: geheim
      ieee80211r: 1
      mobility_domain: abcd
      ft_over_ds: 1
      ft_psk_generate_local: 1
      isolate: 1

- name: configure 2.4G wifi guest interface
  uci:
    command: section
    config: wireless
    type: wifi-iface 'network2_radio1'
    find_by:
      device: radio1
      mode: ap
    value:
      ssid: ssid_ABCD
      network: lan
      encryption: psk2+ccmp
      key: geheim

Apart from this syntax doesn't work: How to I do it?

This should work:

# example, needs to be modified in all section.wireless.wifi-iface tasks:
- name: configure 2.4G wifi guest interface
  uci:
    command: section
    config: wireless
    type: wifi-iface
    name: network2_radio1 # previously appended to type
    find_by:
      device: radio1
      mode: ap
      ssid: ssid_ABCD # previously in value, but you'll need a way to distinguish between instances
    value:
      network: lan
      encryption: psk2+ccmp
      key: geheim

Does that work for you?

19.07 has a new wireless config syntax (it asks you to upgrade when you go to the wireless LuCI tab).
Is there a shorter way to set the wireless.wifinet0=wifi-iface key and the subkeys with just one uci task?

wireless.wifinet0=wifi-iface
wireless.wifinet0.device='radio1'

I haven't checked yet, but this is probably the way to do it now:

    - name: "Configure wireless.wifinet0=wifi-iface"
      uci:
        command: set
        key: wireless
        value:
          wifinet0: 'wifi-iface'
    - name: "Configure wireless.wifinet0.*"
      uci:
        command: set
        key: wireless.wifinet0
        value:
          #'': 'wifi-iface'
          device: radio0
          mode: ap
          ssid: "ssid"