From f02e514cd1c8d18cdee20e1a3ebf641b194d5712 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 5 Oct 2022 08:23:34 -0500 Subject: [PATCH 1/7] Move 'hooks' to their respective backends With NetworkManager active, systemd-networkd/networkd-dispatcher are used for br0/ap0 support but the hooks were not being installed on the first pass through network as systemd_networkd_active was not detected when ansibled stated. --- roles/network/tasks/hostapd.yml | 55 ------------------------ roles/network/tasks/rpi_debian.yml | 15 +++++++ roles/network/tasks/sysd-netd-debian.yml | 41 ++++++++++++++++-- 3 files changed, 53 insertions(+), 58 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 99fb6cf41..3df0f2c36 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -55,61 +55,6 @@ # 2022-07-11: Install of iiab-hotspot-on|off moved to network/tasks/main.yml # as required for Admin Console -- name: Create dhcpcd hook for hostapd and ap0 when wifi_up_down True - template: - src: hostapd/50-hostapd - dest: /lib/dhcpcd/dhcpcd-hooks/50-hostapd - owner: root - group: root - mode: 0644 - when: is_raspbian and wifi_up_down - -- name: Remove dhcpcd hook for hostapd if WiFi is not split using ap0 - file: - path: /lib/dhcpcd/dhcpcd-hooks/50-hostapd - state: absent - when: is_raspbian and not wifi_up_down - -- name: Create networkd-dispatcher diagnostic hook for recording network events - template: - owner: root - group: root - mode: 0755 - src: "{{ item.src }}" - dest: "{{ item.dest }}" - with_items: - - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/carrier.d/00-iiab-debug' } - - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/degraded.d/00-iiab-debug' } - - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/dormant.d/00-iiab-debug' } - - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/no-carrier.d/00-iiab-debug' } - - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/off.d/00-iiab-debug' } - - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/routable.d/00-iiab-debug' } - when: systemd_networkd_active and discovered_wireless_iface != "none" - -- name: Create networkd-dispatcher hook for hostapd wifi_up_down True - template: - owner: root - group: root - mode: 0755 - src: "{{ item.src }}" - dest: "{{ item.dest }}" - with_items: - - { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/carrier.d/iiab-wifi' } - - { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' } - - { src: 'hostapd/netd-disp2', dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi2' } - when: systemd_networkd_active and discovered_wireless_iface != "none" and wifi_up_down - -- name: Remove networkd-dispatcher hook wifi_up_down False - file: - path: "{{ item.dest }}" - state: absent - with_items: - - { dest: '/etc/networkd-dispatcher/carrier.d/iiab-wifi' } - - { dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' } - - { dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi' } - - { dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi2' } - when: systemd_networkd_active and discovered_wireless_iface != "none" and not wifi_up_down - - name: Enable the Access Point 'hostapd' service systemd: name: hostapd diff --git a/roles/network/tasks/rpi_debian.yml b/roles/network/tasks/rpi_debian.yml index 1df7b4fd9..4dbcd97ee 100644 --- a/roles/network/tasks/rpi_debian.yml +++ b/roles/network/tasks/rpi_debian.yml @@ -20,6 +20,21 @@ dest: /etc/dhcpcd.conf src: network/dhcpcd.conf.j2 +- name: Create dhcpcd hook for hostapd and ap0 when wifi_up_down True + template: + src: hostapd/50-hostapd + dest: /lib/dhcpcd/dhcpcd-hooks/50-hostapd + owner: root + group: root + mode: 0644 + when: wifi_up_down + +- name: Remove dhcpcd hook for hostapd if WiFi is not split using ap0 + file: + path: /lib/dhcpcd/dhcpcd-hooks/50-hostapd + state: absent + when: not wifi_up_down + - name: New Raspbian requires country code -- check for it shell: grep country /etc/wpa_supplicant/wpa_supplicant.conf | awk -F = '{print $2}' register: country_code diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index 57c70e889..c691f8317 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -42,10 +42,45 @@ src: network/systemd-static-net.j2 when: wan_ip != "dhcp" and ( is_ubuntu_16 or not network_manager_active ) - #when: wan_ip != "dhcp" and not is_ubuntu_18 +- name: Create networkd-dispatcher diagnostic hook for recording network events + template: + owner: root + group: root + mode: 0755 + src: "{{ item.src }}" + dest: "{{ item.dest }}" + with_items: + - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/carrier.d/00-iiab-debug' } + - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/degraded.d/00-iiab-debug' } + - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/dormant.d/00-iiab-debug' } + - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/no-carrier.d/00-iiab-debug' } + - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/off.d/00-iiab-debug' } + - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/routable.d/00-iiab-debug' } + when: discovered_wireless_iface != "none" or discovered_wired_iface != "none" -#- name: Stopping services -# include_tasks: down-debian.yml +- name: Create networkd-dispatcher hook for hostapd wifi_up_down True + template: + owner: root + group: root + mode: 0755 + src: "{{ item.src }}" + dest: "{{ item.dest }}" + with_items: + - { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/carrier.d/iiab-wifi' } + - { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' } + - { src: 'hostapd/netd-disp2', dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi2' } + when: discovered_wireless_iface != "none" and wifi_up_down + +- name: Remove networkd-dispatcher hook for wifi_up_down False + file: + path: "{{ item.dest }}" + state: absent + with_items: + - { dest: '/etc/networkd-dispatcher/carrier.d/iiab-wifi' } + - { dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' } + - { dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi' } + - { dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi2' } + when: discovered_wireless_iface != "none" and not wifi_up_down - name: Reload systemd systemd: From 5ab9e0ff76930a53898ecd2bd450df932ee23433 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 6 Oct 2022 07:25:53 -0500 Subject: [PATCH 2/7] use ap0 hack only on RPi hardware --- roles/network/tasks/sysd-netd-debian.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index c691f8317..ed627f797 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -58,7 +58,7 @@ - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/routable.d/00-iiab-debug' } when: discovered_wireless_iface != "none" or discovered_wired_iface != "none" -- name: Create networkd-dispatcher hook for hostapd wifi_up_down True +- name: Create networkd-dispatcher hook for ap0 on RPi hardware with wifi_up_down True template: owner: root group: root @@ -69,9 +69,9 @@ - { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/carrier.d/iiab-wifi' } - { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' } - { src: 'hostapd/netd-disp2', dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi2' } - when: discovered_wireless_iface != "none" and wifi_up_down + when: discovered_wireless_iface != "none" and rpi_model != "none" and wifi_up_down -- name: Remove networkd-dispatcher hook for wifi_up_down False +- name: Remove networkd-dispatcher hook for ap0 on RPi hardware with wifi_up_down False file: path: "{{ item.dest }}" state: absent @@ -80,7 +80,7 @@ - { dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' } - { dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi' } - { dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi2' } - when: discovered_wireless_iface != "none" and not wifi_up_down + when: discovered_wireless_iface != "none" and rpi_model != "none" and not wifi_up_down - name: Reload systemd systemd: From cf1869bd118459ac95d55112eee8ebce209dfeb8 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 7 Oct 2022 03:24:12 -0500 Subject: [PATCH 3/7] Revert "shut the log up for #3278" This reverts commit eb3c0a2684c81e6f916c8219c49918e8d304d1da. --- roles/network/tasks/enable_services.yml | 4 +--- roles/network/tasks/install.yml | 2 +- roles/network/tasks/sysd-netd-debian.yml | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/roles/network/tasks/enable_services.yml b/roles/network/tasks/enable_services.yml index 4566c00bb..efbd3e12a 100644 --- a/roles/network/tasks/enable_services.yml +++ b/roles/network/tasks/enable_services.yml @@ -95,8 +95,6 @@ #- debug: # var: nd_dir -# networkd-dispatcher not enabled for is_linuxmint https://github.com/iiab/iiab/issues/3278 -# might need the same dispatcher treatment using networkmanager-dispatcher to bring up dnsmasq or look at dnsmasq-iiab - name: To restart dnsmasq whenever br0 comes up, install /etc/networkd-dispatcher/routable.d/dnsmasq.sh from template (if isn't Appliance, and directory /etc/networkd-dispatcher/routable.d exists, i.e. OS's like Ubuntu 18.04 or later) (root:root by default) template: src: roles/network/templates/network/dnsmasq.sh.j2 @@ -109,7 +107,7 @@ #when: dnsmasq_install and dnsmasq_enabled and nd_enabled is defined and nd_enabled.stdout == "enabled" and nd_dir.stat.exists and nd_dir.stat.isdir and (iiab_network_mode != "Appliance") #when: dnsmasq_install and dnsmasq_enabled and systemd_out.status.UnitFileState == "enabled" and networkd_dir.stat.exists and networkd_dir.stat.isdir and (iiab_network_mode != "Appliance") -- name: Remove /etc/dnsmasq.d/iiab.conf, when is Appliance +- name: Remove /etc/dnsmasq.d/iiab.conf, when not dnsmasq_enabled or is Appliance file: path: /etc/dnsmasq.d/iiab.conf state: absent diff --git a/roles/network/tasks/install.yml b/roles/network/tasks/install.yml index 8ac1b8cc6..0c8592d45 100644 --- a/roles/network/tasks/install.yml +++ b/roles/network/tasks/install.yml @@ -7,7 +7,7 @@ package: name: networkd-dispatcher # 15kB download: Dispatcher service for systemd-networkd connection status changes state: present - when: not is_raspbian or not is_linuxmint + when: not is_raspbian # 2021-07-27 from @jvonau: 3 apt packages BELOW (iw, rfkill, wireless-tools) # are provided by RasPiOS. Ubuntu|Debian on the other hand are hit or miss: diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index ed627f797..d5a494786 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -112,4 +112,3 @@ state: restarted enabled: yes masked: no - when: not is_linuxmint From fe18c8e05080a86433ac797cb7fb43c79ddebe97 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 7 Oct 2022 03:33:41 -0500 Subject: [PATCH 4/7] remove RasPiOS restriction --- roles/network/tasks/install.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/roles/network/tasks/install.yml b/roles/network/tasks/install.yml index 0c8592d45..08a749707 100644 --- a/roles/network/tasks/install.yml +++ b/roles/network/tasks/install.yml @@ -3,12 +3,6 @@ - name: Install dnsmasq -- configure LATER in 'network', after Stage 9 include_tasks: roles/network/tasks/dnsmasq.yml # Invoked by 1-prep (so full path needed) -- name: Install package networkd-dispatcher (OS's other than RasPiOS and Linux Mint) - package: - name: networkd-dispatcher # 15kB download: Dispatcher service for systemd-networkd connection status changes - state: present - when: not is_raspbian - # 2021-07-27 from @jvonau: 3 apt packages BELOW (iw, rfkill, wireless-tools) # are provided by RasPiOS. Ubuntu|Debian on the other hand are hit or miss: # desktops might have some/all 3 preinstalled, while servers tend not to have @@ -19,7 +13,7 @@ # total download size) and they can help IIAB field operators with BOTH # (1) internal WiFi AND (2) USB WiFi devices inserted anytime/later. -- name: 'Install 11 network packages: avahi-daemon, hostapd, iproute2, iptables-persistent, iw, libnss-mdns, netmask, net-tools, rfkill, wireless-tools, wpasupplicant -- later used by https://github.com/iiab/iiab/tree/master/roles/network' +- name: 'Install 12 network packages: avahi-daemon, hostapd, iproute2, iptables-persistent, iw, libnss-mdns, netmask, net-tools, networkd-dispatcher, rfkill, wireless-tools, wpasupplicant -- later used by https://github.com/iiab/iiab/tree/master/roles/network' package: name: - avahi-daemon # 97kB download: RasPiOS (and package libnss-mnds, below) install this regardless -- holdover from the XO days and used to advertise ssh/admin-console being available via avahi-daemon -- used with https://github.com/iiab/iiab/blob/master/roles/network/tasks/avahi.yml @@ -32,6 +26,7 @@ - libnss-mdns # 27kB download: RasPiOS (and package avahi-daemon, above) install this regardless -- client-side library -- provides name resolution via mDNS (Multicast DNS) using Zeroconf/Bonjour e.g. Avahi - netmask # 25kB download: Handy utility -- helps determine network masks - net-tools # 248kB download: RasPiOS installs this regardless -- @jvonau suggests possibly deleting this...unless oldtimers really want these older commands in iiab-diagnostics output? + - networkd-dispatcher # 15kB download: Dispatcher service for systemd-networkd connection status changes - rfkill # 87kB download: RasPiOS installs this regardless -- enable & disable wireless devices - wireless-tools # 112kB download: RasPiOS installs this regardless -- manipulate Linux Wireless Extensions - wpasupplicant # 1188kB download: RasPiOS installs this regardless -- client library for connections to a WiFi AP From 07f663b8eecb18659ea789989c6a9334ecb05abd Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 7 Oct 2022 03:39:01 -0500 Subject: [PATCH 5/7] restore missing optional user disabling of dnsmasq --- roles/network/tasks/enable_services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/enable_services.yml b/roles/network/tasks/enable_services.yml index efbd3e12a..7cdb6da00 100644 --- a/roles/network/tasks/enable_services.yml +++ b/roles/network/tasks/enable_services.yml @@ -111,7 +111,7 @@ file: path: /etc/dnsmasq.d/iiab.conf state: absent - when: iiab_network_mode == "Appliance" + when: not dnsmasq_enabled or iiab_network_mode == "Appliance" - name: Enable iiab-dnsmasq systemd service, if dnsmasq_enabled systemd: From bad5b38e259a1f12ef516811ab416a462c5a27d6 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 7 Oct 2022 13:07:28 -0500 Subject: [PATCH 6/7] always install 00-iiab-debug --- roles/network/tasks/sysd-netd-debian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index d5a494786..fc9067537 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -56,7 +56,7 @@ - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/no-carrier.d/00-iiab-debug' } - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/off.d/00-iiab-debug' } - { src: 'hostapd/00-iiab-debug', dest: '/etc/networkd-dispatcher/routable.d/00-iiab-debug' } - when: discovered_wireless_iface != "none" or discovered_wired_iface != "none" + # when: discovered_wireless_iface != "none" or discovered_wired_iface != "none" - name: Create networkd-dispatcher hook for ap0 on RPi hardware with wifi_up_down True template: From 417386121c79db66272d360e91cdc2b585827663 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 7 Oct 2022 17:32:00 -0500 Subject: [PATCH 7/7] wording --- roles/network/tasks/sysd-netd-debian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index fc9067537..2954d22e3 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -106,7 +106,7 @@ enabled: yes masked: no -- name: Enable & Restart networkd-dispatcher.service except for Linux Mint +- name: Enable & Restart networkd-dispatcher.service systemd: name: networkd-dispatcher state: restarted