diff --git a/iiab-network b/iiab-network index 65c77b55a..563ecace6 100755 --- a/iiab-network +++ b/iiab-network @@ -19,11 +19,11 @@ fi OS="unknown" # will be overridden below, if /etc/iiab/iiab.env is legit if [ -f /etc/iiab/iiab.env ]; then - echo "Running /etc/iiab/iiab.env" + echo "Reading /etc/iiab/iiab.env" source /etc/iiab/iiab.env fi -echo "Ansible will now run iiab-network.yml -- monitor log file iiab-network.log" +echo "Ansible will now run iiab-network.yml -- log file is iiab-network.log" Start=`date` ansible-playbook -i ansible_hosts iiab-network.yml --connection=local End=`date` diff --git a/roles/network/tasks/NM-debian.yml b/roles/network/tasks/NM-debian.yml index a7ece265e..23ecc9dd2 100644 --- a/roles/network/tasks/NM-debian.yml +++ b/roles/network/tasks/NM-debian.yml @@ -29,22 +29,11 @@ when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" - name: Reload systemd - shell: systemctl daemon-reload + systemd: + daemon_reload: yes - name: Restart the NetworkManager service - service: + systemd: name: network-manager state: restarted when: not nobridge is defined and not no_net_restart - -- name: Restart hostapd when WiFi is present - service: - name: hostapd - state: restarted - when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" - -- name: dhcp_server may be affected - starting - user choice - service: - name: "{{ dhcp_service2 }}" - state: started - when: iiab_network_mode != "Appliance" diff --git a/roles/network/tasks/debian.yml b/roles/network/tasks/debian.yml index 69ae60cbd..e2103047d 100644 --- a/roles/network/tasks/debian.yml +++ b/roles/network/tasks/debian.yml @@ -58,7 +58,8 @@ when: dnsmasq_install - name: Reload systemd - shell: systemctl daemon-reload + systemd: + daemon_reload: yes # now pick up denyinterfaces - name: Restart dhcpcd @@ -68,11 +69,3 @@ - name: Restart the networking service service: name=networking state=restarted when: not nobridge is defined and not no_net_restart - -- name: Restart hostapd when WiFi is present - service: name=hostapd state=restarted - when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" - -#- name: dhcp_server may be affected - starting - user choice -# service: name={{ dhcp_service2 }} state=started -# when: iiab_network_mode != "Appliance" diff --git a/roles/network/tasks/enable_services.yml b/roles/network/tasks/enable_services.yml index 243342c15..ee7b395d0 100644 --- a/roles/network/tasks/enable_services.yml +++ b/roles/network/tasks/enable_services.yml @@ -1,9 +1,3 @@ -- name: Disable the Access Point 'hostapd' service - service: enabled=no - name=hostapd.service - when: not iiab_wireless_lan_iface is defined or iiab_network_mode == "Appliance" -#or not hostapd_enabled - - name: Disable dhcpd service service: name=dhcpd enabled=no diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index f0c8e9fbe..f27e60470 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -16,12 +16,6 @@ mode: 0644 when: discovered_wireless_iface is defined -- name: Disable the Access Point 'hostapd' service - service: - enabled: no - name: hostapd.service - when: not hostapd_enabled - - name: Use custom systemd unit file to start 'hostapd' service template: src: hostapd/hostapd.service.j2 @@ -37,6 +31,7 @@ owner: root group: root mode: 0755 + when: is_rpi - name: Create /usr/bin/iiab-hotspot-off from template template: @@ -45,10 +40,24 @@ owner: root group: root mode: 0755 + when: is_rpi -- name: Enable/Restart the Access Point 'hostapd' service - service: - # enabled: yes - state: restarted - name: hostapd.service +- name: Disable the Access Point 'hostapd' service + systemd: + name: hostapd + enabled: no +# cheap workaround for when /etc/init.d is populated +# when: not hostapd_enabled + +- name: Enable the Access Point 'hostapd' service + systemd: + name: hostapd + enabled: yes when: hostapd_enabled and iiab_wireless_lan_iface is defined and iiab_network_mode != "Appliance" + +- name: Record HOSTAPD_ENABLED to /etc/iiab/iiab.env + lineinfile: + dest: /etc/iiab/iiab.env + regexp: '^HOSTAPD_ENABLED=*' + line: 'HOSTAPD_ENABLED={{ hostapd_enabled }}' + state: present diff --git a/roles/network/tasks/ifcfg_mods.yml b/roles/network/tasks/ifcfg_mods.yml index 2d8a4769f..b5a3f5f9c 100644 --- a/roles/network/tasks/ifcfg_mods.yml +++ b/roles/network/tasks/ifcfg_mods.yml @@ -1,6 +1,7 @@ - name: Stop the Access Point hostapd program - service: name=hostapd.service - state=stopped + systemd: + name: hostapd + state: stopped when: iiab_wireless_lan_iface != "none" # might need an exclude for F18 here @@ -81,7 +82,8 @@ when: not installing and not iiab_demo_mode - name: ask systemd to reread the unit files, picks up changes done - shell: systemctl daemon-reload + systemd: + daemon_reload: yes when: not installing # monitor-connection-files defaults to no with F21, F18-F20 defaults to yes diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index cc595770b..f1adc8d92 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -12,23 +12,13 @@ # (2) debian.yml, (3) rpi_debian.yml when: discovered_wireless_iface == iiab_wan_iface and not reboot_to_AP # EITHER WAY: hostapd_enabled's state is RECORDED into /etc/iiab/iiab.env -# (happens just below) for later use by... +# in hostapd.yml for later use by... # /usr/libexec/iiab-startup.sh, iiab-hotspot-off & iiab-hotspot-on # # Separate Idea, Not Without Risks: should WiFi-as-gateway detection logic # be encapsulated into roles/network/tasks/hostapd.yml in future? Whereas # today "./runtags hostapd" doesn't exist & "./runtags AP" is UNSUPPORTED! -- name: Record HOSTAPD_ENABLED to /etc/iiab/iiab.env - lineinfile: - dest: /etc/iiab/iiab.env - regexp: '^HOSTAPD_ENABLED=*' - line: 'HOSTAPD_ENABLED={{ hostapd_enabled }}' - state: present - #when: not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml - tags: - - network - #- name: RPi - reboot to AP post install - installed via wifi so the services are ready # set_fact: # iiab_lan_iface: br0 diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index 98fc09114..30aa4b307 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -1,6 +1,8 @@ -#- name: restart hostapd when wifi is present -# service: name=hostapd state=started -# when: iiab_wireless_lan_iface is defined and hostapd_enabled +- name: restart hostapd when wifi is present + systemd: + name: hostapd + state: restarted + when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" - name: Start named service service: @@ -63,8 +65,8 @@ register: wifi_slave - name: Restart hostapd if WiFi slave is inactive - service: - name: hostapd.service + systemd: + name: hostapd state: restarted when: hostapd_enabled and wifi_slave.stdout is defined and wifi_slave.stdout == 0 diff --git a/roles/network/tasks/rpi_debian.yml b/roles/network/tasks/rpi_debian.yml index be4ea571a..406c70e07 100644 --- a/roles/network/tasks/rpi_debian.yml +++ b/roles/network/tasks/rpi_debian.yml @@ -46,7 +46,8 @@ include_tasks: down-debian.yml - name: Reload systemd - shell: systemctl daemon-reload + systemd: + daemon_reload: yes # now pick up denyinterfaces - name: Restart dhcpcd @@ -60,17 +61,3 @@ enabled: yes state: restarted when: not nobridge is defined and not no_net_restart - -- name: Restart hostapd if appropriate - service: - name: hostapd - state: restarted - when: hostapd_enabled and iiab_wan_iface != discovered_wireless_iface and iiab_network_mode != "Appliance" - -- name: Ansible is having a problem enabling services - shell: systemctl enable hostapd - when: hostapd_enabled and iiab_wan_iface != discovered_wireless_iface and iiab_network_mode != "Appliance" - -#- name: dhcp_server may be affected - starting - user choice -# service: name={{ dhcp_service2 }} state=started -# when: iiab_network_mode != "Appliance" diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index 6e94c9c1f..08e09f1bc 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -19,22 +19,12 @@ include_tasks: down-debian.yml - name: Reload systemd - shell: systemctl daemon-reload + systemd: + daemon_reload: yes - name: Restart the systemd-networkd service - service: + systemd: name: systemd-networkd enabled: yes state: restarted when: not nobridge is defined and not no_net_restart - -- name: Restart hostapd when WiFi is present - service: - name: hostapd - enabled: yes - state: restarted - when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" - -#- name: dhcp_server may be affected - starting - user choice -# service: name={{ dhcp_service2 }} state=started -# when: iiab_network_mode != "Appliance"