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

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.
This commit is contained in:
Jerry Vonau 2022-10-05 08:23:34 -05:00
parent 92e7e4acfc
commit f02e514cd1
3 changed files with 53 additions and 58 deletions

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

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