1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-14 20:22:08 +00:00

Merge pull request #3392 from jvonau/timing

Move 'hooks' to their respective backends
This commit is contained in:
A Holt 2022-10-07 19:31:29 -04:00 committed by GitHub
commit ea74f8cf3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 71 deletions

View file

@ -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,11 +107,11 @@
#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
when: iiab_network_mode == "Appliance"
when: not dnsmasq_enabled or iiab_network_mode == "Appliance"
- name: Enable iiab-dnsmasq systemd service, if dnsmasq_enabled
systemd:

View file

@ -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

View file

@ -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 or not is_linuxmint
# 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

View file

@ -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

View file

@ -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 ap0 on RPi hardware with 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 rpi_model != "none" and wifi_up_down
- name: Remove networkd-dispatcher hook for ap0 on RPi hardware with 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 rpi_model != "none" and not wifi_up_down
- name: Reload systemd
systemd:
@ -71,10 +106,9 @@
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
enabled: yes
masked: no
when: not is_linuxmint