From 5c074e59a4cf8c49187cb30631957af5ca8285e9 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Thu, 29 Mar 2018 17:57:24 +0000 Subject: [PATCH 1/8] put rpi in Gateway, enable hostapd --- roles/network/tasks/computed_network.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/roles/network/tasks/computed_network.yml b/roles/network/tasks/computed_network.yml index ee418a81c..62d64bd25 100644 --- a/roles/network/tasks/computed_network.yml +++ b/roles/network/tasks/computed_network.yml @@ -130,7 +130,18 @@ - name: LAN configured - 'Gateway' mode set_fact: iiab_network_mode: "Gateway" - when: iiab_lan_iface != "none" and iiab_wan_iface != "none" + when: (iiab_lan_iface != "none" and iiab_wan_iface != "none") or is_rpi + +- name: Force iiab_lan_iface if is_rpi + set_fact: + iiab_lan_iface: "br0" + iiab_wireless_lan_iface: "wlan0" + when: is_rpi + +- name: Enable hostapd if discovered_wireless_iface is not WAN + set_fact: + hostapd_enabled: True + when: is_rpi and iiab_wan_iface != discovered_wireless_iface # override with user_lan_iface setting if no longer in auto - name: Setting user LAN fact From 227b5f4c323608a88528cc72f8cbf579cad2e4ea Mon Sep 17 00:00:00 2001 From: George Hunt Date: Thu, 29 Mar 2018 20:39:20 +0000 Subject: [PATCH 2/8] wifi really is turned off by rfkill until wpa_supplicant has country= --- roles/network/defaults/main.yml | 2 +- roles/network/tasks/computed_network.yml | 20 ++++++++++++++++++++ roles/network/tasks/main.yml | 21 --------------------- roles/network/tasks/rpi_debian.yml | 20 +++++++++++++++++--- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index cc6862dee..a160a01dc 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -14,7 +14,7 @@ device_gw2: "" iiab_wan_iface: "none" iiab_lan_iface: "none" -#discovered_lan_iface: "none" +discovered_lan_iface: "none" discovered_wired_iface: "none" discovered_wireless_iface: "none" #iiab_wired_lan_iface: "none" diff --git a/roles/network/tasks/computed_network.yml b/roles/network/tasks/computed_network.yml index 62d64bd25..ace548616 100644 --- a/roles/network/tasks/computed_network.yml +++ b/roles/network/tasks/computed_network.yml @@ -167,6 +167,26 @@ iiab_wan_iface: "none" when: adapter_count.stdout|int >= "5" and device_gw == "none" and gui_wan_iface == "unset" and gui_static_wan is defined +- name: Record IIAB_WAN_DEVICE to /etc/iiab/iiab.env + lineinfile: + dest: /etc/iiab/iiab.env + regexp: '^IIAB_WAN_DEVICE=*' + line: 'IIAB_WAN_DEVICE="{{ iiab_wan_iface }}"' + 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: Record IIAB_LAN_DEVICE to /etc/iiab/iiab.env + lineinfile: + dest: /etc/iiab/iiab.env + regexp: '^IIAB_LAN_DEVICE=*' + line: 'IIAB_LAN_DEVICE="{{ iiab_lan_iface }}"' + 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: Add location section to config file ini_file: dest: "{{ iiab_config_file }}" diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index 1735dcc91..f26f83d5a 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -132,27 +132,6 @@ tags: - network -# this is moving -- name: Record IIAB_WAN_DEVICE to /etc/iiab/iiab.env - lineinfile: - dest: /etc/iiab/iiab.env - regexp: '^IIAB_WAN_DEVICE=*' - line: 'IIAB_WAN_DEVICE="{{ iiab_wan_iface }}"' - 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: Record IIAB_LAN_DEVICE to /etc/iiab/iiab.env - lineinfile: - dest: /etc/iiab/iiab.env - regexp: '^IIAB_LAN_DEVICE=*' - line: 'IIAB_LAN_DEVICE="{{ iiab_lan_iface }}"' - state: present - when: not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml - tags: - - network - #### end network layout - include_tasks: restart.yml when: not installing diff --git a/roles/network/tasks/rpi_debian.yml b/roles/network/tasks/rpi_debian.yml index 25390091b..478e4d24e 100644 --- a/roles/network/tasks/rpi_debian.yml +++ b/roles/network/tasks/rpi_debian.yml @@ -20,10 +20,21 @@ dest: /etc/dhcpcd.conf src: network/dhcpcd.conf.j2 +- name: New raspbian requires counry code -- check for it + shell: grep country /etc/wpa_supplicant/wpa_supplicant.conf + register: country_code + +- name: Put a country code if it does not exist + lineinfile: + dest: /etc/wpa_supplicant/wpa_supplicant.conf + regexp: "^country.*" + line: country={{ host_country_code }} + when: country_code.stdout == "" + - name: Copy the bridge script for RPi template: dest: /etc/network/interfaces.d/iiab - src: network/rpi.j2 + src: network/iiab.j2 when: iiab_lan_iface == "br0" - name: Stopping services @@ -48,9 +59,12 @@ - name: Restart hostapd if appropriate service: name: hostapd - enabled: yes state: restarted - when: hostapd_enabled and iiab_wireless_lan_iface is defined and iiab_network_mode != "Appliance" + when: hostapd_enabled and iiab_wan_iface != discoveed_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 != discoveed_wireless_iface and iiab_network_mode != "Appliance" #- name: dhcp_server may be affected - starting - user choice # service: name={{ dhcp_service2 }} state=started From 54066b9b0792fd1f4ecd65f3fe020302ce2ef280 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Fri, 30 Mar 2018 00:17:56 +0000 Subject: [PATCH 3/8] typo, and use rfkill to unblock wifi --- roles/network/tasks/rpi_debian.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/roles/network/tasks/rpi_debian.yml b/roles/network/tasks/rpi_debian.yml index 478e4d24e..be4ea571a 100644 --- a/roles/network/tasks/rpi_debian.yml +++ b/roles/network/tasks/rpi_debian.yml @@ -23,13 +23,18 @@ - name: New raspbian requires counry code -- check for it shell: grep country /etc/wpa_supplicant/wpa_supplicant.conf register: country_code + ignore_errors: True - name: Put a country code if it does not exist lineinfile: dest: /etc/wpa_supplicant/wpa_supplicant.conf regexp: "^country.*" line: country={{ host_country_code }} - when: country_code.stdout == "" + when: country_code is defined and country_code.stdout == "" + +- name: Enable the wifi with rfkill + shell: rfkill unblock 0 + ignore_errors: True - name: Copy the bridge script for RPi template: @@ -60,11 +65,11 @@ service: name: hostapd state: restarted - when: hostapd_enabled and iiab_wan_iface != discoveed_wireless_iface and iiab_network_mode != "Appliance" + 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 != discoveed_wireless_iface and iiab_network_mode != "Appliance" + 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 From dc3f1c8ce00ef4e06458fe56c758a679de41ee3d Mon Sep 17 00:00:00 2001 From: George Hunt Date: Fri, 30 Mar 2018 17:34:42 +0000 Subject: [PATCH 4/8] wrong python_path for centos --- roles/0-init/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index b66db2d5a..01d391d65 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -123,7 +123,7 @@ - name: Set python_path (redhat) set_fact: - python_path: /usr/lib/python2.7/site-packages/ + python_path: /lib/python2.7/site-packages/ when: is_redhat - name: Set python_path (debuntu) From 7ee2bd43b67afab6ad2c714b735e3774ffb9d5a9 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Fri, 30 Mar 2018 18:40:00 +0000 Subject: [PATCH 5/8] centos missing mod_authnz_external --- roles/httpd/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/httpd/tasks/main.yml b/roles/httpd/tasks/main.yml index 518840487..76979dd84 100644 --- a/roles/httpd/tasks/main.yml +++ b/roles/httpd/tasks/main.yml @@ -39,6 +39,7 @@ - httpd - php - php-curl + - mod_authnz_external # - php-sqlite tags: - download From e0eae4fe9bed8008cc0503adac5c5eb0d76c4b84 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Fri, 30 Mar 2018 13:10:35 -0700 Subject: [PATCH 6/8] variables required by redhat --- roles/network/defaults/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index a160a01dc..b4cee63a2 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -17,10 +17,10 @@ iiab_lan_iface: "none" discovered_lan_iface: "none" discovered_wired_iface: "none" discovered_wireless_iface: "none" -#iiab_wired_lan_iface: "none" -#iiab_wireless_lan_iface: "none" #Redhat +iiab_wired_lan_iface: "none" +iiab_wireless_lan_iface: "none" has_WAN: False has_ifcfg_gw: "none" has_wifi_gw: "none" From 82394328cf8e2893f0057b1e1e3e3340a640cbbc Mon Sep 17 00:00:00 2001 From: George Hunt Date: Fri, 30 Mar 2018 16:02:31 -0700 Subject: [PATCH 7/8] centos errors out if no ifcfg files to delete --- roles/network/tasks/ifcfg_mods.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/network/tasks/ifcfg_mods.yml b/roles/network/tasks/ifcfg_mods.yml index 760cdd4aa..2d8a4769f 100644 --- a/roles/network/tasks/ifcfg_mods.yml +++ b/roles/network/tasks/ifcfg_mods.yml @@ -14,6 +14,7 @@ # clear all bridge ifcfg files - name: Now delete slave bridge ifcfg files shell: rm -f /etc/sysconfig/network-scripts/ifcfg-"{{ item }}" + ignore_errors: True when: num_lan_interfaces != 0 or iiab_wireless_lan_iface != "none" with_items: - "{{ ifcfg_slaves.stdout_lines }}" From 9be8d527362125da05f1e7da6d13525e4f8c0297 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Sat, 31 Mar 2018 00:01:45 +0000 Subject: [PATCH 8/8] need systemd service for hostapd unconditionally --- roles/network/tasks/hostapd.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index e5d744d5e..f0c8e9fbe 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -29,7 +29,6 @@ owner: root group: root mode: 0644 - when: hostapd_enabled - name: Create /usr/bin/iiab-hotspot-on from template template: