Initial commit

This commit is contained in:
2024-10-30 01:50:38 +01:00
commit 587ca23374
147 changed files with 7521 additions and 0 deletions

80
roles/mesh11sd/README.md Normal file
View File

@@ -0,0 +1,80 @@
# `flyoverhead.openwrt.mesh`
OpenWRT `mesh` configuration
- create and configure mesh network
## Role Variables
| Variable | Descritpion | Status | Type | Default/Example |
| :--- | :--- | :--- | :--- | :--- |
| `mesh_enabled` | Enable mesh configuration | `required` | `boolean` | `false` |
| `ath10k_ct_fix` | Enable [ath10k-ct drivers fix](https://openwrt.org/docs/guide-user/network/wifi/mesh/80211s#wireless_hardware_support) | `optional` | `boolean` | `false` |
| `non_mesh_pkgs` | List of non-mesh wpad packages installed by default | `required` | `list` | `["wpad-mini", "wpad-basic", "wpad-basic-wolfssl", "wpad-basic-openssl", "wpad-basic-mbedtls"]` |
| `mesh_pkgs` | List of mesh wpad packages to be installed | `required` | `list` | `["wpad-mesh-wolfssl", "mesh11sd"]` |
| `mesh11sd_interfaces` | List of [wireless interfaces](https://openwrt.org/docs/guide-user/network/wifi/mesh/80211s#the_wireless_uci_config_file) to be configured as mesh nodes | | `list of dictionaries` | |
|  `id` | Unique interface ID | `mandatory` | `string` | `mesh` |
|  `name` | Unique interface name | `mandatory` | `string` | `mesh` |
|  `state` | Interface status (`present` or `absent`) | `required` | `string` | `present` |
|  `device` | Radio device associated with the interface | `mandatory` | `string` | `radio0` |
|  `network` | List of networks associated with the interface | `mandatory` | `list` | `["lan"]` |
|  `mode` | Wireless interface operation mode | `required` | `string` | `mesh` |
|  `disabled` | Disable wireless network | `optional` | `boolean` | `0` |
|  `mesh_id` | ID of the mesh network (as defined in IEEE 802.11s) to join wireless interface to | `required` | `string` | `example_mesh_id` |
|  `encryption` | Wireless encryption method | `required` | `string` | `sae` |
|  `key` | Passphrase for pre-shared key | `required` | `string` | `password` |
| `mesh_settings` | List of [mesh parameters and options](https://openwrt.org/docs/guide-user/network/wifi/mesh/80211s#mesh11sd_-_setting_parameters_and_options) | | `list of dictionaries` | |
|  `mesh_fwding` | Forward packets to peer mesh nodes | `required` | `boolean` | `1` |
|  `mesh_rssi_threshold` | Minimum received signal strength from a peer meshnode for a connection to be established | `optional` | `integer` | `-80` |
|  `mesh_gate_announcements` | Enable gate announcements | `optional` | `boolean` | `1` |
|  `mesh_hwmp_rootmode` | Mesh convergence level (`0`, `1`, `2`, `3` or `4`) | `required` | `integer` | `2` |
|  `mesh_max_peer_links` | Maximum number of peer nodes that can connect | `optional` | `integer` | `150` |
## Dependencies
| Name | Description |
| :--- | :--- |
| `Ansible Role: openwrt` | [Ansible role by gekmihesg](https://github.com/gekmihesg/ansible-openwrt) for managing OpenWRT and derivatives |
## Example Playbook
```yaml
- hosts: openwrt
roles:
- role: flyoverhead.openwrt.mesh
```
## Example Vars
```yaml
mesh_enabled: true
ath10k_ct_fix: true
mesh11sd_interfaces:
- id: "mesh0"
name: "mesh0"
state: "present"
device: "radio0"
network: ["lan"]
mode: "mesh"
mesh_id: "openwrt_mesh"
encryption: "sae"
key: "passphrase"
mesh11sd_settings:
mesh_fwding: "1"
mesh_rssi_threshold: "-80"
mesh_gate_announcements: "1"
mesh_hwmp_rootmode: "3"
mesh_max_peer_links: "150"
```
## License
[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.txt)
## Author Information
fly0v3rH34D
## References
- https://openwrt.org/docs/guide-user/network/wifi/mesh/80211s
- https://openwrt.org/docs/guide-user/network/wifi/mesh/mesh11sd

View File

@@ -0,0 +1,41 @@
---
# Deafult mesh status
mesh_enabled: false
# Enable ath10k-ct drivers fix
# https://openwrt.org/docs/guide-user/network/wifi/mesh/80211s#wireless_hardware_support
ath10k_ct_fix: false
# Non-mesh wpad packages
non_mesh_pkgs:
[
"wpad-mini",
"wpad-basic",
"wpad-basic-wolfssl",
"wpad-basic-openssl",
"wpad-basic-mbedtls",
]
# Mesh wpad packages
mesh11sd_pkgs: ["wpad-mesh-wolfssl", "mesh11sd"]
# Mesh interface configuration
mesh11sd_interfaces:
- id: ""
name: ""
state: ""
device: ""
network: []
mode: ""
disabled: ""
mesh_id: ""
encryption: ""
key: ""
# Mesh interface additional settings
mesh11sd_settings:
mesh_fwding: ""
mesh_rssi_threshold: ""
mesh_gate_announcements: ""
mesh_hwmp_rootmode: ""
mesh_max_peer_links: ""

View File

@@ -0,0 +1,8 @@
---
# Reload wireless service
- name: Reload wireless
ansible.builtin.command:
cmd: "/sbin/wifi {{ item }}"
register: reload_wifi_status
changed_when: reload_wifi_status != 0
loop: ["config", "reload"]

View File

@@ -0,0 +1,12 @@
---
galaxy_info:
author: flyoverhead
description: Configure mesh
license: GPL-3.0
min_ansible_version: "2.13"
platforms:
- name: OpenWrt
versions: ["22.03"]
galaxy_tags: ["openwrt", "mesh"]
dependencies:
- role: gekmihesg.openwrt

View File

@@ -0,0 +1,50 @@
---
# Check current driver release
- name: Check current ath10k firmware release
ansible.bultin.command:
cmd: "opkg list-installed | grep ath10k-firmware | awk '{print $1}'"
register: ath10k_firmware_current_release
# Enable reinstall if installed driver contain *-ct postfix
- name: Enable replacement of current driver
ansible.builtin.set_fact:
replace_ath10k_ct_driver: true
when: "'-ct' in ath10k_firmware_current_release.stdout"
# Replace current driver with new one
- name: Replace ath10k-ct firmware and module
when: replace_ath10k_ct_driver
block:
# Get current ath10k module package name
- name: Check current ath10k module release
ansible.builtin.command:
cmd: "opkg list-installed | grep kmod-ath10k | awk '{print $1}'"
register: ath10k_kmod_current_release
# Set current ath10k module package name fact
- name: Set current ath10k module release fact
ansible.builtin.set_fact:
ath10k_kmod_pkg_name: "{{ ath10k_kmod_current_release.stdout }}"
# Set current driver release name fact
- name: Set current driver release name fact
ansible.builtin.set_fact:
ath10k_driver_pkg_name: "{{ ath10k_firmware_current_release.stdout }}"
# Remove current driver
- name: Remove current driver
opkg:
name: "{{ item }}"
state: "absent"
loop: ["{{ ath10k_kmod_pkg_name }}", "{{ ath10k_driver_pkg_name }}"]
# Install new driver
- name: Install new driver
opkg:
name: "{{ item }}"
state: "present"
loop:
[
"{{ ath10k_kmod_pkg_name | regex_replace('-?ct', '') }}",
"{{ ath10k_driver_pkg_name | regex_replace('-?ct', '') }}",
]

View File

@@ -0,0 +1,14 @@
---
# Configure mesh parameters
- name: Configure mesh parameters
uci:
command: "set"
config: "mesh11sd"
section: "mesh_params"
type: "mesh11sd"
value:
mesh_fwding: "{{ mesh11sd_settings.mesh_fwding | default(omit) }}"
mesh_rssi_threshold: "{{ mesh11sd_settings.mesh_rssi_threshold | default(omit) }}"
mesh_gate_announcements: "{{ mesh11sd_settings.mesh_gate_announcements | default(omit) }}"
mesh_hwmp_rootmode: "{{ mesh11sd_settings.mesh_hwmp_rootmode | default(omit) }}"
mesh_max_peer_links: "{{ mesh11sd_settings.mesh_max_peer_links | default(omit) }}"

View File

@@ -0,0 +1,31 @@
---
# Fix ath10k drivers
# https://openwrt.org/docs/guide-user/network/wifi/mesh/80211s#wireless_hardware_support
- name: Fix ath10k drivers
ansible.builtin.include_tasks: ath10k.yml
when: mesh_enabled and ath10k_ct_fix
# Install required packages
- name: Install required packages
ansible.builtin.include_tasks: prepare.yml
when: mesh_enabled
# Create mesh interface
- name: Create mesh interface
ansible.builtin.include_role:
name: "wireless"
vars:
wireless_interfaces: "{{ mesh11sd_interfaces | default([]) }}"
when: mesh_enabled
# Configure mesh interface
- name: Configure mesh interface
ansible.builtin.include_tasks: configure.yml
when: mesh_enabled
# Apply changes and reload wireless service
- name: Apply changes and reload wireless
when: mesh_enabled
uci:
command: commit
notify: Reload wireless

View File

@@ -0,0 +1,20 @@
---
# Remove non-mesh wpad packages
- name: Remove non-mesh wpad packages
opkg:
name: "{{ item }}"
state: "absent"
loop: "{{ non_mesh_pkgs }}"
# Update opkg cache
- name: Update opkg cache
ansible.builtin.command:
cmd: "opkg update"
changed_when: false
# Install mesh packages
- name: Install mesh packages
opkg:
name: "{{ item }}"
state: "present"
loop: "{{ mesh11sd_pkgs }}"