From e39f5069a2f55ad9e44af1e93bd129da2034fd81 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 17:36:31 -0400 Subject: [PATCH 001/127] Update kalite/tasks/main.yml --- roles/kalite/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/kalite/tasks/main.yml b/roles/kalite/tasks/main.yml index 7335cafbe..18f46dc65 100644 --- a/roles/kalite/tasks/main.yml +++ b/roles/kalite/tasks/main.yml @@ -30,7 +30,7 @@ name: kalite-serve enabled: yes state: restarted - when: kalite_enabled + when: kalite_enabled | bool - name: Disable & Stop 'kalite-serve' service, if not kalite_enabled systemd: From ad3df8ac653d698f8c77aa0262881e7eae6cc81f Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 17:47:08 -0400 Subject: [PATCH 002/127] Update calibre/tasks/main.yml --- roles/calibre/tasks/main.yml | 86 ++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/roles/calibre/tasks/main.yml b/roles/calibre/tasks/main.yml index 6b0a77d70..e5c9d11c1 100644 --- a/roles/calibre/tasks/main.yml +++ b/roles/calibre/tasks/main.yml @@ -1,5 +1,83 @@ -- include_tasks: install.yml - when: calibre_install and not calibre_installed is defined +# "How do i fail a task in Ansible if the variable contains a boolean value? +# I want to perform input validation for Ansible playbooks" +# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499 -- include_tasks: enable.yml - when: calibre_install or calibre_installed is defined +# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need +# to re-check whether vars are defined here. As Ansible vars cannot be unset: +# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible + +- name: Assert that "calibre_install is sameas true" (boolean not string etc) + assert: + that: calibre_install is sameas true + fail_msg: "PLEASE SET 'calibre_install: True' e.g. IN: /etc/iiab/local_vars.yml" + quiet: yes + +- name: Assert that "calibre_enabled | type_debug == 'bool'" (boolean not string etc) + assert: + that: calibre_enabled | type_debug == 'bool' + fail_msg: "PLEASE GIVE VARIABLE 'calibre_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + quiet: yes + + +- name: Install Calibre if 'calibre_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml + include_tasks: install.yml + when: calibre_installed is undefined + +# http://box:8080 & http://box:8080/mobile WORK BUT OTHER URL'S LIKE http://box/calibre ARE A MESS (BOOKS RARELY DISPLAY) +# +# 2018-08-27 POSSIBLE FIX...CONSIDER THIS ProxyPass / ProxyPassReverse TECHNIQUE: +# https://github.com/iiab/iiab/tree/master/roles/calibre-web/templates/calibre-web.conf.j2 +# (anyway this works great for calibre-web, allowing http://box/books +# to work even better than http://box:8083 when box == 192.168.0.x !) +# +#- name: Attempt to enable http://box/calibre via Apache (UNTESTED) +# command: a2ensite calibre.conf +# when: apache_installed and calibre_enabled +# +#- name: Attempt to disable http://box/calibre via Apache (UNTESTED) +# command: a2dissite calibre.conf +# when: apache_installed and not calibre_enabled + +- name: Enable & (Re)Start 'calibre-serve' service, if calibre_enabled + systemd: + daemon_reload: yes + name: calibre-serve + enabled: yes + state: restarted + when: calibre_enabled | bool + +- name: Disable & Stop 'calibre-serve' service, if not calibre_enabled + systemd: + name: calibre-serve + enabled: no + state: stopped + when: not calibre_enabled + +#- name: Enable/Disable/Restart Apache if primary +# include_tasks: apache.yml +# when: not nginx_enabled +# +#- name: Enable/Disable/Restart NGINX if primary +# include_tasks: nginx.yml +# when: nginx_enabled | bool + + +- name: Add 'calibre' variable values to {{ iiab_ini_file }} + ini_file: + path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini + section: calibre + option: "{{ item.option }}" + value: "{{ item.value | string }}" + with_items: + - option: name + value: Calibre + - option: description + value: '"Calibre is an extremely popular personal library system for e-books."' + - option: calibre_src_url + value: "{{ calibre_src_url }}" + - option: calibre_dbpath + value: "{{ calibre_dbpath }}" + - option: calibre_port + value: "{{ calibre_port }}" + - option: calibre_enabled + value: "{{ calibre_enabled }}" From 81ad70277e385bdbc8a0e4b7b7b418465736000a Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 17:47:52 -0400 Subject: [PATCH 003/127] Delete calibre/tasks/enable.yml --- roles/calibre/tasks/enable.yml | 49 ---------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 roles/calibre/tasks/enable.yml diff --git a/roles/calibre/tasks/enable.yml b/roles/calibre/tasks/enable.yml deleted file mode 100644 index 21bde746b..000000000 --- a/roles/calibre/tasks/enable.yml +++ /dev/null @@ -1,49 +0,0 @@ -# 5. WRAP UP: ENABLE CALIBRE SERVICE, http://box/books ETC - -# http://box:8080 & http://box:8080/mobile WORK BUT OTHER URL'S LIKE http://box/calibre ARE A MESS (BOOKS RARELY DISPLAY) -# -# 2018-08-27 POSSIBLE FIX...CONSIDER THIS ProxyPass / ProxyPassReverse TECHNIQUE: -# https://github.com/iiab/iiab/tree/master/roles/calibre-web/templates/calibre-web.conf.j2 -# (anyway this works great for calibre-web, allowing http://box/books -# to work even better than http://box:8083 when box == 192.168.0.x !) -- name: Attempt to enable http://box/calibre via Apache (UNTESTED) - command: a2ensite calibre.conf - when: apache_installed and calibre_enabled - -- name: Attempt to disable http://box/calibre via Apache (UNTESTED) - command: a2dissite calibre.conf - when: apache_installed and not calibre_enabled - -- name: Enable & Start service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal) - service: - name: calibre-serve - enabled: yes - state: started - when: calibre_enabled | bool - #async: 900 - #poll: 5 - -- name: Reload Apache service ({{ apache_service }}) - systemd: - name: "{{ apache_service }}" - state: reloaded - -- name: Add 'calibre' variable values to {{ iiab_ini_file }} - ini_file: - path: "{{ iiab_ini_file }}" - section: calibre - option: "{{ item.option }}" - value: "{{ item.value | string }}" - with_items: - - option: name - value: Calibre - - option: description - value: '"Calibre is an extremely popular personal library system for e-books."' - - option: url - value: "{{ calibre_src_url }}" - - option: database - value: "{{ calibre_dbpath }}" - - option: port - value: "{{ calibre_port }}" - - option: calibre_enabled - value: "{{ calibre_enabled }}" From 719d680d4cf704d9153847cf44fac8c4de8b665b Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:41:15 -0400 Subject: [PATCH 004/127] Update calibre/tasks/install.yml --- roles/calibre/tasks/install.yml | 58 +++++++++++++-------------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/roles/calibre/tasks/install.yml b/roles/calibre/tasks/install.yml index 1424a81b5..2a48c1127 100644 --- a/roles/calibre/tasks/install.yml +++ b/roles/calibre/tasks/install.yml @@ -1,25 +1,22 @@ -# 1. INSTALL THE LATEST CALIBRE 3.X+ (calibre, calibredb, calibre-server etc) ON ALL OS'S +# 1. INSTALL CALIBRE 4.X+ (calibre, calibredb, calibre-server etc) ON ALL OS'S -- name: Does /usr/bin/calibre exist? - stat: - path: "/usr/bin/calibre" - register: calib_executable +#- name: "Install OS's latest packages: calibre, calibre-bin" +# package: +# name: +# - calibre +# - calibre-bin +# state: latest -- name: "Install OS's latest packages: calibre, calibre-bin (IF not rpi AND /usr/bin/calibre MISSING)" - package: - name: - - calibre - - calibre-bin - state: latest - when: internet_available and not is_raspbian and (not calib_executable.stat.exists) +# May require above 2 pkgs first? +- name: Install Calibre via .debs (raspbian) + command: scripts/calibre-install-latest-rpi.sh # WORKED for Calibre 3.33.1 on 2018-10-23. And Calibre 3.28 on 2018-07-26 (PR #971). Likewise for Calibre 3.26.x. FAILED with Calibre 3.24+ ("calibre : Depends: python-pyqt5 (>= 5.10.1+dfsg-2) but 5.10.1+dfsg-1+rpi1 is to be installed") since June 2018. + #include_tasks: debs.yml + when: is_raspbian | bool -- name: Install Calibre .debs IF calibre_via_debs (AND /usr/bin/calibre WAS MISSING) - include_tasks: debs.yml - when: calibre_via_debs and (not calib_executable.stat.exists) - -- name: Install Calibre via calibre-installer.py IF calibre_via_python (AND /usr/bin/calibre WAS MISSING) +# May require above 2 pkgs first? +- name: Install Calibre via py-installer.yml -> calibre-installer.py (not raspbian) include_tasks: py-installer.yml - when: calibre_via_python and (not calib_executable.stat.exists) + when: not is_raspbian # SEE calibre_via_python's value vars/default_vars.yml, vars/ubuntu-18.yml & # vars/raspbian-9.yml: try to AVOID Python installer on Raspbian since its @@ -34,19 +31,13 @@ # 2. SYSTEMD SERVICES -- name: Create calibre-serve.service and calibre.conf (IF /usr/bin/calibre WAS MISSING) +- name: Create /etc/systemd/system/calibre-serve.service and /etc/calibre.conf template: src: "{{ item.src }}" dest: "{{ item.dest }}" - owner: root - group: root - mode: "{{ item.mode }}" - backup: no - #register: calibre_config with_items: - - { src: 'calibre-serve.service.j2', dest: '/etc/systemd/system/calibre-serve.service', mode: '0644'} - - { src: 'calibre.conf', dest: '/etc/{{ apache_conf_dir }}', mode: '0644'} - when: (not calib_executable.stat.exists) + - { src: 'calibre-serve.service.j2', dest: '/etc/systemd/system/calibre-serve.service'} + - { src: 'calibre.conf', dest: '/etc/{{ apache_conf_dir }}'} - name: Stop service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal) systemd: @@ -57,20 +48,15 @@ # 3. CREATE USER DATABASE -- name: Create /library/calibre (mandatory since Calibre 3.x) +- name: Create {{ calibre_dbpath }} (mandatory since Calibre 3.x) file: - path: "{{ calibre_dbpath }}" + path: "{{ calibre_dbpath }}" # /library/calibre state: directory - #mode: 0755 -- name: Copy template userdb to /library/calibre/users.sqlite (IF /usr/bin/calibre WAS MISSING) +- name: Copy template userdb to {{ calibre_userdb }} copy: src: /opt/iiab/iiab/roles/calibre/templates/users.sqlite - dest: "{{ calibre_userdb }}" - owner: root - group: root - mode: 0644 - when: (not calib_executable.stat.exists) + dest: "{{ calibre_userdb }}" # /library/calibre/users.sqlite # 4. CREATE CONTENT DATABASE WITH A SAMPLE BOOK (REQUIRED AS OF CALIBRE 3.x) From bad864d995617c18bcc4f47b50a01ebe4105f88f Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:43:22 -0400 Subject: [PATCH 005/127] Update raspbian-10.yml --- vars/raspbian-10.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/vars/raspbian-10.yml b/vars/raspbian-10.yml index 1f156a007..3c73327bc 100644 --- a/vars/raspbian-10.yml +++ b/vars/raspbian-10.yml @@ -27,11 +27,6 @@ sshd_service: ssh php_version: 7.3 postgresql_version: 11 systemd_location: /lib/systemd/system -# Upgrade Raspbian Buster's Calibre 3.x: (via role/calibre/tasks/debs.yml, -# with .deb's released about 5-10 days after Calibre's quasi-monthly releases) -calibre_via_debs: True -# roles/calibre/tasks/py-installer.yml FAILS on ARM as of 2018-05-10: -calibre_via_python: False # minetest for rpi minetest_server_bin: /library/games/minetest/bin/minetestserver From 9cd5b7414868253268cb8aa9a68fb4e338e8b2a3 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:43:34 -0400 Subject: [PATCH 006/127] Update ubuntu-20.yml --- vars/ubuntu-20.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/ubuntu-20.yml b/vars/ubuntu-20.yml index de8990863..f58ba79ed 100644 --- a/vars/ubuntu-20.yml +++ b/vars/ubuntu-20.yml @@ -27,6 +27,3 @@ php_version: 7.4 # "postgresql_version: 11.2" failed (too detailed for /etc/systemd/system/postgresql-iiab.service on Ubuntu 19.04) postgresql_version: 12 systemd_location: /lib/systemd/system -# Upgrade Ubuntu 20.04's Calibre 4.x to very latest...for now? -calibre_via_debs: False -calibre_via_python: True From 317ccda90cfa09eac9ada397d4b3993d96c7bdea Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:43:42 -0400 Subject: [PATCH 007/127] Update debian-10.yml --- vars/debian-10.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/debian-10.yml b/vars/debian-10.yml index 9780612da..3dc80fa27 100644 --- a/vars/debian-10.yml +++ b/vars/debian-10.yml @@ -25,6 +25,3 @@ sshd_service: ssh php_version: 7.3 postgresql_version: 11 systemd_location: /lib/systemd/system -# Upgrade OS's own Calibre to very latest: -calibre_via_debs: False -calibre_via_python: True From f826395e4483c197e630d89391d32635c7e2d3ec Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:44:56 -0400 Subject: [PATCH 008/127] Update ubuntu-19.yml --- vars/ubuntu-19.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/ubuntu-19.yml b/vars/ubuntu-19.yml index 348146c67..ac6ccda75 100644 --- a/vars/ubuntu-19.yml +++ b/vars/ubuntu-19.yml @@ -27,6 +27,3 @@ php_version: 7.3 # "postgresql_version: 11.2" fails (too detailed for /etc/systemd/system/postgresql-iiab.service on Ubuntu 19.04) postgresql_version: 11 systemd_location: /lib/systemd/system -# Upgrade Ubuntu 19.x's Calibre 3.39.1+ to very latest -calibre_via_debs: False -calibre_via_python: True From 9a8aba76e486bb7130b1391890f4e7571098f901 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:45:25 -0400 Subject: [PATCH 009/127] Update ubuntu-18.yml --- vars/ubuntu-18.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/ubuntu-18.yml b/vars/ubuntu-18.yml index 1b5579da8..32b0923b6 100644 --- a/vars/ubuntu-18.yml +++ b/vars/ubuntu-18.yml @@ -27,6 +27,3 @@ php_version: 7.2 # "postgresql_version: 10.3" fails (too detailed for /etc/systemd/system/postgresql-iiab.service on Ubuntu 18.04) postgresql_version: 10 systemd_location: /lib/systemd/system -# Upgrade Ubuntu 18.04's Calibre 3.21.0 to very latest: -calibre_via_debs: False -calibre_via_python: True From 518431397292c5277adb59c9d4a926caa81e1d98 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:46:20 -0400 Subject: [PATCH 010/127] Update ubuntu-17.yml --- vars/ubuntu-17.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/ubuntu-17.yml b/vars/ubuntu-17.yml index 751b16706..ff03515e0 100644 --- a/vars/ubuntu-17.yml +++ b/vars/ubuntu-17.yml @@ -26,6 +26,3 @@ sshd_service: ssh php_version: 7.1 postgresql_version: 9.6 systemd_location: /lib/systemd/system -# Upgrade Ubuntu 17.10's Calibre 3.7.0 to very latest: -calibre_via_debs: False -calibre_via_python: True From 8456d7b91e75095519ed89dcd492d53550cb8ce6 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:46:35 -0400 Subject: [PATCH 011/127] Update ubuntu-16.yml --- vars/ubuntu-16.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/ubuntu-16.yml b/vars/ubuntu-16.yml index 96312974a..5c1cdeb7e 100644 --- a/vars/ubuntu-16.yml +++ b/vars/ubuntu-16.yml @@ -25,6 +25,3 @@ sshd_service: ssh php_version: 7.0 postgresql_version: 9.5 systemd_location: /lib/systemd/system -# Upgrade Ubuntu 16.04's Calibre 2.55.0 to very latest: -calibre_via_debs: False -calibre_via_python: True From 652d5a8a4b5adab8fffec34470136e437351b9ac Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:47:01 -0400 Subject: [PATCH 012/127] Update raspbian-9.yml --- vars/raspbian-9.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/vars/raspbian-9.yml b/vars/raspbian-9.yml index 069afaac9..d25755700 100644 --- a/vars/raspbian-9.yml +++ b/vars/raspbian-9.yml @@ -27,11 +27,6 @@ sshd_service: ssh php_version: 7.0 postgresql_version: 9.6 systemd_location: /lib/systemd/system -# Upgrade Raspbian Stretch's Calibre 2.75.1: (via role/calibre/tasks/debs.yml, -# with .deb's released about 5-10 days after Calibre's quasi-monthly releases) -calibre_via_debs: True -# roles/calibre/tasks/py-installer.yml FAILS on ARM as of 2018-05-10: -calibre_via_python: False # minetest for rpi minetest_server_bin: /library/games/minetest/bin/minetestserver From 703b5149f9b35cfff6e6ac27467895b4ad31911f Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:47:20 -0400 Subject: [PATCH 013/127] Update raspbian-8.yml --- vars/raspbian-8.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/vars/raspbian-8.yml b/vars/raspbian-8.yml index 1d5e190e3..94d628895 100644 --- a/vars/raspbian-8.yml +++ b/vars/raspbian-8.yml @@ -26,8 +26,3 @@ sshd_service: ssh php_version: 5 postgresql_version: 9.4 systemd_location: /lib/systemd/system -# Upgrade Raspbian Jessie's Calibre 2.5.0: (via role/calibre/tasks/debs.yml, -# with .deb's released about 5-10 days after Calibre's quasi-monthly releases) -calibre_via_debs: True -# roles/calibre/tasks/py-installer.yml FAILS on ARM as of 2018-05-10: -calibre_via_python: False From b5293845ba5a2ed7bc178b3280fd22f8cd263241 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:47:36 -0400 Subject: [PATCH 014/127] Update fedora-22.yml --- vars/fedora-22.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/fedora-22.yml b/vars/fedora-22.yml index 2c8ec05b6..6dcfa4337 100644 --- a/vars/fedora-22.yml +++ b/vars/fedora-22.yml @@ -22,6 +22,3 @@ apache_log: /var/log/httpd/access_log sshd_package: openssh-server sshd_service: sshd systemd_location: /usr/lib/systemd/system -# Upgrade OS's own Calibre to very latest: -calibre_via_debs: False -calibre_via_python: True From 7ecd3afddf1213a3cd78fceab24ecbca23dc773c Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:47:51 -0400 Subject: [PATCH 015/127] Update fedora-18.yml --- vars/fedora-18.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/fedora-18.yml b/vars/fedora-18.yml index ca863a016..f35a81364 100644 --- a/vars/fedora-18.yml +++ b/vars/fedora-18.yml @@ -26,6 +26,3 @@ sshd_service: sshd nextcloud_install: False nextcloud_enabled: False systemd_location: /usr/lib/systemd/system -# Upgrade OS's own Calibre to very latest: -calibre_via_debs: False -calibre_via_python: True From 6586726e705066dce1e31329fb2854484e8d555a Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:48:14 -0400 Subject: [PATCH 016/127] Update debian-9.yml --- vars/debian-9.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/debian-9.yml b/vars/debian-9.yml index 19ef67bb3..ac1fc1b73 100644 --- a/vars/debian-9.yml +++ b/vars/debian-9.yml @@ -25,6 +25,3 @@ sshd_service: ssh php_version: 7.0 postgresql_version: 9.6 systemd_location: /lib/systemd/system -# Upgrade OS's own Calibre to very latest: -calibre_via_debs: False -calibre_via_python: True From 879244d379c10809a327f19f7265660d3045dd40 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:48:29 -0400 Subject: [PATCH 017/127] Update debian-8.yml --- vars/debian-8.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/debian-8.yml b/vars/debian-8.yml index bb23c04b0..e1713a1df 100644 --- a/vars/debian-8.yml +++ b/vars/debian-8.yml @@ -24,6 +24,3 @@ sshd_service: ssh php_version: 5 postgresql_version: 9.4 systemd_location: /lib/systemd/system -# Upgrade OS's own Calibre to very latest: -calibre_via_debs: False -calibre_via_python: True From 9301e4d4851a16891c56e3788b58a4030e048bca Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 18:48:46 -0400 Subject: [PATCH 018/127] Update centos-7.yml --- vars/centos-7.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/vars/centos-7.yml b/vars/centos-7.yml index c57ab58f7..18e99ac54 100644 --- a/vars/centos-7.yml +++ b/vars/centos-7.yml @@ -25,6 +25,3 @@ sshd_service: sshd php_version: 7.0 postgresql_version: 9.5 systemd_location: /usr/lib/systemd/system -# Upgrade OS's own Calibre to very latest: -calibre_via_debs: False -calibre_via_python: True From 2899a73bbcb4eb7356a94ac03ff391c4843d5233 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 29 Apr 2020 23:52:22 +0000 Subject: [PATCH 019/127] Update calibre/tasks/install.yml --- roles/calibre/tasks/install.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/roles/calibre/tasks/install.yml b/roles/calibre/tasks/install.yml index 2a48c1127..2982fe60e 100644 --- a/roles/calibre/tasks/install.yml +++ b/roles/calibre/tasks/install.yml @@ -1,22 +1,23 @@ # 1. INSTALL CALIBRE 4.X+ (calibre, calibredb, calibre-server etc) ON ALL OS'S -#- name: "Install OS's latest packages: calibre, calibre-bin" -# package: -# name: -# - calibre -# - calibre-bin -# state: latest +- name: "Install OS's latest packages: calibre, calibre-bin" + package: + name: + - calibre + - calibre-bin + state: latest -# May require above 2 pkgs first? -- name: Install Calibre via .debs (raspbian) +- name: Install Calibre via .debs (if Raspbian) command: scripts/calibre-install-latest-rpi.sh # WORKED for Calibre 3.33.1 on 2018-10-23. And Calibre 3.28 on 2018-07-26 (PR #971). Likewise for Calibre 3.26.x. FAILED with Calibre 3.24+ ("calibre : Depends: python-pyqt5 (>= 5.10.1+dfsg-2) but 5.10.1+dfsg-1+rpi1 is to be installed") since June 2018. - #include_tasks: debs.yml when: is_raspbian | bool -# May require above 2 pkgs first? -- name: Install Calibre via py-installer.yml -> calibre-installer.py (not raspbian) - include_tasks: py-installer.yml - when: not is_raspbian +# 2020-04-29: Can work *IF* you do 'apt install python2' and change top line +# of /opt/iiab/downloads/calibre-installer.py from '#!/usr/bin/env python2' +# to '#!/usr/bin/python2' +# +#- name: Install Calibre via py-installer.yml -> calibre-installer.py (if not Raspbian) +# include_tasks: py-installer.yml +# when: not is_raspbian # SEE calibre_via_python's value vars/default_vars.yml, vars/ubuntu-18.yml & # vars/raspbian-9.yml: try to AVOID Python installer on Raspbian since its From 483ab973f0458d9fbe13881fc0e023d7add651a7 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 20:06:33 -0400 Subject: [PATCH 020/127] Update calibre/tasks/install.yml --- roles/calibre/tasks/install.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/roles/calibre/tasks/install.yml b/roles/calibre/tasks/install.yml index 2982fe60e..ad72beade 100644 --- a/roles/calibre/tasks/install.yml +++ b/roles/calibre/tasks/install.yml @@ -7,9 +7,14 @@ - calibre-bin state: latest -- name: Install Calibre via .debs (if Raspbian) - command: scripts/calibre-install-latest-rpi.sh # WORKED for Calibre 3.33.1 on 2018-10-23. And Calibre 3.28 on 2018-07-26 (PR #971). Likewise for Calibre 3.26.x. FAILED with Calibre 3.24+ ("calibre : Depends: python-pyqt5 (>= 5.10.1+dfsg-2) but 5.10.1+dfsg-1+rpi1 is to be installed") since June 2018. - when: is_raspbian | bool +# 2020-04-29: AT YOUR OWN RISK, this *sometimes* works, e.g. to upgrade from +# Raspbian 10's Calibre 3.39.1 to "4.99.4+dfsg+really4.12.0-1" or higher, from: +# http://raspbian.raspberrypi.org/raspbian/pool/main/c/calibre/ +# http://archive.raspbian.org/raspbian/pool/main/c/calibre/ +# +#- name: Install Calibre via .debs (if Raspbian) +# command: scripts/calibre-install-latest-rpi.sh # WORKED for Calibre 3.33.1 on 2018-10-23. And Calibre 3.28 on 2018-07-26 (PR #971). Likewise for Calibre 3.26.x. FAILED with Calibre 3.24+ ("calibre : Depends: python-pyqt5 (>= 5.10.1+dfsg-2) but 5.10.1+dfsg-1+rpi1 is to be installed") since June 2018. +# when: is_raspbian | bool # 2020-04-29: Can work *IF* you do 'apt install python2' and change top line # of /opt/iiab/downloads/calibre-installer.py from '#!/usr/bin/env python2' @@ -17,7 +22,7 @@ # #- name: Install Calibre via py-installer.yml -> calibre-installer.py (if not Raspbian) # include_tasks: py-installer.yml -# when: not is_raspbian +# when: not is_raspbian # True Debian or any Ubuntu? # SEE calibre_via_python's value vars/default_vars.yml, vars/ubuntu-18.yml & # vars/raspbian-9.yml: try to AVOID Python installer on Raspbian since its From 02ac99e03fadb0d893d22fc827a1a7f4278c0258 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 20:10:52 -0400 Subject: [PATCH 021/127] Update calibre/tasks/install.yml --- roles/calibre/tasks/install.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/calibre/tasks/install.yml b/roles/calibre/tasks/install.yml index ad72beade..ca2eddf39 100644 --- a/roles/calibre/tasks/install.yml +++ b/roles/calibre/tasks/install.yml @@ -1,4 +1,4 @@ -# 1. INSTALL CALIBRE 4.X+ (calibre, calibredb, calibre-server etc) ON ALL OS'S +# 1. INSTALL CALIBRE 3.39.1+ or 4.12+ (calibre, calibredb, calibre-server etc) ON ALL OS'S - name: "Install OS's latest packages: calibre, calibre-bin" package: @@ -18,7 +18,7 @@ # 2020-04-29: Can work *IF* you do 'apt install python2' and change top line # of /opt/iiab/downloads/calibre-installer.py from '#!/usr/bin/env python2' -# to '#!/usr/bin/python2' +# to '#!/usr/bin/python2' e.g. to upgrade Calibre 4.12 on Ubuntu 20.04 LTS. # #- name: Install Calibre via py-installer.yml -> calibre-installer.py (if not Raspbian) # include_tasks: py-installer.yml From 9272926630acd00c0211eea60e8c392a9585a48e Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Apr 2020 20:15:50 -0400 Subject: [PATCH 022/127] Update roles/nginx/README.md --- roles/nginx/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/nginx/README.md b/roles/nginx/README.md index 261d0ac74..6b8edd323 100644 --- a/roles/nginx/README.md +++ b/roles/nginx/README.md @@ -10,7 +10,7 @@ 2. Without PHP available via FastCGI, any function at all for PHP-based applications validates NGINX. -3. Current state of IIAB App/Service migrations as of 2020-04-24: +3. Current state of IIAB App/Service migrations as of 2020-04-29: 1. These support "Native" NGINX but ***NOT*** Apache * Admin Console @@ -39,7 +39,7 @@ * nodered 4. These each run their own web server or non-web / backend services, e.g. off of their own [unique port(s)](https://github.com/iiab/iiab/wiki/IIAB-Networking#list-of-ports--services) (IIAB home pages link directly to these destinations). In future we'd like mnemonic URL's for all of these: (e.g. http://box/calibre, http://box/archive, http://box/kalite) - * calibre (menu goes directly to port 8080) [*] + * calibre (menu goes directly to port 8080) * internetarchive (menu goes directly to port 4244, [PR #2120](https://github.com/iiab/iiab/pull/2120)) [*] * kalite (menu goes directly to ports 8006-8008) * minetest [*] @@ -47,4 +47,4 @@ * pbx [*] * transmission [*] -[*] The 5 above starred roles could use improvement, as of 2020-04-24. +[*] The 4 above starred roles could use improvement, as of 2020-04-29. From 50a5cc0d8559043e0dd1821707948313c424aeed Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Apr 2020 01:53:14 +0000 Subject: [PATCH 023/127] Mark 5 of 6 as .unused: scripts/calibre-install-* --- ...test-rpi-plus.sh => calibre-install-latest-rpi-plus.sh.unused} | 0 ...calibre-install-latest.sh => calibre-install-latest.sh.unused} | 0 ...re-install-packages.sh => calibre-install-packages.sh.unusued} | 0 ...install-pinned-rpi.sh => calibre-install-pinned-rpi.sh.unused} | 0 ...bre-install-unstable.sh => calibre-install-unstable.sh.unused} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename scripts/{calibre-install-latest-rpi-plus.sh => calibre-install-latest-rpi-plus.sh.unused} (100%) rename scripts/{calibre-install-latest.sh => calibre-install-latest.sh.unused} (100%) rename scripts/{calibre-install-packages.sh => calibre-install-packages.sh.unusued} (100%) rename scripts/{calibre-install-pinned-rpi.sh => calibre-install-pinned-rpi.sh.unused} (100%) rename scripts/{calibre-install-unstable.sh => calibre-install-unstable.sh.unused} (100%) diff --git a/scripts/calibre-install-latest-rpi-plus.sh b/scripts/calibre-install-latest-rpi-plus.sh.unused similarity index 100% rename from scripts/calibre-install-latest-rpi-plus.sh rename to scripts/calibre-install-latest-rpi-plus.sh.unused diff --git a/scripts/calibre-install-latest.sh b/scripts/calibre-install-latest.sh.unused similarity index 100% rename from scripts/calibre-install-latest.sh rename to scripts/calibre-install-latest.sh.unused diff --git a/scripts/calibre-install-packages.sh b/scripts/calibre-install-packages.sh.unusued similarity index 100% rename from scripts/calibre-install-packages.sh rename to scripts/calibre-install-packages.sh.unusued diff --git a/scripts/calibre-install-pinned-rpi.sh b/scripts/calibre-install-pinned-rpi.sh.unused similarity index 100% rename from scripts/calibre-install-pinned-rpi.sh rename to scripts/calibre-install-pinned-rpi.sh.unused diff --git a/scripts/calibre-install-unstable.sh b/scripts/calibre-install-unstable.sh.unused similarity index 100% rename from scripts/calibre-install-unstable.sh rename to scripts/calibre-install-unstable.sh.unused From 85854a2d976476308c02d6ff52389798815ee845 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Apr 2020 01:55:36 +0000 Subject: [PATCH 024/127] rm roles/kalite/tasks/*.unused --- roles/kalite/tasks/enable.yml.unused | 59 -------------- roles/kalite/tasks/install-f18.yml.unused | 76 ------------------ roles/kalite/tasks/install-old.yml.unused | 95 ----------------------- roles/kalite/tasks/setup-f18.yml.unused | 14 ---- roles/kalite/tasks/setup.yml.unused | 32 -------- 5 files changed, 276 deletions(-) delete mode 100644 roles/kalite/tasks/enable.yml.unused delete mode 100644 roles/kalite/tasks/install-f18.yml.unused delete mode 100644 roles/kalite/tasks/install-old.yml.unused delete mode 100644 roles/kalite/tasks/setup-f18.yml.unused delete mode 100644 roles/kalite/tasks/setup.yml.unused diff --git a/roles/kalite/tasks/enable.yml.unused b/roles/kalite/tasks/enable.yml.unused deleted file mode 100644 index 529cf86e8..000000000 --- a/roles/kalite/tasks/enable.yml.unused +++ /dev/null @@ -1,59 +0,0 @@ -# By the time we get here we should have ka-lite of some version -# And the systemd unit files should be defined - -- name: Enable & (re)start 'kalite-serve' service - systemd: - daemon_reload: yes - name: kalite-serve - enabled: yes - state: restarted - when: kalite_enabled - -- name: Disable & stop 'kalite-serve' service - systemd: - name: kalite-serve - enabled: no - state: stopped - when: not kalite_enabled - -# 2019-10-20: Below is for Fedora 18 (XO laptops) only. -# Since F18 we don't have a separate unit file for kalite-cron. -# -# SEE --skip-job-scheduler @ https://ka-lite.readthedocs.io/en/latest/usermanual/cli.html -# ...as implemented in templates/kalite-serve.service.j2 -# ...if not kalite_cron_enabled -# ...using {{ job_scheduler_stanza }} from kalite/tasks/install.yml - -- name: Enable & (re)start 'kalite-cron' service (F18) - service: - name: kalite-cron - enabled: yes - state: restarted - when: kalite_cron_enabled and is_F18 - -- name: Disable & stop 'kalite-cron' service (F18) - service: - name: kalite-cron - enabled: no - state: stopped - when: not kalite_cron_enabled and is_F18 - -- name: Add 'kalite' variable values to {{ iiab_ini_file }} - ini_file: - path: "{{ iiab_ini_file }}" - section: kalite - option: "{{ item.option }}" - value: "{{ item.value | string }}" - with_items: - - option: name - value: "KA Lite" - - option: description - value: '"KA Lite downloads Khan Academy videos for offline use, with exercises and accounts if students want to track their own progress."' - - option: path - value: "{{ kalite_root }}" - - option: port - value: "{{ kalite_server_port }}" - - option: kalite_enabled - value: "{{ kalite_enabled }}" - - option: cron_enabled - value: "{{ kalite_cron_enabled }}" diff --git a/roles/kalite/tasks/install-f18.yml.unused b/roles/kalite/tasks/install-f18.yml.unused deleted file mode 100644 index 28cd4cb1c..000000000 --- a/roles/kalite/tasks/install-f18.yml.unused +++ /dev/null @@ -1,76 +0,0 @@ -# This is for Fedora 18, assumed to be an XO - -- name: Install dependent packages (Fedora 18) - package: - name: "{{ item }}" - state: present - with_items: - - python-psutil - - expect - when: is_F18 | bool - -- name: Install dependent pip packages (Fedora 18) - pip: - name: selenium - when: internet_available and is_F18 - -- name: Determine if KA Lite is already downloaded - stat: - path: "{{ downloads_dir }}/ka-lite" - register: kalite - -- name: Download the latest KA Lite repo - git: - repo: "{{ kalite_repo_url }}" - dest: "{{ downloads_dir }}/ka-lite" - depth: 1 - version: 0.13.x - ignore_errors: yes - when: internet_available and kalite.stat.exists is defined and not kalite.stat.exists - -- name: Create iiab-kalite user and password (Fedora 18) - user: - name: "{{ kalite_user }}" - password: "{{ kalite_password_hash }}" - update_password: on_create - -- name: Create kalite_root directory (Fedora 18) - file: - path: "{{ kalite_root }}" - owner: root - group: root - mode: 0755 - state: directory - -- name: Copy the KA Lite repo into place (Fedora 18) - command: "rsync -at {{ downloads_dir }}/ka-lite/ {{ kalite_root }}" - -- name: Make kalite_user owner - file: - path: "{{ kalite_root }}" - owner: "{{ kalite_user }}" - group: "{{ kalite_user }}" - recurse: yes - state: directory - -# local_settings is deprecated -- name: Copy local_settings file - template: - src: f18/local_settings.py.j2 - dest: "{{ kalite_root }}/kalite/local_settings.py" - owner: "{{ kalite_user }}" - group: "{{ kalite_user }}" - mode: 0644 - -- name: Create kalite-serve & kalite-cron services, and iiab_cronservectl.sh - template: - backup: no - src: "{{ item.src }}" - dest: "{{ item.dest }}" - owner: root - group: root - mode: "{{ item.mode }}" - with_items: - - { src: 'f18/kalite-serve.service.j2', dest: '/etc/systemd/system/kalite-serve.service', mode: '0644'} - - { src: 'f18/kalite-cron.service.j2', dest: '/etc/systemd/system/kalite-cron.service', mode: '0644'} - - { src: 'f18/iiab_cronservectl.sh.j2', dest: '{{ kalite_root }}/scripts/iiab_cronservectl.sh', mode: '0755'} diff --git a/roles/kalite/tasks/install-old.yml.unused b/roles/kalite/tasks/install-old.yml.unused deleted file mode 100644 index 1e0879c58..000000000 --- a/roles/kalite/tasks/install-old.yml.unused +++ /dev/null @@ -1,95 +0,0 @@ -# For OS's other than Fedora 18 -- name: Download {{ kalite_requirements }} to {{ pip_packages_dir }}/kalite.txt - get_url: - url: "{{ kalite_requirements }}" - dest: "{{ pip_packages_dir }}/kalite.txt" # /opt/iiab/pip-packages/kalite.txt - timeout: "{{ download_timeout }}" - when: internet_available | bool - -# 2020-01-19: https://github.com/piwheels/packages/issues/74 says the following is not longer needed... -#- name: Run 'mv /etc/pip.conf /etc/pip.conf.see-iiab-issue-2139' as "TEMPORARY" workaround (2020-01-17) for piwheels.org's setuptools Python 2/3 brokenness on RPi (https://github.com/iiab/iiab/issues/2139) -# command: mv /etc/pip.conf /etc/pip.conf.see-iiab-issue-2139 -# ignore_errors: yes -# when: is_raspbian | bool - -#- name: Install KA Lite non-static + reqs file with pip - (debuntu) -# pip: requirements={{ pip_packages_dir }}/kalite.txt -# virtualenv={{ kalite_venv }} -# virtualenv_site_packages=no -# extra_args="--no-cache-dir" -# extra_args="--disable-pip-version-check" -# when: internet_available and is_debuntu - -- name: Install KA Lite static to {{ kalite_venv }}, using pip (debuntu) - pip: - name: ka-lite-static - version: "{{ kalite_version }}" - virtualenv: "{{ kalite_venv }}" - virtualenv_site_packages: no - virtualenv_command: /usr/bin/virtualenv - virtualenv_python: python2.7 - extra_args: "--no-cache-dir" -# extra_args="--disable-pip-version-check" - when: internet_available and is_debuntu - -#- name: Install KA Lite non-static + reqs file with pip (OS's other than debuntu) -# pip: requirements={{ pip_packages_dir }}/kalite.txt -# virtualenv={{ kalite_venv }} -# virtualenv_site_packages=no -# extra_args="--no-cache-dir" -# extra_args="--disable-pip-version-check" -# when: internet_available and not is_debuntu - -- name: Install KA Lite static to {{ kalite_venv }}, using pip (OS's other than debuntu) - pip: - name: ka-lite-static - version: "{{ kalite_version }}" - virtualenv: "{{ kalite_venv }}" - virtualenv_site_packages: no - virtualenv_command: /usr/bin/virtualenv - virtualenv_python: python2.7 -# extra_args="--no-cache-dir" -# extra_args="--disable-pip-version-check" - when: internet_available and not is_debuntu - -# This effectively does nothing at all on Ubuntu & Raspbian, where libgeos-* -# pkgs are not installed FWIW. But it's included to safeguard us across all -# OS's, in case others OS's like Ubermix later appear. See #1382 for details. -# Removing pkgs libgeos-3.6.2 & libgeos-c1v5 fixed the situation on Ubermix! -- name: Remove libgeos-* pkgs, avoiding KA Lite Django failure on Ubermix - shell: apt -y remove "libgeos-*" - -# 2019-10-20: For Fedora 18 legacy (XO laptops) specially -- name: Default is to have cronserve started with KA Lite - set_fact: - job_scheduler_stanza: "" - -- name: Add --skip-job-scheduler to start if cronserve not enabled - set_fact: - job_scheduler_stanza: "--skip-job-scheduler " - when: not kalite_cron_enabled - -- name: "Install from template: venv wrapper /usr/bin/kalite, systemd unit file kalite-serve.service, Apache's kalite.conf" - template: - backup: no - src: "{{ item.src }}" - dest: "{{ item.dest }}" - owner: root - group: root - mode: "{{ item.mode }}" - with_items: - - { src: 'kalite.sh.j2', dest: '/usr/bin/kalite', mode: '0755'} - - { src: 'kalite-serve.service.j2', dest: '/etc/systemd/system/kalite-serve.service', mode: '0644'} - - { src: 'kalite.conf', dest: '/etc/{{ apache_conf_dir }}', mode: '0644'} - -- name: Fix KA Lite bug in regex parsing ifconfig output, for @m-anish's network names that contain dashes - replace: - path: /usr/local/kalite/venv/local/lib/python2.7/site-packages/kalite/packages/dist/ifcfg/parser.py - regexp: 'a-zA-Z0-9' - replace: 'a-zA-Z0-9\-' - - -# RECORD KA Lite AS INSTALLED - -# TO DO: move the last 2 stanzas from setup.yml so they live right here, -# as any action named "install.yml" should do exactly what it says (install!) diff --git a/roles/kalite/tasks/setup-f18.yml.unused b/roles/kalite/tasks/setup-f18.yml.unused deleted file mode 100644 index 23037d260..000000000 --- a/roles/kalite/tasks/setup-f18.yml.unused +++ /dev/null @@ -1,14 +0,0 @@ -# This is for Fedora 18, assumed to be an XO - -- name: Run the setup using 'kalite manage' (Fedora 18) - command: "/usr/bin/su {{ kalite_user }} -c '{{ kalite_root }}/bin/kalite manage setup --username={{ kalite_user }} --password={{ kalite_password }} --noinput'" - async: 900 - poll: 10 - -- name: Finish setup by running 'kalite start' (Fedora 18) - command: "/usr/bin/su {{ kalite_user }} -c '{{ kalite_root }}/bin/kalite start'" - async: 900 - poll: 10 - -- name: Stop kalite server started in previous step because we use systemd - command: "/usr/bin/su {{ kalite_user }} -c '{{ kalite_root }}/bin/kalite stop'" diff --git a/roles/kalite/tasks/setup.yml.unused b/roles/kalite/tasks/setup.yml.unused deleted file mode 100644 index 7884e6be2..000000000 --- a/roles/kalite/tasks/setup.yml.unused +++ /dev/null @@ -1,32 +0,0 @@ -# For OS's other than Fedora 18 - -- name: Create {{ kalite_root }} directory - file: - path: "{{ kalite_root }}/httpsrv/static" # /library/ka-lite - # owner: root - # group: root - # mode: 0755 - state: directory - -- name: Run the setup using 'kalite manage' - command: "{{ kalite_program }} manage setup --username={{ kalite_admin_user }} --password={{ kalite_admin_password }} --noinput" # Runs /usr/local/kalite/venv/bin/kalite - environment: - KALITE_HOME: "{{ kalite_root }}" # /library/ka-lite - async: 1800 - poll: 10 - - -# RECORD KA Lite AS INSTALLED - -# TO DO: move these last 2 stanzas to install.yml, -# as any action named "install.yml" should do exactly what it says (install!) - -- name: "Set 'kalite_installed: True'" - set_fact: - kalite_installed: True - -- name: "Add 'kalite_installed: True' to {{ iiab_state_file }}" - lineinfile: - path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml - regexp: '^kalite_installed' - line: 'kalite_installed: True' From 93d787f3d24870597cf98b6e3a3422bd04b69d54 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 30 Apr 2020 14:02:36 -0400 Subject: [PATCH 025/127] calibre/tasks/install.yml - clarify #529, PR #2378 --- roles/calibre/tasks/install.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/calibre/tasks/install.yml b/roles/calibre/tasks/install.yml index ca2eddf39..856fbfbf9 100644 --- a/roles/calibre/tasks/install.yml +++ b/roles/calibre/tasks/install.yml @@ -37,13 +37,13 @@ # 2. SYSTEMD SERVICES -- name: Create /etc/systemd/system/calibre-serve.service and /etc/calibre.conf +- name: Create /etc/systemd/system/calibre-serve.service and /etc/{{ apache_conf_dir }}/calibre.conf template: src: "{{ item.src }}" dest: "{{ item.dest }}" with_items: - - { src: 'calibre-serve.service.j2', dest: '/etc/systemd/system/calibre-serve.service'} - - { src: 'calibre.conf', dest: '/etc/{{ apache_conf_dir }}'} + - { src: 'calibre-serve.service.j2', dest: '/etc/systemd/system/calibre-serve.service' } + - { src: 'calibre.conf', dest: '/etc/{{ apache_conf_dir }}' } # apache2/sites-available (this doesn't work, see #529: let's try to create /etc/nginx/conf.d/calibre-nginx.conf in future!) - name: Stop service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal) systemd: From 87b86000b23e4afddf4aabe67be79187974122c7 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 8 Sep 2018 21:59:50 +0000 Subject: [PATCH 026/127] method to creat ap0 and have hostapd use it --- roles/network/tasks/hostapd.yml | 8 ++++++++ roles/network/templates/hostapd/70-persistent-net.rules | 3 +++ roles/network/templates/hostapd/hostapd.conf.j2 | 3 +-- roles/network/templates/hostapd/iiab-hostapd.conf.j2 | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 roles/network/templates/hostapd/70-persistent-net.rules diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 386eafb92..cea1f1bd4 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -21,6 +21,14 @@ mode: 0644 when: discovered_wireless_iface != "none" +- name: Use custom udev rule to create ap0 + template: + src: hostapd/70-persistent-net.rules + dest: /etc/udev/rules.d/70-persistent-net.rules + owner: root + group: root + mode: 0644 + - name: Use custom systemd unit file to start 'hostapd' service template: src: hostapd/hostapd.service.j2 diff --git a/roles/network/templates/hostapd/70-persistent-net.rules b/roles/network/templates/hostapd/70-persistent-net.rules new file mode 100644 index 000000000..5e9cca3c3 --- /dev/null +++ b/roles/network/templates/hostapd/70-persistent-net.rules @@ -0,0 +1,3 @@ +SUBSYSTEM=="ieee80211", ACTION=="add|change", KERNEL=="phy0", \ + RUN+="/sbin/iw phy phy0 interface add ap0 type __ap", \ + RUN+="MAC=`iw dev wlan0 info | grep addr | sed -e s/addr//` && /bin/ip link set ap0 address $MAC" diff --git a/roles/network/templates/hostapd/hostapd.conf.j2 b/roles/network/templates/hostapd/hostapd.conf.j2 index 9e38ace62..097a8d41a 100644 --- a/roles/network/templates/hostapd/hostapd.conf.j2 +++ b/roles/network/templates/hostapd/hostapd.conf.j2 @@ -1,7 +1,6 @@ # Basic configuration -interface={% if iiab_wireless_lan_iface is defined %}{{ iiab_wireless_lan_iface }}{% endif %} - +interface=ap0 ssid={{ host_ssid }} channel={{ host_channel }} diff --git a/roles/network/templates/hostapd/iiab-hostapd.conf.j2 b/roles/network/templates/hostapd/iiab-hostapd.conf.j2 index 3cfffc69e..097a8d41a 100644 --- a/roles/network/templates/hostapd/iiab-hostapd.conf.j2 +++ b/roles/network/templates/hostapd/iiab-hostapd.conf.j2 @@ -1,6 +1,6 @@ # Basic configuration -interface={{ discovered_wireless_iface }} +interface=ap0 ssid={{ host_ssid }} channel={{ host_channel }} From d03df344ff174f68219bcf2258d2ca3291c7ccdc Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 8 Sep 2018 22:55:18 +0000 Subject: [PATCH 027/127] alter dhcpcd.conf for ap0 --- roles/network/templates/network/dhcpcd.conf.j2 | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/roles/network/templates/network/dhcpcd.conf.j2 b/roles/network/templates/network/dhcpcd.conf.j2 index f1265b10c..ac139711a 100644 --- a/roles/network/templates/network/dhcpcd.conf.j2 +++ b/roles/network/templates/network/dhcpcd.conf.j2 @@ -42,16 +42,12 @@ slaac private # Always (try) to run DHCP client on RPi's Ethernet port, for in-field # "cablemodems" used by many non-technical operators, who want Zero-Hassle # Updates. This means AVOIDING "denyinterfaces eth0" below: -{% if is_raspbian and hostapd_enabled %} -denyinterfaces{% if discovered_wireless_iface != "none" %} {{ discovered_wireless_iface }}{% endif %} -{% elif is_raspbian %} -#denyinterfaces{% if discovered_wireless_iface != "none" %} {{ discovered_wireless_iface }}{% endif %} -{% else %} -denyinterfaces{% if iiab_wireless_lan_iface is defined %} {{ iiab_wireless_lan_iface }}{% endif %}{% if iiab_wired_lan_iface is defined %} {{ iiab_wired_lan_iface }}{% endif %} +{% if is_rpi and hostapd_enabled %} +denyinterfaces ap0 +{% endif %} +{% if iiab_wired_lan_iface is defined %} +denyinterfaces {{ iiab_wired_lan_iface }} {% endif %} - -# FYI this 'denyinterfaces' line (here in /etc/dhcpcd.conf) is commented out by -# /usr/bin/iiab-hotspot-off, and uncommented by /usr/bin/iiab-hotspot-on {% if dhcpcd_result == "enabled" and iiab_lan_iface != "none" %} interface {{ iiab_lan_iface }} From 6ba20a63e973afc2797ba63f03b0f55d70dbdc5b Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 8 Sep 2018 23:40:02 +0000 Subject: [PATCH 028/127] start hostapd before dhcpcd --- roles/network/templates/hostapd/hostapd.service.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 4094b812a..bf1d8bef8 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -1,7 +1,7 @@ [Unit] Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator -Before=network.target -Wants=network-pre.target +After=network-pre.target +Before=network.target dhcpcd.service [Service] Type=idle From c56b9e651077ad994e7679f82a45de4ad6b2b7ad Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 13 Sep 2018 17:14:44 +0000 Subject: [PATCH 029/127] use hostapd's service file to create ap0 --- roles/network/tasks/hostapd.yml | 8 -------- roles/network/templates/hostapd/hostapd.service.j2 | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index cea1f1bd4..386eafb92 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -21,14 +21,6 @@ mode: 0644 when: discovered_wireless_iface != "none" -- name: Use custom udev rule to create ap0 - template: - src: hostapd/70-persistent-net.rules - dest: /etc/udev/rules.d/70-persistent-net.rules - owner: root - group: root - mode: 0644 - - name: Use custom systemd unit file to start 'hostapd' service template: src: hostapd/hostapd.service.j2 diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index bf1d8bef8..8ccce4c7f 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -6,6 +6,7 @@ Before=network.target dhcpcd.service [Service] Type=idle PIDFile=/run/hostapd.pid +ExecStartPre=/sbin/iw phy phy0 interface add ap0 type __ap ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf [Install] From 71907893cb178bb5e5ba12e29e87b877b4afba08 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 30 Nov 2018 02:20:20 -0600 Subject: [PATCH 030/127] set ap0 mac_addr to be different from wlan0 --- roles/network/templates/hostapd/50-hostapd | 12 ++++++++++++ .../templates/hostapd/70-persistent-net.rules | 2 +- roles/network/templates/hostapd/hostapd.service.j2 | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 roles/network/templates/hostapd/50-hostapd diff --git a/roles/network/templates/hostapd/50-hostapd b/roles/network/templates/hostapd/50-hostapd new file mode 100644 index 000000000..b663599b3 --- /dev/null +++ b/roles/network/templates/hostapd/50-hostapd @@ -0,0 +1,12 @@ + +if [ "$interface" = "wlan0" ]; then + syslog info "50-hostapd-ap0" + sleep 2 + # wpa_supplicant wants MHz for frequency= while hostapd wants channel..... whatever + # FREQ=`iw wlan0 info|grep channel|cut -d' ' -f9` + FREQ=`iw wlan0 info|grep channel|cut -d' ' -f2` + sed -i -e "s/^frequency.*/channel=$FREQ /" /etc/hostapd/hostapd.conf + syslog info "50-hostapd restarting hostapd" + systemctl daemon-reload + systemctl restart hostapd +fi diff --git a/roles/network/templates/hostapd/70-persistent-net.rules b/roles/network/templates/hostapd/70-persistent-net.rules index 5e9cca3c3..7bb53337d 100644 --- a/roles/network/templates/hostapd/70-persistent-net.rules +++ b/roles/network/templates/hostapd/70-persistent-net.rules @@ -1,3 +1,3 @@ SUBSYSTEM=="ieee80211", ACTION=="add|change", KERNEL=="phy0", \ RUN+="/sbin/iw phy phy0 interface add ap0 type __ap", \ - RUN+="MAC=`iw dev wlan0 info | grep addr | sed -e s/addr//` && /bin/ip link set ap0 address $MAC" + RUN+="/sbin/ip link set ap0 address b8:27:99:12:34:56" diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 8ccce4c7f..26195358e 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -6,7 +6,8 @@ Before=network.target dhcpcd.service [Service] Type=idle PIDFile=/run/hostapd.pid -ExecStartPre=/sbin/iw phy phy0 interface add ap0 type __ap +ExecStartPre=/sbin/iw phy phy0 interface add ap0 type __ap 2>1 > /dev/null +ExecStartPre=/sbin/ip link set ap0 address b8:27:99:12:34:56 2>1 > /dev/null ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf [Install] From 188407614cef0f868f45d4d0fe4340ca78558c6c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 2 Dec 2018 23:15:22 -0600 Subject: [PATCH 031/127] dhcpcd hook for hostapd --- roles/network/tasks/hostapd.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 386eafb92..ae53d7807 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -48,6 +48,15 @@ mode: 0755 when: is_raspbian | bool +- name: Create dhcpcd hook for hostapd + template: + src: hostapd/50-hostapd + dest: /lib/dhcpcd/dhcpcd-hooks/50-hostapd + owner: root + group: root + mode: 0644 + when: is_rpi + - name: Disable the Access Point 'hostapd' service systemd: name: hostapd From 79a829dabe83c78bc77e635d958d05a4e1f278ca Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 2 Dec 2018 23:16:08 -0600 Subject: [PATCH 032/127] softcode apo_mac_addr --- roles/network/defaults/main.yml | 35 +++++++++++++++++++ .../templates/hostapd/70-persistent-net.rules | 2 +- .../templates/hostapd/hostapd.service.j2 | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index 7cdf5b37c..b46dc0930 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -97,6 +97,41 @@ wondershaper_upspeed: "1024" # Unused # network_config_dir: /etc/network/interfaces.d +# Wi-Fi +host_ssid: IIAB +hostapd_wait: 1 +host_wifi_mode: g +host_channel: 6 +host_wireless_n: False +ap0_mac_addr: b8:27:99:12:34:56 +# Below moved to /etc/iiab/local_vars.yml: (so implementer sets this) +#host_country_code: US +hostapd_secure: True +hostapd_password: "iiab2017" +driver_name: nl80211 +hostapd_enabled: True +# Above is forcibly set to False (in roles/network/tasks/main.yml) if IIAB is +# being WiFi-installed (run "iiab-hotspot-on" AFTER ./iiab-install completes +# and content is downloaded, to enable the internal WiFi Access Point / AP!) +reboot_to_AP: False +# For those installing IIAB over WiFi: "reboot_to_AP: True" overrides the above +# detection of WiFi-as-gateway, forcing "hostapd_enabled: True" regardless. + +network_config_dir: /etc/network/interfaces.d +#iiab_network_mode: "Gateway" +dns_jail_enabled: False +services_externally_visible: False + +# DNS / name resolution +dhcpd_install: True +dhcpd_enabled: False +#dhcp_service: ???? # Set in individual OS's /opt/iiab/iiab/vars/.yml for use in roles/network/tasks/dhcpd.yml +#dhcp_service2: "dhcpd disabled" # Moved to roles/network/tasks/computed_services.yml as community transitions from named/BIND to dnsmasq (PR #1202) +named_install: True +named_enabled: False +dnsmasq_enabled: True +dnsmasq_install: True + # Originally for @tim-moody's Nodogsplash approach to Captive Portal # Highly experimental as of June 2018: https://github.com/iiab/iiab/issues/608 # diff --git a/roles/network/templates/hostapd/70-persistent-net.rules b/roles/network/templates/hostapd/70-persistent-net.rules index 7bb53337d..3ced0ef8b 100644 --- a/roles/network/templates/hostapd/70-persistent-net.rules +++ b/roles/network/templates/hostapd/70-persistent-net.rules @@ -1,3 +1,3 @@ SUBSYSTEM=="ieee80211", ACTION=="add|change", KERNEL=="phy0", \ RUN+="/sbin/iw phy phy0 interface add ap0 type __ap", \ - RUN+="/sbin/ip link set ap0 address b8:27:99:12:34:56" + RUN+="/sbin/ip link set ap0 address {{ ap0_mac_addr }}" diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 26195358e..73500c0f6 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -7,7 +7,7 @@ Before=network.target dhcpcd.service Type=idle PIDFile=/run/hostapd.pid ExecStartPre=/sbin/iw phy phy0 interface add ap0 type __ap 2>1 > /dev/null -ExecStartPre=/sbin/ip link set ap0 address b8:27:99:12:34:56 2>1 > /dev/null +ExecStartPre=/sbin/ip link set ap0 address {{ ap0_mac_addr }} 2>1 > /dev/null ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf [Install] From 218872c637ed0a68625300ff3ce6204893055e42 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 31 Dec 2018 00:51:29 -0600 Subject: [PATCH 033/127] refine hostapd.service --- roles/network/templates/hostapd/hostapd.service.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 73500c0f6..5c92483c7 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -6,8 +6,8 @@ Before=network.target dhcpcd.service [Service] Type=idle PIDFile=/run/hostapd.pid -ExecStartPre=/sbin/iw phy phy0 interface add ap0 type __ap 2>1 > /dev/null -ExecStartPre=/sbin/ip link set ap0 address {{ ap0_mac_addr }} 2>1 > /dev/null +ExecStartPre=-/sbin/iw phy phy0 interface add ap0 type __ap +ExecStartPre=-/sbin/ip link set ap0 address {{ ap0_mac_addr }} ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf [Install] From 75133bd7115d21fa3dd9c8b93080fd410fad8ae1 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 8 Aug 2019 13:04:48 -0500 Subject: [PATCH 034/127] refine hostapd.service.j2 --- roles/network/templates/hostapd/hostapd.service.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 5c92483c7..f7e19b96a 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -1,7 +1,8 @@ [Unit] Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator -After=network-pre.target Before=network.target dhcpcd.service +After=network-pre.target +Wants=network-pre.target [Service] Type=idle From 9df4e169b64d8e36f415266c397f758d084a5848 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 12 Feb 2020 14:42:54 -0600 Subject: [PATCH 035/127] slimdown defaults --- roles/network/defaults/main.yml | 36 +-------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index b46dc0930..c052fcc46 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -38,6 +38,7 @@ hostapd_wait: 5 host_wireless_n: False driver_name: nl80211 +ap0_mac_addr: b8:27:99:12:34:56 # DNS / name resolution # dhcpd_install: False @@ -97,41 +98,6 @@ wondershaper_upspeed: "1024" # Unused # network_config_dir: /etc/network/interfaces.d -# Wi-Fi -host_ssid: IIAB -hostapd_wait: 1 -host_wifi_mode: g -host_channel: 6 -host_wireless_n: False -ap0_mac_addr: b8:27:99:12:34:56 -# Below moved to /etc/iiab/local_vars.yml: (so implementer sets this) -#host_country_code: US -hostapd_secure: True -hostapd_password: "iiab2017" -driver_name: nl80211 -hostapd_enabled: True -# Above is forcibly set to False (in roles/network/tasks/main.yml) if IIAB is -# being WiFi-installed (run "iiab-hotspot-on" AFTER ./iiab-install completes -# and content is downloaded, to enable the internal WiFi Access Point / AP!) -reboot_to_AP: False -# For those installing IIAB over WiFi: "reboot_to_AP: True" overrides the above -# detection of WiFi-as-gateway, forcing "hostapd_enabled: True" regardless. - -network_config_dir: /etc/network/interfaces.d -#iiab_network_mode: "Gateway" -dns_jail_enabled: False -services_externally_visible: False - -# DNS / name resolution -dhcpd_install: True -dhcpd_enabled: False -#dhcp_service: ???? # Set in individual OS's /opt/iiab/iiab/vars/.yml for use in roles/network/tasks/dhcpd.yml -#dhcp_service2: "dhcpd disabled" # Moved to roles/network/tasks/computed_services.yml as community transitions from named/BIND to dnsmasq (PR #1202) -named_install: True -named_enabled: False -dnsmasq_enabled: True -dnsmasq_install: True - # Originally for @tim-moody's Nodogsplash approach to Captive Portal # Highly experimental as of June 2018: https://github.com/iiab/iiab/issues/608 # From 3f749036e4b173c28b4b918a3c7cd8ac6f8efd28 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 26 Feb 2020 02:21:27 -0600 Subject: [PATCH 036/127] update hostapd.service --- roles/network/templates/hostapd/hostapd.service.j2 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index f7e19b96a..fbbdd37fc 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -1,8 +1,11 @@ [Unit] Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator -Before=network.target dhcpcd.service -After=network-pre.target Wants=network-pre.target +After=network-pre.target +{% if is_rpi %} +Before=dhcpcd.service +{% endif %} +Before=network.target [Service] Type=idle @@ -10,6 +13,8 @@ PIDFile=/run/hostapd.pid ExecStartPre=-/sbin/iw phy phy0 interface add ap0 type __ap ExecStartPre=-/sbin/ip link set ap0 address {{ ap0_mac_addr }} ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf +ExecStartPost=-/sbin/ip link set ap0 up +ExecStopPost=-/sbin/iw dev ap0 del [Install] WantedBy=multi-user.target From 0bcf3c8184f760ebe752af5e23bc8456c1f3d275 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 26 Feb 2020 02:22:06 -0600 Subject: [PATCH 037/127] update dhcpcd hook --- roles/network/templates/hostapd/50-hostapd | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/roles/network/templates/hostapd/50-hostapd b/roles/network/templates/hostapd/50-hostapd index b663599b3..47a769639 100644 --- a/roles/network/templates/hostapd/50-hostapd +++ b/roles/network/templates/hostapd/50-hostapd @@ -1,12 +1,20 @@ if [ "$interface" = "wlan0" ]; then - syslog info "50-hostapd-ap0" - sleep 2 - # wpa_supplicant wants MHz for frequency= while hostapd wants channel..... whatever - # FREQ=`iw wlan0 info|grep channel|cut -d' ' -f9` - FREQ=`iw wlan0 info|grep channel|cut -d' ' -f2` - sed -i -e "s/^frequency.*/channel=$FREQ /" /etc/hostapd/hostapd.conf - syslog info "50-hostapd restarting hostapd" - systemctl daemon-reload - systemctl restart hostapd + REASON="$reason" + if [ "$reason" = "CARRIER" ]; then + syslog info "50-iiab CARRIER change wlan0" + # wpa_supplicant wants MHz for frequency= while hostapd wants channel..... whatever + # FREQ=`iw wlan0 info|grep channel|cut -d' ' -f9` + FREQ=`iw wlan0 info|grep channel|cut -d' ' -f2` + syslog info "40-iiab set channel $FREQ" + sed -i -e "s/^channel.*/channel=$FREQ /" /etc/hostapd/hostapd.conf + # will need a reboot for hostapd if the channel changed + fi + # spams the logging + #syslog info "50-iiab set ap0 spam $REASON" + if [ -e /sys/class/net/ap0 ] && ! [ "$reason" = "ROUTERADVERT" ]; then + syslog info "50-iiab set ap0 up $REASON" + # keeps ap0 up so hostapd works + ip link set ap0 up + fi fi From 37da7407d473170bee2e68a3163d65d809e0b5f7 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 26 Feb 2020 02:23:27 -0600 Subject: [PATCH 038/127] update iiab-hotspot support files --- roles/2-common/templates/iiab-startup.sh | 4 ++-- .../network/templates/network/iiab-hotspot-off | 12 ++++++------ .../network/templates/network/iiab-hotspot-on | 18 ++++++++---------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/roles/2-common/templates/iiab-startup.sh b/roles/2-common/templates/iiab-startup.sh index b563b908d..e84eab8f0 100644 --- a/roles/2-common/templates/iiab-startup.sh +++ b/roles/2-common/templates/iiab-startup.sh @@ -31,8 +31,8 @@ if [[ $(grep -i raspbian /etc/*release) && #) #]]; then - ip link set dev wlan0 promisc on - echo "wlan0 promiscuous mode ON, internal AP OFF: github.com/iiab/iiab/issues/638" +# ip link set dev wlan0 promisc on + echo "wlan0 promiscuous mode ON, internal AP OFF: github.com/iiab/iiab/issues/638 DISABLED" fi exit 0 diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index 2341c6f5b..5541a260e 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -1,19 +1,19 @@ #!/bin/bash -sed -i -e "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf +#sed -i -e "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf systemctl disable hostapd systemctl stop hostapd #systemctl disable dnsmasq #systemctl stop dnsmasq -systemctl daemon-reload -systemctl restart dhcpcd +#systemctl daemon-reload +#systemctl restart dhcpcd #systemctl restart networking 6/15/2019 TFM removed # Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" # Set wlan0 to promiscuous when AP's OFF (for possible WiFi gateway) # SEE ALSO iiab-hotspot-on + /usr/libexec/iiab-startup.sh # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -if grep -qi raspbian /etc/*release; then - ip link set dev wlan0 promisc on -fi +#if grep -qi raspbian /etc/*release; then +# ip link set dev wlan0 promisc on +#fi sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index 9b57c579a..c88130d4c 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -1,13 +1,11 @@ #!/bin/bash -cp -f /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf -sed -i -e "s/^#denyinterfaces/denyinterfaces/" /etc/dhcpcd.conf +#cp -f /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf +#sed -i -e "s/^#denyinterfaces/denyinterfaces/" /etc/dhcpcd.conf # shut down wlan0 in case connected to network -ip link set wlan0 down +#ip link set wlan0 down systemctl enable hostapd -#systemctl enable dnsmasq -systemctl daemon-reload -systemctl restart dhcpcd -#systemctl restart networking 6/15/2019 TFM removed +#systemctl daemon-reload +#systemctl restart dhcpcd systemctl start hostapd systemctl start dnsmasq @@ -15,9 +13,9 @@ systemctl start dnsmasq # Disable "promiscuous" on wlan0 when AP (i.e. no WiFi gateway) # SEE ALSO iiab-hotspot-off + /usr/libexec/iiab-startup.sh # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -if grep -qi raspbian /etc/*release; then - ip link set dev wlan0 promisc off -fi +#if grep -qi raspbian /etc/*release; then +# ip link set dev wlan0 promisc off +#fi sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} From 7b1f7016e5f65d9fcdbd7058af1875e8205f73d4 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 10 Mar 2020 00:38:58 -0500 Subject: [PATCH 039/127] remove is_rpi -> is_raspbian, more notes --- roles/network/templates/hostapd/hostapd.service.j2 | 2 +- roles/network/templates/network/dhcpcd.conf.j2 | 11 ++++++++--- roles/network/templates/network/rpi.j2 | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index fbbdd37fc..5c743898a 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -2,7 +2,7 @@ Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator Wants=network-pre.target After=network-pre.target -{% if is_rpi %} +{% if is_raspbian %} Before=dhcpcd.service {% endif %} Before=network.target diff --git a/roles/network/templates/network/dhcpcd.conf.j2 b/roles/network/templates/network/dhcpcd.conf.j2 index ac139711a..88c88201a 100644 --- a/roles/network/templates/network/dhcpcd.conf.j2 +++ b/roles/network/templates/network/dhcpcd.conf.j2 @@ -38,13 +38,18 @@ require dhcp_server_identifier slaac private # IIAB +denyinterfaces ap0 +# Setting iiab_wired_lan_iface would install the device as a slave under +# br0 so we need to turn off the dhcp client in that network layout. +# Auto creation of the wired slave is suppressed in discovered_network.yml +# -> Set iiab_wired_lan_iface if present is conditional on is_raspbian +# Slave creation can be forced by populating local_vars.yml with +# 'iiab_wired_lan_iface: eth0' which populates /etc/network/interfaces.d/iiab +# with 'bridge_ports eth0' in place of 'bridge_ports none' # Always (try) to run DHCP client on RPi's Ethernet port, for in-field # "cablemodems" used by many non-technical operators, who want Zero-Hassle # Updates. This means AVOIDING "denyinterfaces eth0" below: -{% if is_rpi and hostapd_enabled %} -denyinterfaces ap0 -{% endif %} {% if iiab_wired_lan_iface is defined %} denyinterfaces {{ iiab_wired_lan_iface }} {% endif %} diff --git a/roles/network/templates/network/rpi.j2 b/roles/network/templates/network/rpi.j2 index 9e3c1b69b..a2860fb95 100644 --- a/roles/network/templates/network/rpi.j2 +++ b/roles/network/templates/network/rpi.j2 @@ -3,6 +3,8 @@ # gui_desired_network_role is {{ gui_desired_network_role }} {% endif %} {% if iiab_network_mode != "Appliance" %} +# auto wired slave creation is suppressed in detected_network.yml +# 'none' would become the name of the wired slave device. ################# LANCONTROLLER ################### auto br0 iface br0 inet manual From 23124b3a19de0ec217898518d4459775e8d23731 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 10 Mar 2020 00:51:38 -0500 Subject: [PATCH 040/127] iiab-hotspot-on|off for all, is_rpi, style --- roles/network/tasks/hostapd.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index ae53d7807..9eba9d159 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -1,7 +1,7 @@ - name: Turn off hostapd when no wifi interface present or in "Appliance Mode" set_fact: hostapd_enabled: False - when: not iiab_wireless_lan_iface is defined or iiab_network_mode == "Appliance" + when: iiab_wireless_lan_iface is undefined or iiab_network_mode == "Appliance" - name: Create /etc/hostapd/hostapd.conf from template template: @@ -37,7 +37,6 @@ owner: root group: root mode: 0755 - when: is_raspbian | bool - name: Create /usr/bin/iiab-hotspot-off from template template: @@ -46,7 +45,6 @@ owner: root group: root mode: 0755 - when: is_raspbian | bool - name: Create dhcpcd hook for hostapd template: @@ -55,7 +53,7 @@ owner: root group: root mode: 0644 - when: is_rpi + when: is_raspbian - name: Disable the Access Point 'hostapd' service systemd: From bccb15552306131a73c850debf44144ffa4e024d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 10 Mar 2020 11:42:21 -0500 Subject: [PATCH 041/127] better discription of when rpi_debian.yml task is used --- roles/network/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index b2729314b..e73b12eea 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -89,7 +89,7 @@ when: is_debuntu and systemd_networkd_active #and not installing -- name: RPi's have dhcpcd in use +- name: Raspbian uses dhcpcd only with no N-M or SYS-NETD active include_tasks: rpi_debian.yml when: is_raspbian #and not installing From aab9c1ba874f38234a3202ca9705991b1ef1bd9b Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 11 Mar 2020 00:39:45 -0500 Subject: [PATCH 042/127] setup auto restart of hostapd - based on current stock service file --- roles/network/templates/hostapd/hostapd.service.j2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 5c743898a..abc718d0c 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -8,11 +8,13 @@ Before=dhcpcd.service Before=network.target [Service] -Type=idle +Type=forking +Restart=on-failure +RestartSec=2 PIDFile=/run/hostapd.pid ExecStartPre=-/sbin/iw phy phy0 interface add ap0 type __ap ExecStartPre=-/sbin/ip link set ap0 address {{ ap0_mac_addr }} -ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf +ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf ExecStartPost=-/sbin/ip link set ap0 up ExecStopPost=-/sbin/iw dev ap0 del From cc5674a922780553ba73befa07c6806db873a5a5 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 11 Mar 2020 14:59:21 -0500 Subject: [PATCH 043/127] iiab-network remove stale config_vars creation --- iiab-network | 6 ------ 1 file changed, 6 deletions(-) diff --git a/iiab-network b/iiab-network index 0bef05005..ee9d057bc 100755 --- a/iiab-network +++ b/iiab-network @@ -11,12 +11,6 @@ if [ ! -f iiab-network.yml ]; then exit 1 fi -if [ ! -f /etc/iiab/config_vars.yml ]; then - echo "Creating stub /etc/iiab/config_vars.yml" - mkdir -p /etc/iiab - echo "{}" > /etc/iiab/config_vars.yml -fi - OS="unknown" # will be overridden below, if /etc/iiab/iiab.env is legit if [ -f /etc/iiab/iiab.env ]; then echo "Reading /etc/iiab/iiab.env" From ad5d4c4f73882d038cc880b9293ffc5437374429 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 11 Mar 2020 15:10:37 -0500 Subject: [PATCH 044/127] add stage lockout from iiab-configure --- iiab-network | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/iiab-network b/iiab-network index ee9d057bc..caded9a6a 100755 --- a/iiab-network +++ b/iiab-network @@ -15,6 +15,29 @@ OS="unknown" # will be overridden below, if /etc/iiab/iiab.env is legit if [ -f /etc/iiab/iiab.env ]; then echo "Reading /etc/iiab/iiab.env" source /etc/iiab/iiab.env + STAGE=0 + if grep -q STAGE= /etc/iiab/iiab.env ; then + echo -e "\nExtracted STAGE=$STAGE (counter) from /etc/iiab/iiab.env" + if ! [ "$STAGE" -eq "$STAGE" ] 2> /dev/null; then + echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"" is non-integer" + exit 1 + elif [ "$STAGE" -lt 0 ] || [ "$STAGE" -gt 9 ]; then + echo -e "\nEXITING: STAGE (counter) value == ""$STAGE"" is out-of-range" + exit 1 + elif [ "$STAGE" -lt 3 ]; then + echo -e "\nEXITING: STAGE (counter) value == ""$STAGE" + echo -e "\nIIAB Stage 3 not complete." + echo -e "\nPlease run: ./iiab-install" + exit 1 + else + echo -e "\nEXITING: STAGE (counter) not found" + echo -e "\nIIAB not installed." + echo -e "\nPlease run: ./iiab-install" + exit 1 + fi +else + echo -e "\nEXITING: /etc/iiab/iiab.env not found" + exit 1 fi echo "Ansible will now run iiab-network.yml -- log file is iiab-network.log" From eebd14581e57a1cee59f5a173e3200a7073325c2 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Tue, 17 Mar 2020 03:43:47 +0000 Subject: [PATCH 045/127] typos --- iiab-network | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iiab-network b/iiab-network index caded9a6a..d73978e63 100755 --- a/iiab-network +++ b/iiab-network @@ -14,8 +14,8 @@ fi OS="unknown" # will be overridden below, if /etc/iiab/iiab.env is legit if [ -f /etc/iiab/iiab.env ]; then echo "Reading /etc/iiab/iiab.env" - source /etc/iiab/iiab.env STAGE=0 + source /etc/iiab/iiab.env if grep -q STAGE= /etc/iiab/iiab.env ; then echo -e "\nExtracted STAGE=$STAGE (counter) from /etc/iiab/iiab.env" if ! [ "$STAGE" -eq "$STAGE" ] 2> /dev/null; then @@ -29,6 +29,7 @@ if [ -f /etc/iiab/iiab.env ]; then echo -e "\nIIAB Stage 3 not complete." echo -e "\nPlease run: ./iiab-install" exit 1 + fi else echo -e "\nEXITING: STAGE (counter) not found" echo -e "\nIIAB not installed." From bf5dc8cf1550cdc86aaec4b0ebe81e012f0bc7fa Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 24 Mar 2020 21:41:20 -0500 Subject: [PATCH 046/127] generate random mac address for ap0 --- roles/network/tasks/hostapd.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 9eba9d159..8ac825472 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -21,6 +21,14 @@ mode: 0644 when: discovered_wireless_iface != "none" +- name: Generate new random mac address for ap0 + shell: tr -dc A-F0-9 < /dev/urandom | head -c 10 | sed -r 's/(..)/\1:/g;s/:$//;s/^/02:/' + register: ap0_mac + +- name: Setting ap0 mac address for use in hostapd service file + set_fact: + ap0_mac_addr: "{{ ap0_mac.stdout }}" + - name: Use custom systemd unit file to start 'hostapd' service template: src: hostapd/hostapd.service.j2 From 39cf3b2947c7d1c48ca5e0165a870a76a0b87fb9 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 3 Apr 2020 03:53:46 -0500 Subject: [PATCH 047/127] exclude ap0 from count_wifi_interfaces --- roles/network/tasks/detected_network.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml index 25f71d48d..e97cfb74b 100644 --- a/roles/network/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -81,7 +81,7 @@ #item|trim != discovered_wan_iface - name: Count WiFi ifaces - shell: "ls -la /sys/class/net/*/phy80211 | awk -F / '{print $5}' | wc -l" + shell: "ls -la /sys/class/net/*/phy80211 | awk -F / '{print $5}' | grep -v -e ap0 | wc -l" register: count_wifi_interfaces # facts are apparently all stored as text, so do text comparisons from here on From 668b8baf10b0b49f4681936d67929581ff0320a7 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 3 Apr 2020 05:24:22 -0500 Subject: [PATCH 048/127] keep wlan0 and ap0 on the same channel on RPi hardware --- roles/network/tasks/hostapd.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 8ac825472..fe535a41b 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -3,6 +3,16 @@ hostapd_enabled: False when: iiab_wireless_lan_iface is undefined or iiab_network_mode == "Appliance" +- name: Detect current Wifi channel + shell: iw {{ discovered_wireless_iface }} info | grep channel | cut -d' ' -f2 + register: current_host_channel + when: discovered_wireless_iface != "none" + +- name: Setting WiFi channel to {{ current_host_channel.stdout }} on RPi hardware + set_fact: + host_channel: "{{ current_host_channel.stdout }}" + when: current_host_channel.stdout != "" and discovered_wireless_iface != "none" and rpi_model != "none" + - name: Create /etc/hostapd/hostapd.conf from template template: src: hostapd/hostapd.conf.j2 From 3e02d5721025a73f2eee98cb9261c4cf350d31e9 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 3 Apr 2020 09:23:33 -0500 Subject: [PATCH 049/127] restart - use ap0 for bridge slave test --- roles/network/tasks/restart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index 6c6720d3c..b4c7ccce2 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -60,7 +60,7 @@ command: /usr/bin/iiab-gen-iptables - name: Checking if WiFi slave is active - shell: brctl show br0 | grep {{ iiab_wireless_lan_iface }} | wc -l + shell: brctl show br0 | grep ap0 | wc -l when: hostapd_enabled and iiab_wireless_lan_iface is defined and iiab_lan_iface == "br0" register: wifi_slave From 36212548f43c7f2d67d1e6a3611f6821413e1206 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 01:07:26 -0500 Subject: [PATCH 050/127] hostapd.service - Before wpa_supplicant --- roles/network/templates/hostapd/hostapd.service.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index abc718d0c..11318a2d7 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -5,6 +5,8 @@ After=network-pre.target {% if is_raspbian %} Before=dhcpcd.service {% endif %} +Before=wpa_supplicant.service +Before=wpa_supplicant@{{ discovered_wireless_iface }}.service Before=network.target [Service] From ac935f4c932be4ad0425081b06cbf206fc9abc94 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 3 Apr 2020 03:50:16 -0500 Subject: [PATCH 051/127] netplan don't delete user's wifi config --- roles/network/tasks/netplan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index 69959b77f..b865e4834 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -12,9 +12,9 @@ file: state: absent path: /etc/netplan/{{ item }} + when: netplan.stdout.find("yaml") != -1 and (item != "02-iiab-config.yaml") with_items: - "{{ netplan.stdout_lines }}" - when: netplan.stdout.find("yaml") != -1 - name: Cheap way to do systemd unmask file: From d0a27ce0df6ae49fdb98c3ec2108fc4a2ce5bd7c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 3 Apr 2020 01:03:46 -0500 Subject: [PATCH 052/127] systemd-networkd version of dhcpcd's 50-hostapd hook --- roles/network/tasks/hostapd.yml | 28 +++++++++++++++++++ roles/network/templates/hostapd/00-iiab-debug | 2 ++ roles/network/templates/hostapd/netd-disp | 6 ++++ 3 files changed, 36 insertions(+) create mode 100644 roles/network/templates/hostapd/00-iiab-debug create mode 100644 roles/network/templates/hostapd/netd-disp diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index fe535a41b..691d9a76b 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -73,6 +73,34 @@ mode: 0644 when: is_raspbian +- name: Create networkd-dispatcher diagnosic 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 on RPi hardware + 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' } + when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" + - name: Disable the Access Point 'hostapd' service systemd: name: hostapd diff --git a/roles/network/templates/hostapd/00-iiab-debug b/roles/network/templates/hostapd/00-iiab-debug new file mode 100644 index 000000000..d1d028d52 --- /dev/null +++ b/roles/network/templates/hostapd/00-iiab-debug @@ -0,0 +1,2 @@ +#!/bin/bash +echo "NET-DISP-$AdministrativeState $IFACE $STATE" diff --git a/roles/network/templates/hostapd/netd-disp b/roles/network/templates/hostapd/netd-disp new file mode 100644 index 000000000..f950ac4a1 --- /dev/null +++ b/roles/network/templates/hostapd/netd-disp @@ -0,0 +1,6 @@ +#!/bin/bash +if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then + echo "NET-DISP-WiFi $IFACE $STATE" + /usr/sbin/ip link set up ap0 +fi + From ccb1bf348a141302ffdd1ad38848623a9dc0e2fd Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 01:35:02 -0500 Subject: [PATCH 053/127] adjust networkd-dispatcher dnsmasq script --- roles/network/templates/hostapd/netd-disp | 1 + roles/network/templates/network/dnsmasq.sh.j2 | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/network/templates/hostapd/netd-disp b/roles/network/templates/hostapd/netd-disp index f950ac4a1..5b13d4167 100644 --- a/roles/network/templates/hostapd/netd-disp +++ b/roles/network/templates/hostapd/netd-disp @@ -1,4 +1,5 @@ #!/bin/bash + if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then echo "NET-DISP-WiFi $IFACE $STATE" /usr/sbin/ip link set up ap0 diff --git a/roles/network/templates/network/dnsmasq.sh.j2 b/roles/network/templates/network/dnsmasq.sh.j2 index 31700113e..1969f8da5 100755 --- a/roles/network/templates/network/dnsmasq.sh.j2 +++ b/roles/network/templates/network/dnsmasq.sh.j2 @@ -1,5 +1,7 @@ #!/bin/bash if [ "$IFACE" == "{{ iiab_lan_iface }}" ]; then - /bin/systemctl restart dnsmasq.service + echo "Restarting dnsmasq in 5 seconds" + /bin/sleep 5 && /bin/systemctl --no-block restart dnsmasq.service + echo "Restarting dnsmasq" fi From a31145443611fc9f8878e4edbfe818c4e0408db1 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 01:37:05 -0500 Subject: [PATCH 054/127] network/main remove installing, move hostapd.yml, notes, cleanup --- roles/network/tasks/{ => fedora}/NM.yml | 0 .../tasks/fedora/create_ifcfg.yml.deprecated | 17 +++++++++++ .../tasks/{ => fedora}/detected_redhat.yml | 0 .../network/tasks/{ => fedora}/edit_ifcfg.yml | 0 .../network/tasks/{ => fedora}/enable_wan.yml | 0 .../network/tasks/fedora/hosts.yml.deprecated | 28 +++++++++++++++++++ .../network/tasks/{ => fedora}/ifcfg_mods.yml | 0 roles/network/tasks/{ => fedora}/redetect.yml | 0 roles/network/tasks/{ => fedora}/static.yml | 0 roles/network/tasks/main.yml | 15 ++-------- 10 files changed, 48 insertions(+), 12 deletions(-) rename roles/network/tasks/{ => fedora}/NM.yml (100%) create mode 100644 roles/network/tasks/fedora/create_ifcfg.yml.deprecated rename roles/network/tasks/{ => fedora}/detected_redhat.yml (100%) rename roles/network/tasks/{ => fedora}/edit_ifcfg.yml (100%) rename roles/network/tasks/{ => fedora}/enable_wan.yml (100%) create mode 100644 roles/network/tasks/fedora/hosts.yml.deprecated rename roles/network/tasks/{ => fedora}/ifcfg_mods.yml (100%) rename roles/network/tasks/{ => fedora}/redetect.yml (100%) rename roles/network/tasks/{ => fedora}/static.yml (100%) diff --git a/roles/network/tasks/NM.yml b/roles/network/tasks/fedora/NM.yml similarity index 100% rename from roles/network/tasks/NM.yml rename to roles/network/tasks/fedora/NM.yml diff --git a/roles/network/tasks/fedora/create_ifcfg.yml.deprecated b/roles/network/tasks/fedora/create_ifcfg.yml.deprecated new file mode 100644 index 000000000..7c982dbd2 --- /dev/null +++ b/roles/network/tasks/fedora/create_ifcfg.yml.deprecated @@ -0,0 +1,17 @@ +- name: Stop 'Wired WAN connection' + shell: nmcli dev disconnect {{ discovered_wan_iface }} + ignore_errors: True + changed_when: False + when: discovered_wan_iface != "none" and not has_WAN and has_ifcfg_gw == "none" + +# set user_wan_iface: for static +# use wan_* for static info +- name: Supply ifcfg-WAN file + template: src=network/ifcfg-WAN.j2 + dest=/etc/sysconfig/network-scripts/ifcfg-WAN + when: iiab_wan_iface != "none" and not has_WAN and has_ifcfg_gw == "none" + +- name: Now setting ifcfg-WAN True after creating file + set_fact: + has_WAN: True + when: iiab_wan_iface != "none" and has_ifcfg_gw == "none" diff --git a/roles/network/tasks/detected_redhat.yml b/roles/network/tasks/fedora/detected_redhat.yml similarity index 100% rename from roles/network/tasks/detected_redhat.yml rename to roles/network/tasks/fedora/detected_redhat.yml diff --git a/roles/network/tasks/edit_ifcfg.yml b/roles/network/tasks/fedora/edit_ifcfg.yml similarity index 100% rename from roles/network/tasks/edit_ifcfg.yml rename to roles/network/tasks/fedora/edit_ifcfg.yml diff --git a/roles/network/tasks/enable_wan.yml b/roles/network/tasks/fedora/enable_wan.yml similarity index 100% rename from roles/network/tasks/enable_wan.yml rename to roles/network/tasks/fedora/enable_wan.yml diff --git a/roles/network/tasks/fedora/hosts.yml.deprecated b/roles/network/tasks/fedora/hosts.yml.deprecated new file mode 100644 index 000000000..ce4a7467f --- /dev/null +++ b/roles/network/tasks/fedora/hosts.yml.deprecated @@ -0,0 +1,28 @@ +# this (hosts.yml) WAS invoked by roles/network/tasks/main.yml up until 2019-12-10 + +#TODO: Use vars instead of hardcoded values +- name: Remove FQDN with 172.18.96.1 in /etc/hosts without LAN (if iiab_lan_iface == "none" and not installing) + lineinfile: + path: /etc/hosts + regexp: '^172\.18\.96\.1' + state: absent + when: iiab_lan_iface == "none" and not installing + +- name: Configure FQDN with 172.18.96.1 in /etc/hosts with LAN (if iiab_lan_iface != "none" and not installing) + lineinfile: + path: /etc/hosts + regexp: '^172\.18\.96\.1' + line: '172.18.96.1 {{ iiab_hostname }}.{{ iiab_domain }} {{ iiab_hostname }} box box.lan' + state: present + when: not (iiab_lan_iface == "none") and not installing + +# roles/0-init/tasks/hostname.yml ALSO does this: +- name: 'Put FQDN & hostnames in /etc/hosts: "127.0.0.1 {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan" (if iiab_lan_iface == "none" and not installing, appliance mode?)' + lineinfile: + path: /etc/hosts + regexp: '^127\.0\.0\.1' + line: '127.0.0.1 {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan' + owner: root + group: root + mode: 0644 + when: iiab_lan_iface == "none" and not installing diff --git a/roles/network/tasks/ifcfg_mods.yml b/roles/network/tasks/fedora/ifcfg_mods.yml similarity index 100% rename from roles/network/tasks/ifcfg_mods.yml rename to roles/network/tasks/fedora/ifcfg_mods.yml diff --git a/roles/network/tasks/redetect.yml b/roles/network/tasks/fedora/redetect.yml similarity index 100% rename from roles/network/tasks/redetect.yml rename to roles/network/tasks/fedora/redetect.yml diff --git a/roles/network/tasks/static.yml b/roles/network/tasks/fedora/static.yml similarity index 100% rename from roles/network/tasks/static.yml rename to roles/network/tasks/fedora/static.yml diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index e73b12eea..486532cae 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -1,12 +1,12 @@ - include_tasks: detected_network.yml - when: not installing # REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml - name: IF WIFI IS PRIMARY GATEWAY, PLEASE RUN 'iiab-hotspot-on' MANUALLY set_fact: hostapd_enabled: False # used in (1) hostapd.yml, (2) rpi_debian.yml + # (3) its dhcpcd.conf.j2, (4) restart.yml no_net_restart: True # used below in (1) sysd-netd-debian.yml, - # (2) debian.yml, (3) rpi_debian.yml + # (2) debian.yml, (3) rpi_debian.yml, + # (4) NM-debian.yml when: discovered_wireless_iface == iiab_wan_iface and not reboot_to_AP # EITHER WAY: hostapd_enabled's state is RECORDED into {{ iiab_env_file }} # in hostapd.yml for later use by... @@ -25,9 +25,6 @@ # when: is_raspbian and discovered_wireless_iface is defined and discovered_wireless_iface == iiab_wan_iface and reboot_to_AP - include_tasks: computed_network.yml - when: not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml - -- include_tasks: hostapd.yml #- name: RPi - don't reboot to AP post install - installed via wifi - don't blow away current network # set_fact: @@ -35,13 +32,6 @@ # hostapd_enabled: False # when: is_raspbian and discovered_wireless_iface is defined and discovered_wired_iface != iiab_wan_iface -##### Start static ip address info for first run ##### -#- include_tasks: static.yml -# when: 'iiab_wan_iface != "none" and wan_ip != "dhcp"' -##### End static ip address info - -#- include_tasks: hosts.yml - - name: Configure wondershaper include_tasks: wondershaper.yml when: wondershaper_install or wondershaper_installed is defined @@ -63,6 +53,7 @@ - include_tasks: avahi.yml - include_tasks: computed_services.yml - include_tasks: enable_services.yml +- include_tasks: hostapd.yml #### End services From 1693e502bad7c933b8887918524c8030340fe74e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 03:15:14 -0500 Subject: [PATCH 055/127] Rework reserved_wifi -> reserved_device --- roles/network/defaults/main.yml | 2 +- roles/network/tasks/detected_network.yml | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index c052fcc46..87296ede1 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -66,7 +66,7 @@ wan_cidr: # Set defaults for discovery process as strings wifi1: "not found-1" wifi2: "not found-2" -ap_device: "none" +exclude_device: "none" device_gw: "none" device_gw2: "" diff --git a/roles/network/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml index e97cfb74b..b047488a9 100644 --- a/roles/network/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -15,9 +15,9 @@ device_gw: "{{ discovered_wan_iface }}" when: ansible_default_ipv4.gateway is defined -- name: Red Hat network detection (redhat) - include_tasks: detected_redhat.yml - when: is_redhat | bool +#- name: Red Hat network detection (redhat) +# include_tasks: detected_redhat.yml +# when: is_redhat | bool - name: Setting dhcpcd_test results set_fact: @@ -97,13 +97,14 @@ ap_device: "eth0" when: iiab_wan_iface != "eth0" and discovered_wireless_iface != "none" and xo_model == "XO-1.5" -- name: Exclude reserved WiFi adapter if defined - takes adapter name +- name: Exclude reserved Network Adapter if defined - takes adapter name set_fact: - ap_device: "{{ reserved_wifi }}" - when: reserved_wifi is defined and discovered_wireless_iface != iiab_wan_iface and num_wifi_interfaces >= "2" + exclude_device: "{{ reserved_device }}" +# when: reserved_device is defined and discovered_wireless_iface != iiab_wan_iface and num_wifi_interfaces >= "2" + when: reserved_device is defined - name: Count LAN ifaces - shell: ls /sys/class/net | grep -v -e ap0 -e wwlan -e ppp -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth -e {{ device_gw }} -e {{ ap_device }} | wc -l + shell: ls /sys/class/net | grep -v -e ap0 -e wwlan -e ppp -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth -e {{ device_gw }} -e {{ exclude_device }} | wc -l register: num_lan_interfaces_result - name: Calculate number of LAN interfaces including WiFi @@ -112,7 +113,7 @@ # LAN - pick non WAN's - name: Create list of LAN (non WAN) ifaces - shell: ls /sys/class/net | grep -v -e ap0 -e wwlan -e ppp -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth -e {{ device_gw }} -e {{ ap_device }} + shell: ls /sys/class/net | grep -v -e ap0 -e wwlan -e ppp -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth -e {{ device_gw }} -e {{ exclude_device }} when: num_lan_interfaces != "0" register: lan_list_result @@ -143,10 +144,6 @@ iiab_wired_lan_iface: "{{ discovered_wired_iface }}" when: discovered_wired_iface is defined and discovered_wired_iface != "none" and discovered_wired_iface != iiab_wan_iface and not is_raspbian -#unused -#- name: Get a list of ifcfg files to delete -# moved to detected_redhat - # use value only if present - name: 2 or more devices on the LAN - use bridging set_fact: From 3d5428b0a5c89ca4088ee7d3e3cd5fd65eb878c0 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 05:09:03 -0500 Subject: [PATCH 056/127] sysd-netd-debian - multi wired slaves --- roles/network/tasks/sysd-netd-debian.yml | 9 ++++++--- roles/network/templates/network/systemd-br0-slave.j2 | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index 7bc70071b..3af9ed8a4 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -11,11 +11,14 @@ src: network/systemd-br0-network.j2 when: iiab_lan_iface == "br0" -- name: Copy the bridge script - Assigns br0 wired slaves +# can be more than one wired interface +- name: Wired enslaving - Assigns lan_list_results to br0 as wired slaves if present template: - dest: /etc/systemd/network/IIAB-Slave.network src: network/systemd-br0-slave.j2 - when: iiab_wired_lan_iface is defined and iiab_lan_iface == "br0" + dest: /etc/systemd/network/IIAB-Slave-{{ item|trim }}.network + with_items: + - "{{ lan_list_result.stdout_lines }}" + when: iiab_wired_lan_iface is defined and num_lan_interfaces >= 2 - name: Remove static WAN template file: diff --git a/roles/network/templates/network/systemd-br0-slave.j2 b/roles/network/templates/network/systemd-br0-slave.j2 index 8a31fef2e..15fb5b16e 100644 --- a/roles/network/templates/network/systemd-br0-slave.j2 +++ b/roles/network/templates/network/systemd-br0-slave.j2 @@ -1,5 +1,9 @@ -# /etc/systemd/network/IIAB-Slave.network +# /etc/systemd/network/IIAB-Slave-{{ iiab_wired_lan_iface }}.network [Match] Name={{ iiab_wired_lan_iface }} + +[Link] +RequiredForOnline=no + [Network] Bridge=br0 From ef7ad608006de68c095c253b20959af2a3167588 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 05:52:35 -0500 Subject: [PATCH 057/127] netplan - need to start netplan-wpa@ after hostapd --- roles/network/tasks/detected_network.yml | 8 +++++--- roles/network/tasks/netplan.yml | 4 ---- roles/network/templates/hostapd/hostapd.service.j2 | 3 +++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/roles/network/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml index b047488a9..95cdbeef3 100644 --- a/roles/network/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -15,9 +15,11 @@ device_gw: "{{ discovered_wan_iface }}" when: ansible_default_ipv4.gateway is defined -#- name: Red Hat network detection (redhat) -# include_tasks: detected_redhat.yml -# when: is_redhat | bool +- name: Figure out netplan file name + shell: ls /etc/netplan + register: netplan + ignore_errors: True # pre 17.10 doesn't use netplan + when: is_ubuntu - name: Setting dhcpcd_test results set_fact: diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index b865e4834..98b8e4656 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -1,7 +1,3 @@ -- name: Figure out netplan file name - shell: ls /etc/netplan - register: netplan - - name: Disable cloud-init the easy way shell: touch /etc/cloud/cloud-init.disabled when: ("item" == "50-cloud-init.yaml") diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 11318a2d7..05c0846ba 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -7,6 +7,9 @@ Before=dhcpcd.service {% endif %} Before=wpa_supplicant.service Before=wpa_supplicant@{{ discovered_wireless_iface }}.service +{% if netplan.stdout.find("yaml") != -1 %} +Before=netplan-wpa@{{ discovered_wireless_iface }} +{% endif %} Before=network.target [Service] From 3c1bcc01ef91bb3bb5708a387dd5edc9ae157e1a Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 06:07:05 -0500 Subject: [PATCH 058/127] lets try netplan apply to restart the network --- roles/network/tasks/restart.yml | 4 ++++ roles/network/tasks/sysd-netd-debian.yml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index b4c7ccce2..cf4d9ee4e 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -53,6 +53,10 @@ creates: /etc/sysconfig/olpc-scripts/setup.d/installed/gateway when: iiab_network_mode == "Gateway" +- name: Reload netplan when Wifi is present on Ubuntu 18+ + shell: netplan apply + when: not no_net_restart and is_ubuntu and netplan.stdout.find("yaml") != -1 + - name: Waiting {{ hostapd_wait }} seconds for network to stabilize (dnsmasq will fail if br0 isn't in a 'up' state!) shell: sleep {{ hostapd_wait }} diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index 3af9ed8a4..9a478ea4a 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -55,4 +55,4 @@ name: systemd-networkd enabled: yes state: restarted - when: not nobridge is defined and not no_net_restart + when: not no_net_restart and netplan.stdout.find("yaml") == -1 From 3b0be9d865fa24e5a916566eb73b5d748a9b0b04 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 13:06:41 -0500 Subject: [PATCH 059/127] touchup hostapd.service.j2 for Raspbian --- roles/network/templates/hostapd/hostapd.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 05c0846ba..047ef4b4f 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -7,7 +7,7 @@ Before=dhcpcd.service {% endif %} Before=wpa_supplicant.service Before=wpa_supplicant@{{ discovered_wireless_iface }}.service -{% if netplan.stdout.find("yaml") != -1 %} +{% if is_ubuntu and netplan.stdout.find("yaml") != -1 %} Before=netplan-wpa@{{ discovered_wireless_iface }} {% endif %} Before=network.target From 3dd370e0885d9e4e4669a815d5ea26df0594c091 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 13:20:08 -0500 Subject: [PATCH 060/127] limit hostapd to 2.4GHz for now on RPI --- roles/network/tasks/hostapd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 691d9a76b..1c0df4803 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -11,7 +11,7 @@ - name: Setting WiFi channel to {{ current_host_channel.stdout }} on RPi hardware set_fact: host_channel: "{{ current_host_channel.stdout }}" - when: current_host_channel.stdout != "" and discovered_wireless_iface != "none" and rpi_model != "none" + when: current_host_channel.stdout != "" and current_host_channel.stdout|int <= 13 and discovered_wireless_iface != "none" and rpi_model != "none" - name: Create /etc/hostapd/hostapd.conf from template template: From 6783038b290557f8f97e05b37e8fc7bbe16bd8b8 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 4 Apr 2020 21:40:38 -0500 Subject: [PATCH 061/127] don't forget about non-netplan networkd netplan.stdout is undefined should handle debian netplan.stdout.find("yaml") == -1) should handle U-16.04 U-18+ uses netplan --- 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 9a478ea4a..5e1650bc3 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -55,4 +55,4 @@ name: systemd-networkd enabled: yes state: restarted - when: not no_net_restart and netplan.stdout.find("yaml") == -1 + when: (netplan.stdout is undefined or netplan.stdout.find("yaml") == -1) and not no_net_restart From 1d4e427fa96d79900e2f14596777dd4a44d084aa Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 6 Apr 2020 05:19:16 -0500 Subject: [PATCH 062/127] softcode exclude devices, move tests and turn into hard failures, record wifi after channel detection, prior_gateway_device, fix ap0 exclude --- roles/network/defaults/main.yml | 3 +- roles/network/tasks/computed_network.yml | 49 ++--------------------- roles/network/tasks/computed_services.yml | 8 ++++ roles/network/tasks/detected_network.yml | 46 ++++++++++++++------- roles/network/tasks/main.yml | 2 +- 5 files changed, 46 insertions(+), 62 deletions(-) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index 87296ede1..867ab89f6 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -62,13 +62,14 @@ strict_networking: False iiab_demo_mode: False gui_static_wan: False wan_cidr: +virtual_network_devices: "-e ap0 -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth" # Set defaults for discovery process as strings wifi1: "not found-1" wifi2: "not found-2" exclude_device: "none" device_gw: "none" -device_gw2: "" +prior_gw_device: "" iiab_wan_iface: "none" iiab_lan_iface: "none" diff --git a/roles/network/tasks/computed_network.yml b/roles/network/tasks/computed_network.yml index fb27dc7b5..08540b94e 100644 --- a/roles/network/tasks/computed_network.yml +++ b/roles/network/tasks/computed_network.yml @@ -6,20 +6,6 @@ user_wan_iface: "{{ discovered_wan_iface }}" when: not (discovered_wan_iface == "none") and not (xo_model == "none") and has_ifcfg_gw == "none" -#- name: Checking for NetworkManager-config-server -# shell: rpm -qa | grep NetworkManager-config-server | wc -l -# register: strict_networking_check - -#- name: Found Checking for NetworkManager-config-server -# set_fact: -# strict_networking: True -# when: strict_networking_check == "1" - -#- name: Use restricted network features -# set_fact: -# iiab_demo_mode: True -# when: teamviewer_install and not strict_networking - - name: XO laptop wants USB WiFi interface as AP mode set_fact: iiab_wireless_lan_iface: "{{ discovered_lan_iface }}" @@ -62,7 +48,7 @@ user_wan_iface: "none" when: not iiab_wan_enabled -# gui wants LanController # keeps ifcfg-WAN but onboot=no +# gui wants LanController # the change over might be a little bumpy ATM. - name: Setting GUI wants 'LanController' set_fact: @@ -71,10 +57,9 @@ iiab_gateway_enabled: "False" when: gui_desired_network_role is defined and gui_desired_network_role == "LanController" -# device_gw is used with the LAN detection and LAN's ifcfg file deletion. -# single interface vars/ users would need to set iiab_wan_enabled False as above, to disable the WAN -# and set user_lan_iface = to suppress the auto detection for the same effect. - +# discovered_wan_iface is used with the LAN detection, single interface vars/ users would +# need to set iiab_wan_enabled False as above, to disable the WAN and set +# user_lan_iface: to suppress the auto detection for the same effect. - name: Setting user_lan_iface for 'LanController' for single interface set_fact: user_lan_iface: "{{ discovered_wan_iface }}" @@ -143,24 +128,6 @@ iiab_lan_iface: "{{ user_lan_iface }}" when: not (user_lan_iface == "auto") -# so this works -- name: Interface count - shell: ls /sys/class/net | grep -v -e lo -e bridge0 -e veth -e "br-*" -e docker| wc | awk '{print $1}' - register: adapter_count - -# well if there ever was a point to tell the user things are FUBAR this is it. -- name: We're hosed no work interfaces - set_fact: - iiab_network_mode: "No_network_found" - when: adapter_count.stdout|int == 0 - -# well if there ever was a point to tell the user things are FUBAR this is it. -- name: I'm not guessing declare gateway please - set_fact: - iiab_network_mode: "Undetectable_use_local_vars" - 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 {{ iiab_env_file }} lineinfile: path: "{{ iiab_env_file }}" @@ -197,11 +164,3 @@ value: "{{ iiab_lan_iface }}" - option: iiab_network_mode value: "{{ iiab_network_mode }}" - - option: hostapd_enabled - value: "{{ hostapd_enabled }}" - - option: host_ssid - value: "{{ host_ssid }}" - - option: host_wifi_mode - value: "{{ host_wifi_mode }}" - - option: host_channel - value: "{{ host_channel }}" diff --git a/roles/network/tasks/computed_services.yml b/roles/network/tasks/computed_services.yml index 72fdd951c..1c4ee95ba 100644 --- a/roles/network/tasks/computed_services.yml +++ b/roles/network/tasks/computed_services.yml @@ -74,3 +74,11 @@ value: "{{ dnsmasq_enabled }}" - option: no_net_restart value: "{{ no_net_restart }}" + - option: hostapd_enabled + value: "{{ hostapd_enabled }}" + - option: host_ssid + value: "{{ host_ssid }}" + - option: host_wifi_mode + value: "{{ host_wifi_mode }}" + - option: host_channel + value: "{{ host_channel }}" diff --git a/roles/network/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml index 95cdbeef3..e2dc13e32 100644 --- a/roles/network/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -1,15 +1,26 @@ -- name: iiab_wan_device - shell: grep IIAB_WAN_DEVICE {{ iiab_env_file }} | awk -F "=" '{print $2}' - when: iiab_stage|int > 4 - register: prior_gw +# so this works +- name: Interface count + shell: ls /sys/class/net | grep -v {{ virtual_network_devices }} | wc | awk '{print $1}' + register: adapter_count + +# well if there ever was a point to tell the user things are FUBAR this is it. +- name: We're hosed no work interfaces + fail: # FORCE IT RED THIS ONCE! + msg: "No_network_found" + when: adapter_count.stdout|int == 0 - name: Checking for old device gateway interface for device test + shell: grep IIAB_WAN_DEVICE {{ iiab_env_file }} | awk -F "=" '{print $2}' + when: iiab_stage|int == 9 + register: prior_gw + +- name: Setting device_gw, prior_gw_device set_fact: device_gw: "{{ prior_gw.stdout }}" - device_gw2: "{{ prior_gw.stdout }}" - when: iiab_stage|int > 4 and prior_gw is defined and prior_gw.stdout != "" + prior_gw_device: "{{ prior_gw.stdout }}" + when: prior_gw.stdout is defined and prior_gw.stdout != "" -- name: Setting WAN if detected +- name: Setting WAN, device_gw if detected set_fact: iiab_wan_iface: "{{ discovered_wan_iface }}" device_gw: "{{ discovered_wan_iface }}" @@ -77,7 +88,7 @@ set_fact: wifi2: "{{ item|trim }}" discovered_wireless_iface: "{{ item|trim }}" - when: wireless_list2.stdout is defined and not wireless_list2.stdout == "ap0" + when: wireless_list2.stdout is defined and item|trim != "ap0" with_items: - "{{ wireless_list2.stdout_lines }}" #item|trim != discovered_wan_iface @@ -86,7 +97,6 @@ shell: "ls -la /sys/class/net/*/phy80211 | awk -F / '{print $5}' | grep -v -e ap0 | wc -l" register: count_wifi_interfaces -# facts are apparently all stored as text, so do text comparisons from here on - name: Remember number of WiFi devices set_fact: num_wifi_interfaces: "{{ count_wifi_interfaces.stdout|int }}" @@ -96,17 +106,16 @@ - name: XO laptop override 2 WiFi on LAN set_fact: - ap_device: "eth0" + exclude_device: "eth0" when: iiab_wan_iface != "eth0" and discovered_wireless_iface != "none" and xo_model == "XO-1.5" - name: Exclude reserved Network Adapter if defined - takes adapter name set_fact: exclude_device: "{{ reserved_device }}" -# when: reserved_device is defined and discovered_wireless_iface != iiab_wan_iface and num_wifi_interfaces >= "2" when: reserved_device is defined - name: Count LAN ifaces - shell: ls /sys/class/net | grep -v -e ap0 -e wwlan -e ppp -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth -e {{ device_gw }} -e {{ exclude_device }} | wc -l + shell: ls /sys/class/net | grep -v {{ virtual_network_devices }} -e wwlan -e ppp -e {{ device_gw }} -e {{ exclude_device }} | wc -l register: num_lan_interfaces_result - name: Calculate number of LAN interfaces including WiFi @@ -115,7 +124,7 @@ # LAN - pick non WAN's - name: Create list of LAN (non WAN) ifaces - shell: ls /sys/class/net | grep -v -e ap0 -e wwlan -e ppp -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth -e {{ device_gw }} -e {{ exclude_device }} + shell: ls /sys/class/net | grep -v {{ virtual_network_devices }} -e wwlan -e ppp -e {{ device_gw }} -e {{ exclude_device }} when: num_lan_interfaces != "0" register: lan_list_result @@ -196,8 +205,8 @@ with_items: - option: has_ifcfg_gw value: "{{ has_ifcfg_gw }}" - - option: prior_gateway_(device_gw2) - value: "{{ device_gw2 }}" + - option: prior_gateway_device + value: "{{ prior_gw_device }}" - option: dhcpcd_result value: "{{ dhcpcd_result }}" - option: network_manager_active @@ -226,3 +235,10 @@ value: "{{ iiab_lan_iface }}" - option: iiab_wan_iface value: "{{ iiab_wan_iface }}" + +# well if there ever was a point to tell the user things are FUBAR this is it. +# limit 2 network adapters wifi wired +- name: I'm not guessing declare gateway please + fail: # FORCE IT RED THIS ONCE! + msg: "Undetectable gateway or prior gateway for use with static network addressing from admin-console use local_vars to declare user_wan_iface" + when: adapter_count.stdout|int >=3 and gui_wan_iface == "unset" and gui_static_wan diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index 486532cae..dcff50019 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -51,9 +51,9 @@ #### Start services - include_tasks: avahi.yml +- include_tasks: hostapd.yml - include_tasks: computed_services.yml - include_tasks: enable_services.yml -- include_tasks: hostapd.yml #### End services From 2059de2383342c05e04a47516f1de1002493d82e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 6 Apr 2020 05:20:28 -0500 Subject: [PATCH 063/127] forgot .service --- roles/network/templates/hostapd/hostapd.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 047ef4b4f..9aca337b0 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -8,7 +8,7 @@ Before=dhcpcd.service Before=wpa_supplicant.service Before=wpa_supplicant@{{ discovered_wireless_iface }}.service {% if is_ubuntu and netplan.stdout.find("yaml") != -1 %} -Before=netplan-wpa@{{ discovered_wireless_iface }} +Before=netplan-wpa@{{ discovered_wireless_iface }}.service {% endif %} Before=network.target From 9893e62fd504083b031707b422641828a6f9b8ad Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 8 Apr 2020 08:34:26 -0500 Subject: [PATCH 064/127] int casting --- 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 5e1650bc3..1805020e1 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -18,7 +18,7 @@ dest: /etc/systemd/network/IIAB-Slave-{{ item|trim }}.network with_items: - "{{ lan_list_result.stdout_lines }}" - when: iiab_wired_lan_iface is defined and num_lan_interfaces >= 2 + when: iiab_wired_lan_iface is defined and num_lan_interfaces|int >= 2 - name: Remove static WAN template file: From ca8e9ab79ad07b5650fa699208ad4a4176bce434 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 8 Apr 2020 20:55:22 -0500 Subject: [PATCH 065/127] let NM if active handle wired slaves --- 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 1805020e1..3126da053 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -18,7 +18,7 @@ dest: /etc/systemd/network/IIAB-Slave-{{ item|trim }}.network with_items: - "{{ lan_list_result.stdout_lines }}" - when: iiab_wired_lan_iface is defined and num_lan_interfaces|int >= 2 + when: iiab_wired_lan_iface is defined and num_lan_interfaces|int >= 2 and not network_manager_active - name: Remove static WAN template file: From 04c876b28a1448f30a4b00c8e83587edec55ff90 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 13 Apr 2020 04:50:56 -0500 Subject: [PATCH 066/127] don't clobber later revisions to hostapd.service.j2 --- roles/network/tasks/hostapd.yml | 13 +++++++++++-- roles/network/templates/hostapd/hostapd.legacy.j2 | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 roles/network/templates/hostapd/hostapd.legacy.j2 diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 1c0df4803..0a759249b 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -39,14 +39,23 @@ set_fact: ap0_mac_addr: "{{ ap0_mac.stdout }}" -- name: Use custom systemd unit file to start 'hostapd' service +- name: Use custom 'hostapd' systemd service unit file using ap0 when wifi_up_down template: src: hostapd/hostapd.service.j2 dest: /etc/systemd/system/hostapd.service owner: root group: root mode: 0644 - when: discovered_wireless_iface != "none" + when: discovered_wireless_iface != "none" and wifi_up_down + +- name: Use custom 'hostapd' systemd service unit file for {{ discovered_wireless_iface }} when not wifi_up_down + template: + src: hostapd/hostapd.legacy.j2 + dest: /etc/systemd/system/hostapd.service + owner: root + group: root + mode: 0644 + when: discovered_wireless_iface != "none" and not wifi_up_down - name: Create /usr/bin/iiab-hotspot-on from template template: diff --git a/roles/network/templates/hostapd/hostapd.legacy.j2 b/roles/network/templates/hostapd/hostapd.legacy.j2 new file mode 100644 index 000000000..4094b812a --- /dev/null +++ b/roles/network/templates/hostapd/hostapd.legacy.j2 @@ -0,0 +1,12 @@ +[Unit] +Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator +Before=network.target +Wants=network-pre.target + +[Service] +Type=idle +PIDFile=/run/hostapd.pid +ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf + +[Install] +WantedBy=multi-user.target From a81f8383bbc06ff731433d4986dec343e2bec39a Mon Sep 17 00:00:00 2001 From: George Hunt Date: Fri, 10 Apr 2020 20:48:10 +0100 Subject: [PATCH 067/127] change wifi_up_down to true in local_vars preselects --- vars/local_vars_big.yml | 2 ++ vars/local_vars_medium.yml | 2 ++ vars/local_vars_min.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/vars/local_vars_big.yml b/vars/local_vars_big.yml index 24ef93c34..24f67e278 100644 --- a/vars/local_vars_big.yml +++ b/vars/local_vars_big.yml @@ -46,6 +46,8 @@ host_wifi_mode: g host_channel: 6 hostapd_secure: False hostapd_password: changeme +wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet + # as well as classroom hotspot, use iiab_gateway_enabled for pass through # See "How do I set a static IP address?" for Ethernet, in http://FAQ.IIAB.IO wan_ip: dhcp # wan_ip: 192.168.1.99 diff --git a/vars/local_vars_medium.yml b/vars/local_vars_medium.yml index b8f66307b..d43af20dc 100644 --- a/vars/local_vars_medium.yml +++ b/vars/local_vars_medium.yml @@ -46,6 +46,8 @@ host_wifi_mode: g host_channel: 6 hostapd_secure: False hostapd_password: changeme +wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet + # as well as classroom hotspot, use iiab_gateway_enabled for pass through # See "How do I set a static IP address?" for Ethernet, in http://FAQ.IIAB.IO wan_ip: dhcp # wan_ip: 192.168.1.99 diff --git a/vars/local_vars_min.yml b/vars/local_vars_min.yml index 8918cd634..2f982d59b 100644 --- a/vars/local_vars_min.yml +++ b/vars/local_vars_min.yml @@ -46,6 +46,8 @@ host_wifi_mode: g host_channel: 6 hostapd_secure: False hostapd_password: changeme +wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet + # as well as classroom hotspot, use iiab_gateway_enabled for pass through # See "How do I set a static IP address?" for Ethernet, in http://FAQ.IIAB.IO wan_ip: dhcp # wan_ip: 192.168.1.99 From b0a54afc1c099bba02a91e9d428b452d5f4f5c70 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Fri, 10 Apr 2020 15:23:49 -0700 Subject: [PATCH 068/127] remove dhcpcd hooks if not up_down --- roles/network/tasks/hostapd.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 0a759249b..403015e48 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -82,6 +82,12 @@ mode: 0644 when: is_raspbian +- name: Remove dhcpcd hook for hostapd if WiFi is not split + file: + path: /lib/dhcpcd/dhcpcd-hooks/50-hostapd + state: absent + when: is_raspbian and not wifi_up_down + - name: Create networkd-dispatcher diagnosic hook for recording network events template: owner: root From 97fa35c9d2e53e01d319e51876d4b90a59833f5c Mon Sep 17 00:00:00 2001 From: George Hunt Date: Fri, 10 Apr 2020 20:42:26 +0100 Subject: [PATCH 069/127] don't let dhcpcd muck around with wlan0 if it's under the br0 --- roles/network/tasks/hostapd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 403015e48..75cd0f564 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -80,7 +80,7 @@ owner: root group: root mode: 0644 - when: is_raspbian + when: is_raspbian and wifi_up_down - name: Remove dhcpcd hook for hostapd if WiFi is not split file: From 75162642ad3fbe3d43102b9134c9c1ffbde0029e Mon Sep 17 00:00:00 2001 From: George Hunt Date: Sun, 12 Apr 2020 17:53:26 +0100 Subject: [PATCH 070/127] suppose iiab-wifi should be absent when not wifi_up_down --- roles/network/tasks/hostapd.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 75cd0f564..0cd9a2d5d 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -114,7 +114,16 @@ 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' } - when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" + when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and wifi_up_down + +- name: Remove networkd-dispatcher hook for hostapd on RPi hardware and not up/down + file: + path: "{{ item.dest}} + status: absent + 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' } + when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and not wifi_up_down - name: Disable the Access Point 'hostapd' service systemd: From 4d9d925db8dbc6c0da711cabb663d687105005fa Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 12 Apr 2020 15:29:14 -0500 Subject: [PATCH 071/127] one template - 2 copies --- roles/network/tasks/hostapd.yml | 2 +- .../templates/hostapd/iiab-hostapd.conf.j2 | 32 ------------------- 2 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 roles/network/templates/hostapd/iiab-hostapd.conf.j2 diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 0cd9a2d5d..1e6326258 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -24,7 +24,7 @@ - name: Create backup /etc/hostapd/hostapd.conf.iiab from template template: - src: hostapd/iiab-hostapd.conf.j2 + src: hostapd/hostapd.conf.j2 dest: /etc/hostapd/hostapd.conf.iiab owner: root group: root diff --git a/roles/network/templates/hostapd/iiab-hostapd.conf.j2 b/roles/network/templates/hostapd/iiab-hostapd.conf.j2 deleted file mode 100644 index 097a8d41a..000000000 --- a/roles/network/templates/hostapd/iiab-hostapd.conf.j2 +++ /dev/null @@ -1,32 +0,0 @@ -# Basic configuration - -interface=ap0 - -ssid={{ host_ssid }} -channel={{ host_channel }} -{%if iiab_lan_iface == "br0" %} -bridge=br0 -{% endif %} - -# Hardware configuration -driver={{ driver_name }} -{%if host_wireless_n %} -ieee80211n=1 -{% endif %} -country_code={{ host_country_code }} -# limit emissions to what is legal in country -ieee80211d=1 -hw_mode={{ host_wifi_mode }} - -{%if hostapd_secure %} -# Use WPA authentication -auth_algs=1 -# Use WPA2 -wpa=2 -# Use a pre-shared key -wpa_key_mgmt=WPA-PSK -# The network passphrase -wpa_passphrase={{ hostapd_password }} -# Use AES, instead of TKIP -rsn_pairwise=CCMP -{% endif %} From 640dbd64eae4a94766a956ce350184e76e35d57b Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 13 Apr 2020 02:15:14 -0500 Subject: [PATCH 072/127] use wifi_up_down to set iiab_wireless_lan_iface --- roles/network/tasks/detected_network.yml | 10 ++++++++-- roles/network/tasks/restart.yml | 2 +- roles/network/templates/hostapd/hostapd.conf.j2 | 2 +- roles/network/templates/network/dhcpcd.conf.j2 | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/roles/network/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml index e2dc13e32..05c329dbe 100644 --- a/roles/network/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -145,10 +145,16 @@ with_items: - "{{ lan_list_result.stdout_lines }}" -- name: Set iiab_wireless_lan_iface if present + +- name: Set iiab_wireless_lan_iface to {{ discovered_wireless_iface }} if not none set_fact: iiab_wireless_lan_iface: "{{ discovered_wireless_iface }}" - when: discovered_wireless_iface is defined and discovered_wireless_iface != "none" and discovered_wireless_iface != iiab_wan_iface + when: discovered_wireless_iface != "none" and discovered_wireless_iface != iiab_wan_iface + +- name: Set iiab_wireless_lan_iface to ap0 if WiFi device is present + set_fact: + iiab_wireless_lan_iface: ap0 + when: discovered_wireless_iface != "none" and wifi_up_down - name: Set iiab_wired_lan_iface if present set_fact: diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index cf4d9ee4e..459400326 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -64,7 +64,7 @@ command: /usr/bin/iiab-gen-iptables - name: Checking if WiFi slave is active - shell: brctl show br0 | grep ap0 | wc -l + shell: brctl show br0 | grep {{ iiab_wireless_lan_iface }} | wc -l when: hostapd_enabled and iiab_wireless_lan_iface is defined and iiab_lan_iface == "br0" register: wifi_slave diff --git a/roles/network/templates/hostapd/hostapd.conf.j2 b/roles/network/templates/hostapd/hostapd.conf.j2 index 097a8d41a..28c558e14 100644 --- a/roles/network/templates/hostapd/hostapd.conf.j2 +++ b/roles/network/templates/hostapd/hostapd.conf.j2 @@ -1,6 +1,6 @@ # Basic configuration -interface=ap0 +interface={{ iiab_wireless_lan_iface }} ssid={{ host_ssid }} channel={{ host_channel }} diff --git a/roles/network/templates/network/dhcpcd.conf.j2 b/roles/network/templates/network/dhcpcd.conf.j2 index 88c88201a..bc8f47ebd 100644 --- a/roles/network/templates/network/dhcpcd.conf.j2 +++ b/roles/network/templates/network/dhcpcd.conf.j2 @@ -38,7 +38,7 @@ require dhcp_server_identifier slaac private # IIAB -denyinterfaces ap0 +denyinterfaces {{ iiab_wireless_lan_iface }} # Setting iiab_wired_lan_iface would install the device as a slave under # br0 so we need to turn off the dhcp client in that network layout. From ab0cb6fc90831c7ffb9e60327b343384e5ee4cfe Mon Sep 17 00:00:00 2001 From: George Hunt Date: Sun, 12 Apr 2020 17:34:39 +0100 Subject: [PATCH 073/127] disable hostspot on/off if up/down enabled --- roles/network/templates/network/iiab-hotspot-off | 8 ++++++++ roles/network/templates/network/iiab-hotspot-on | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index 5541a260e..be78c0993 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -1,4 +1,11 @@ #!/bin/bash + +{% if wifi_up_down %} +echo "Iiab-hotspot-up/down only functions when /etc/iiab/wifi_up_down is set to False" +echo " If you want hotspot on/off function please set wifi_up_down and run /opt/iiab/iiab/iiab-network" +exit 0 + +{% else %} #sed -i -e "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf systemctl disable hostapd systemctl stop hostapd @@ -15,5 +22,6 @@ systemctl stop hostapd #if grep -qi raspbian /etc/*release; then # ip link set dev wlan0 promisc on #fi +{% endif %} sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index c88130d4c..8630c7fdf 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -1,4 +1,11 @@ #!/bin/bash + +{% if wifi_up_down %} +echo "Iiab-hotspot-up/down only functions when /etc/iiab/wifi_up_down is set to False" +echo " If you want hotspot on/off function please set wifi_up_down and run /opt/iiab/iiab/iiab-network" +exit 0 + +{% else %} #cp -f /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf #sed -i -e "s/^#denyinterfaces/denyinterfaces/" /etc/dhcpcd.conf # shut down wlan0 in case connected to network @@ -16,6 +23,7 @@ systemctl start dnsmasq #if grep -qi raspbian /etc/*release; then # ip link set dev wlan0 promisc off #fi +{% endif %} sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} From 207cc98255868f92e8fd1befeece7e1821a1764e Mon Sep 17 00:00:00 2001 From: George Hunt Date: Sun, 12 Apr 2020 17:43:20 +0100 Subject: [PATCH 074/127] revert hotspot on/off to master before ap0 when wifi_up_down is false --- roles/network/templates/network/iiab-hotspot-off | 13 +++++++------ roles/network/templates/network/iiab-hotspot-on | 16 +++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index be78c0993..449b0ac0b 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -6,22 +6,23 @@ echo " If you want hotspot on/off function please set wifi_up_down and run /opt exit 0 {% else %} -#sed -i -e "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf +# hotspot-off before ap0_updown +sed -i -e "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf systemctl disable hostapd systemctl stop hostapd #systemctl disable dnsmasq #systemctl stop dnsmasq -#systemctl daemon-reload -#systemctl restart dhcpcd +systemctl daemon-reload +systemctl restart dhcpcd #systemctl restart networking 6/15/2019 TFM removed # Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" # Set wlan0 to promiscuous when AP's OFF (for possible WiFi gateway) # SEE ALSO iiab-hotspot-on + /usr/libexec/iiab-startup.sh # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -#if grep -qi raspbian /etc/*release; then -# ip link set dev wlan0 promisc on -#fi +if grep -qi raspbian /etc/*release; then + ip link set dev wlan0 promisc on +fi {% endif %} sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index 8630c7fdf..9ec78af82 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -6,13 +6,15 @@ echo " If you want hotspot on/off function please set wifi_up_down and run /opt exit 0 {% else %} -#cp -f /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf -#sed -i -e "s/^#denyinterfaces/denyinterfaces/" /etc/dhcpcd.conf +# just do what we have always done in hotspot-on +cp -f /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf +sed -i -e "s/^#denyinterfaces/denyinterfaces/" /etc/dhcpcd.conf # shut down wlan0 in case connected to network -#ip link set wlan0 down +ip link set wlan0 down systemctl enable hostapd #systemctl daemon-reload -#systemctl restart dhcpcd +systemctl daemon-reload +systemctl restart dhcpcd systemctl start hostapd systemctl start dnsmasq @@ -20,9 +22,9 @@ systemctl start dnsmasq # Disable "promiscuous" on wlan0 when AP (i.e. no WiFi gateway) # SEE ALSO iiab-hotspot-off + /usr/libexec/iiab-startup.sh # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -#if grep -qi raspbian /etc/*release; then -# ip link set dev wlan0 promisc off -#fi +if grep -qi raspbian /etc/*release; then + ip link set dev wlan0 promisc off +fi {% endif %} sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} From 13d7c38a730f6a9dd65bf9f14d614cf0d887dafc Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 13 Apr 2020 04:33:38 -0500 Subject: [PATCH 075/127] on|off for wifi_up_down --- roles/network/templates/network/iiab-hotspot-off | 15 ++++++++------- roles/network/templates/network/iiab-hotspot-on | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index 449b0ac0b..8b7eb5bbc 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -1,8 +1,10 @@ #!/bin/bash {% if wifi_up_down %} -echo "Iiab-hotspot-up/down only functions when /etc/iiab/wifi_up_down is set to False" -echo " If you want hotspot on/off function please set wifi_up_down and run /opt/iiab/iiab/iiab-network" +systemctl disable hostapd +systemctl stop hostapd +sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} +echo " IIAB hotspot access point Disabled" exit 0 {% else %} @@ -15,14 +17,13 @@ systemctl stop hostapd systemctl daemon-reload systemctl restart dhcpcd #systemctl restart networking 6/15/2019 TFM removed +sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} # Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" # Set wlan0 to promiscuous when AP's OFF (for possible WiFi gateway) # SEE ALSO iiab-hotspot-on + /usr/libexec/iiab-startup.sh # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -if grep -qi raspbian /etc/*release; then - ip link set dev wlan0 promisc on -fi +#if grep -qi raspbian /etc/*release; then +# ip link set dev wlan0 promisc on +#fi {% endif %} - -sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index 9ec78af82..47250ce56 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -1,8 +1,9 @@ #!/bin/bash {% if wifi_up_down %} -echo "Iiab-hotspot-up/down only functions when /etc/iiab/wifi_up_down is set to False" -echo " If you want hotspot on/off function please set wifi_up_down and run /opt/iiab/iiab/iiab-network" +systemctl enable hostapd +sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} +echo -e "\nPlease reboot to activate hostapd feature.\n" exit 0 {% else %} @@ -17,16 +18,16 @@ systemctl daemon-reload systemctl restart dhcpcd systemctl start hostapd systemctl start dnsmasq +sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} + # Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" # Disable "promiscuous" on wlan0 when AP (i.e. no WiFi gateway) # SEE ALSO iiab-hotspot-off + /usr/libexec/iiab-startup.sh # https://github.com/iiab/iiab/issues/638#issuecomment-355455454 -if grep -qi raspbian /etc/*release; then - ip link set dev wlan0 promisc off -fi +#if grep -qi raspbian /etc/*release; then +# ip link set dev wlan0 promisc off +#fi {% endif %} -sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} - echo -e "\nPlease consider rebooting now.\n" From 0d9321a363fd16478a65333c20e42d7380106853 Mon Sep 17 00:00:00 2001 From: George Hunt Date: Sun, 12 Apr 2020 19:31:16 +0100 Subject: [PATCH 076/127] partial of 720c285... typo iiab_wireless_an_iface --- roles/network/tasks/hostapd.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 1e6326258..4cd3672dc 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -118,11 +118,11 @@ - name: Remove networkd-dispatcher hook for hostapd on RPi hardware and not up/down file: - path: "{{ item.dest}} + path: "{{ item.dest}}" status: absent 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' } + - { dest: '/etc/networkd-dispatcher/carrier.d/iiab-wifi' } + - { dest: '/etc/networkd-dispatcher/no-carrier.d/iiab-wifi' } when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and not wifi_up_down - name: Disable the Access Point 'hostapd' service From fc0b4586de693aa95b415941f6fbe37863f818fb Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 11 Apr 2020 00:39:16 -0400 Subject: [PATCH 077/127] default_vars.yml updated (to match local_vars_min.yml) --- vars/default_vars.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vars/default_vars.yml b/vars/default_vars.yml index 90fbf7ca8..dca8245ed 100644 --- a/vars/default_vars.yml +++ b/vars/default_vars.yml @@ -98,6 +98,8 @@ hostapd_enabled: True # Above is forcibly set to False (in roles/network/tasks/main.yml) if IIAB is # being WiFi-installed (run "iiab-hotspot-on" AFTER ./iiab-install completes # and content is downloaded, to enable the internal WiFi Access Point / AP!) +wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet + # as well as classroom hotspot, use iiab_gateway_enabled for pass through reboot_to_AP: False # For those installing IIAB over WiFi: "reboot_to_AP: True" overrides the above # detection of WiFi-as-gateway, forcing "hostapd_enabled: True" regardless. From ed01d0584d05d6203cebd8379da3666db8d6f4e5 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 13 Apr 2020 08:27:08 -0500 Subject: [PATCH 078/127] netplan - 01-iiab exclude wireless devices --- roles/network/tasks/netplan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index 98b8e4656..801b64658 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -44,6 +44,7 @@ dest: /etc/netplan/01-iiab-config.yaml src: network/netplan.j2 backup: no + when: iiab_wan_iface != discovered_wireless_iface # should blow up here if we messed up the yml file #- name: Generate netplan config From 10eb7e76d9982266fc1a48c2dc3fb93d0b9f1f5c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 13 Apr 2020 08:29:47 -0500 Subject: [PATCH 079/127] sysd-netd drop wired device count --- 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 3126da053..a5a56a802 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -18,7 +18,7 @@ dest: /etc/systemd/network/IIAB-Slave-{{ item|trim }}.network with_items: - "{{ lan_list_result.stdout_lines }}" - when: iiab_wired_lan_iface is defined and num_lan_interfaces|int >= 2 and not network_manager_active + when: iiab_wired_lan_iface is defined and num_lan_interfaces|int >= 1 and not network_manager_active - name: Remove static WAN template file: From 0bc294bbba5bc41c9346a955e9d6cbc713f515fa Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 13 Apr 2020 13:43:15 -0500 Subject: [PATCH 080/127] Update roles/network/tasks/hostapd.yml Co-Authored-By: A Holt --- roles/network/tasks/hostapd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 4cd3672dc..c09b7e8e9 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -11,7 +11,7 @@ - name: Setting WiFi channel to {{ current_host_channel.stdout }} on RPi hardware set_fact: host_channel: "{{ current_host_channel.stdout }}" - when: current_host_channel.stdout != "" and current_host_channel.stdout|int <= 13 and discovered_wireless_iface != "none" and rpi_model != "none" + when: current_host_channel.stdout is defined and current_host_channel.stdout != "" and current_host_channel.stdout|int <= 13 and discovered_wireless_iface != "none" and rpi_model != "none" - name: Create /etc/hostapd/hostapd.conf from template template: From 0249c3a1003abfa49b7fe7a6072fdb258e9ce600 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 14 Apr 2020 07:56:31 -0500 Subject: [PATCH 081/127] turn off hostapd in Appliance mode --- roles/network/tasks/computed_services.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/network/tasks/computed_services.yml b/roles/network/tasks/computed_services.yml index 1c4ee95ba..26523cd1c 100644 --- a/roles/network/tasks/computed_services.yml +++ b/roles/network/tasks/computed_services.yml @@ -3,6 +3,7 @@ dansguardian_enabled: False squid_enabled: False wondershaper_enabled: False + hostapd_enabled: False iiab_network_mode: "Appliance" when: iiab_lan_iface == "none" or user_lan_iface == "none" From ab8de54e24dc3c1f903bcb5c96e06e41710dd2ba Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 14 Apr 2020 07:59:27 -0500 Subject: [PATCH 082/127] restart - hostapd use wifi gateway as test --- roles/network/tasks/restart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index 459400326..61274c625 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -2,7 +2,7 @@ systemd: name: hostapd state: restarted - when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" + when: iiab_wireless_lan_iface is defined and hostapd_enabled and discovered_wireless_iface != iiab_wan_iface - name: Start named service systemd: From 2089a0c91804434c6835927caa70166f899413c3 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 14 Apr 2020 08:03:00 -0500 Subject: [PATCH 083/127] don't set hostapd_enabled: False with wifi gateway --- roles/network/tasks/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index dcff50019..4071d53f3 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -2,12 +2,11 @@ - name: IF WIFI IS PRIMARY GATEWAY, PLEASE RUN 'iiab-hotspot-on' MANUALLY set_fact: - hostapd_enabled: False # used in (1) hostapd.yml, (2) rpi_debian.yml + - # (3) its dhcpcd.conf.j2, (4) restart.yml no_net_restart: True # used below in (1) sysd-netd-debian.yml, # (2) debian.yml, (3) rpi_debian.yml, # (4) NM-debian.yml - when: discovered_wireless_iface == iiab_wan_iface and not reboot_to_AP + when: discovered_wireless_iface == iiab_wan_iface + # EITHER WAY: hostapd_enabled's state is RECORDED into {{ iiab_env_file }} # in hostapd.yml for later use by... # /usr/libexec/iiab-startup.sh, iiab-hotspot-off & iiab-hotspot-on From 3912e6a1ef94c788ba1615545e2135c50a00391c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 14 Apr 2020 08:07:07 -0500 Subject: [PATCH 084/127] remove reboot_to_AP --- roles/network/defaults/main.yml | 12 ++---------- vars/default_vars.yml | 3 --- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/roles/network/defaults/main.yml b/roles/network/defaults/main.yml index 867ab89f6..d1928bdb2 100644 --- a/roles/network/defaults/main.yml +++ b/roles/network/defaults/main.yml @@ -25,16 +25,8 @@ # # hostapd_install: True # 2020-01-21: do not rely on this var for now (might be implemented in future) # hostapd_enabled: True -# Above is forcibly set to False (in roles/network/tasks/main.yml) if IIAB is -# being WiFi-installed (run "iiab-hotspot-on" AFTER ./iiab-install completes -# and content is downloaded, to enable the internal WiFi Access Point / AP!) -# -# reboot_to_AP: False -# For those installing IIAB over WiFi: "reboot_to_AP: True" overrides the above -# detection of WiFi-as-gateway, forcing "hostapd_enabled: True" regardless. -# -# Above 2 vars set in /opt/iiab/iiab/vars/default_vars.yml -# +# Above set in /opt/iiab/iiab/vars/default_vars.yml + hostapd_wait: 5 host_wireless_n: False driver_name: nl80211 diff --git a/vars/default_vars.yml b/vars/default_vars.yml index dca8245ed..953e7d51c 100644 --- a/vars/default_vars.yml +++ b/vars/default_vars.yml @@ -100,9 +100,6 @@ hostapd_enabled: True # and content is downloaded, to enable the internal WiFi Access Point / AP!) wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet # as well as classroom hotspot, use iiab_gateway_enabled for pass through -reboot_to_AP: False -# For those installing IIAB over WiFi: "reboot_to_AP: True" overrides the above -# detection of WiFi-as-gateway, forcing "hostapd_enabled: True" regardless. # Gateway mode iiab_lan_enabled: True From 09c7c3e252bef7dd56dcc29bd8c35d54819dde73 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 14 Apr 2020 10:37:00 -0500 Subject: [PATCH 085/127] legacy support should not boot to AP on mode --- roles/network/tasks/hostapd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index c09b7e8e9..feb2f5523 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -1,7 +1,7 @@ -- name: Turn off hostapd when no wifi interface present or in "Appliance Mode" +- name: Turn off hostapd when not using ap0 and wifi gateway present set_fact: hostapd_enabled: False - when: iiab_wireless_lan_iface is undefined or iiab_network_mode == "Appliance" + when: not wifi_up_down and discovered_wireless_iface == iiab_wan_iface - name: Detect current Wifi channel shell: iw {{ discovered_wireless_iface }} info | grep channel | cut -d' ' -f2 From 7db1464b769265a5f337a8df29bea24c5e9ad9bc Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 14 Apr 2020 10:52:52 -0500 Subject: [PATCH 086/127] don't check for wifi slaves if wifi gateway --- roles/network/tasks/restart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index 61274c625..6c106804c 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -65,7 +65,7 @@ - name: Checking if WiFi slave is active shell: brctl show br0 | grep {{ iiab_wireless_lan_iface }} | wc -l - when: hostapd_enabled and iiab_wireless_lan_iface is defined and iiab_lan_iface == "br0" + when: hostapd_enabled and discovered_wireless_iface != iiab_wan_iface and iiab_lan_iface == "br0" register: wifi_slave - name: Restart hostapd if WiFi slave is inactive From 7e5ce367a22fead2c9a4156c81a118bd70cd6e47 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 15 Apr 2020 06:18:31 -0500 Subject: [PATCH 087/127] don't stall boot if br0 has no slaves --- roles/network/templates/network/systemd-br0-network.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/network/templates/network/systemd-br0-network.j2 b/roles/network/templates/network/systemd-br0-network.j2 index b3eb787cc..21dd6e1d2 100644 --- a/roles/network/templates/network/systemd-br0-network.j2 +++ b/roles/network/templates/network/systemd-br0-network.j2 @@ -5,6 +5,7 @@ Name=br0 [Network] Address={{ lan_ip }}/19 LinkLocalAddressing=no +ConfigureWithoutCarrier=yes # Commenting the below line as it has been causing race/looping issues between dnsmasq and systemd-resolved # IIAB ticket #1747 #DNS={{ lan_ip }} From 37259696868fadbfacb1af0479b0c108ae2da265 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 15 Apr 2020 06:31:05 -0500 Subject: [PATCH 088/127] remove dnsmasq workaround for br0 being down at boot --- roles/network/tasks/enable_services.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/roles/network/tasks/enable_services.yml b/roles/network/tasks/enable_services.yml index b0df14178..60d28a9f4 100644 --- a/roles/network/tasks/enable_services.yml +++ b/roles/network/tasks/enable_services.yml @@ -79,23 +79,23 @@ #- debug: # var: nd_enabled -- name: Check if /etc/networkd-dispatcher/routable.d exists - stat: - path: /etc/networkd-dispatcher/routable.d - register: nd_dir +#- name: Check if /etc/networkd-dispatcher/routable.d exists +# stat: +# path: /etc/networkd-dispatcher/routable.d +# register: nd_dir #- debug: # var: nd_dir #- name: To restart dnsmasq whenever br0 comes up, install /etc/networkd-dispatcher/routable.d/dnsmasq.sh from template (if isn't Appliance, and networkd-dispatcher is enabled, and directory /etc/networkd-dispatcher/routable.d exists, i.e. OS's like Ubuntu 18.04) -- 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) - template: - src: roles/network/templates/network/dnsmasq.sh.j2 - dest: /etc/networkd-dispatcher/routable.d/dnsmasq.sh - mode: 0755 - owner: root - group: root - when: dnsmasq_install and dnsmasq_enabled and nd_dir.stat.exists and nd_dir.stat.isdir and (iiab_network_mode != "Appliance") +#- 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) +# template: +# src: roles/network/templates/network/dnsmasq.sh.j2 +# dest: /etc/networkd-dispatcher/routable.d/dnsmasq.sh +# mode: 0755 +# owner: root +# group: root +# when: dnsmasq_install and dnsmasq_enabled and nd_dir.stat.exists and nd_dir.stat.isdir and (iiab_network_mode != "Appliance") #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") From bb487777fae50b54ab4b7f6899a916bacce1c316 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 15 Apr 2020 08:10:22 -0500 Subject: [PATCH 089/127] start hostapd before NM --- roles/network/templates/hostapd/hostapd.service.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 9aca337b0..fc1f1985d 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -7,6 +7,9 @@ Before=dhcpcd.service {% endif %} Before=wpa_supplicant.service Before=wpa_supplicant@{{ discovered_wireless_iface }}.service +{% if network_manager_active %} +Before=network-manager.service +{% endif %} {% if is_ubuntu and netplan.stdout.find("yaml") != -1 %} Before=netplan-wpa@{{ discovered_wireless_iface }}.service {% endif %} From 14bed5f2fc4be942c0eea82deb9d8f3cab20bd5e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 15 Apr 2020 14:03:26 -0500 Subject: [PATCH 090/127] bad idea NM uses dbus to to call wpa_supplicant --- roles/network/tasks/NM-debian.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/roles/network/tasks/NM-debian.yml b/roles/network/tasks/NM-debian.yml index 0c095a4bb..625741e09 100644 --- a/roles/network/tasks/NM-debian.yml +++ b/roles/network/tasks/NM-debian.yml @@ -58,16 +58,6 @@ mode: 0600 when: wan_ip != "dhcp" -- name: Stop wpa_supplicant service - service: - name: wpa_supplicant - state: stopped - when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" - -- name: Mask wpa_supplicant - shell: systemctl mask wpa_supplicant - when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" - - name: Reload systemd systemd: daemon_reload: yes From 24624c6e6f1131dc349072245063cb033ac73316 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 18 Apr 2020 12:13:23 -0500 Subject: [PATCH 091/127] hostapd is masked force override --- roles/network/tasks/hostapd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index feb2f5523..3a49d0c30 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -136,6 +136,7 @@ systemd: name: hostapd enabled: yes + force: yes when: hostapd_enabled - name: Record HOSTAPD_ENABLED to {{ iiab_env_file }} From 776b983e3d813b68a0710996f3f2bd0babe5e1cf Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 18 Apr 2020 12:21:33 -0500 Subject: [PATCH 092/127] documented force does not work use masked no --- roles/network/tasks/hostapd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 3a49d0c30..0f4001a6b 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -135,8 +135,8 @@ - name: Enable the Access Point 'hostapd' service systemd: name: hostapd + masked: no enabled: yes - force: yes when: hostapd_enabled - name: Record HOSTAPD_ENABLED to {{ iiab_env_file }} From b8cf8712c23dd0e1fd552ffd48134ca483b1a0d5 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Apr 2020 19:25:49 -0500 Subject: [PATCH 093/127] netd-disp tuning --- roles/network/tasks/hostapd.yml | 1 + roles/network/templates/hostapd/netd-disp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 0f4001a6b..9c32bf144 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -114,6 +114,7 @@ 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-disp', dest: '/etc/networkd-dispatcher/routeable.d/iiab-wifi' } when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and wifi_up_down - name: Remove networkd-dispatcher hook for hostapd on RPi hardware and not up/down diff --git a/roles/network/templates/hostapd/netd-disp b/roles/network/templates/hostapd/netd-disp index 5b13d4167..af9a7977b 100644 --- a/roles/network/templates/hostapd/netd-disp +++ b/roles/network/templates/hostapd/netd-disp @@ -2,6 +2,6 @@ if [ "$IFACE" == "{{ discovered_wireless_iface }}" ]; then echo "NET-DISP-WiFi $IFACE $STATE" - /usr/sbin/ip link set up ap0 + /usr/sbin/ip link set ap0 up fi From d34e7053b9480a6cf5e9f1edf81f2b13ea86ca13 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Apr 2020 12:59:47 -0500 Subject: [PATCH 094/127] netplan - Disable cloud-init the easy way - bugfix --- roles/network/tasks/netplan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index 801b64658..04bef0e45 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -1,6 +1,6 @@ - name: Disable cloud-init the easy way shell: touch /etc/cloud/cloud-init.disabled - when: ("item" == "50-cloud-init.yaml") + when: item|trim == "50-cloud-init.yaml" with_items: - "{{ netplan.stdout_lines }}" From 40cbebca4644d59eb4f6c3afd84ee3cde9d22d06 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 22 Apr 2020 21:43:03 -0500 Subject: [PATCH 095/127] hostapd - netplan @ -> - --- roles/network/templates/hostapd/hostapd.service.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index fc1f1985d..a6ec1f79b 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -11,7 +11,7 @@ Before=wpa_supplicant@{{ discovered_wireless_iface }}.service Before=network-manager.service {% endif %} {% if is_ubuntu and netplan.stdout.find("yaml") != -1 %} -Before=netplan-wpa@{{ discovered_wireless_iface }}.service +Before=netplan-wpa-{{ discovered_wireless_iface }}.service {% endif %} Before=network.target From 6f1ef6ec831f978d745c55c4b86b9586faeade54 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 23 Apr 2020 01:46:35 -0500 Subject: [PATCH 096/127] hostapd.yml typo no 'e' --- roles/network/tasks/hostapd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 9c32bf144..bc1b19a28 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -114,7 +114,7 @@ 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-disp', dest: '/etc/networkd-dispatcher/routeable.d/iiab-wifi' } + - { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi' } when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and wifi_up_down - name: Remove networkd-dispatcher hook for hostapd on RPi hardware and not up/down From fa886874b0b9b08d12982d93398dd5354053a8b6 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 23 Apr 2020 10:51:00 -0500 Subject: [PATCH 097/127] iiab-wifi cleanup routable.d when not wifi_up_down --- roles/network/tasks/hostapd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index bc1b19a28..825c8226f 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -124,6 +124,7 @@ 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' } when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and not wifi_up_down - name: Disable the Access Point 'hostapd' service From 5a538cbdd20d875cf4fd4849224da54e5969a035 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 23 Apr 2020 10:57:50 -0500 Subject: [PATCH 098/127] netplan.yml - use item|trim for delete test --- roles/network/tasks/netplan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index 04bef0e45..a9f977faf 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -8,7 +8,7 @@ file: state: absent path: /etc/netplan/{{ item }} - when: netplan.stdout.find("yaml") != -1 and (item != "02-iiab-config.yaml") + when: netplan.stdout.find("yaml") != -1 and item|trim != "02-iiab-config.yaml" with_items: - "{{ netplan.stdout_lines }}" From 3b26b4c59461c18cc88df72f45d8282a3896cec8 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 26 Apr 2020 16:44:41 -0500 Subject: [PATCH 099/127] don't call netplan apply --- roles/network/tasks/restart.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index 6c106804c..0634bdc63 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -53,9 +53,10 @@ creates: /etc/sysconfig/olpc-scripts/setup.d/installed/gateway when: iiab_network_mode == "Gateway" -- name: Reload netplan when Wifi is present on Ubuntu 18+ - shell: netplan apply - when: not no_net_restart and is_ubuntu and netplan.stdout.find("yaml") != -1 +#netplan de-configures pre-created bridged interfaces +#- name: Reload netplan when Wifi is not gateway on Ubuntu 18+ +# shell: netplan apply +# when: not no_net_restart and is_ubuntu and netplan.stdout.find("yaml") != -1 - name: Waiting {{ hostapd_wait }} seconds for network to stabilize (dnsmasq will fail if br0 isn't in a 'up' state!) shell: sleep {{ hostapd_wait }} From 4f4e7f5cc5899ec43a1592c121934bb98d8572b1 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 27 Apr 2020 15:48:38 -0500 Subject: [PATCH 100/127] file status -> state think0 --- roles/network/tasks/hostapd.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 825c8226f..8e12593c7 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -118,9 +118,9 @@ when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and wifi_up_down - name: Remove networkd-dispatcher hook for hostapd on RPi hardware and not up/down - file: - path: "{{ item.dest}}" - status: absent + 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' } From e741ba35eadbb325850400eb8edb319c3786ed01 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 27 Apr 2020 17:03:50 -0500 Subject: [PATCH 101/127] revert the rest of 5a70c9feead4b56a5dd2153d741b0b312575d74b --- roles/network/tasks/sysd-netd-debian.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index a5a56a802..2bcfd86bb 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -55,4 +55,5 @@ name: systemd-networkd enabled: yes state: restarted - when: (netplan.stdout is undefined or netplan.stdout.find("yaml") == -1) and not no_net_restart + #when: (netplan.stdout is undefined or netplan.stdout.find("yaml") == -1) and not no_net_restart + when: not no_net_restart From 73079620674436a3da7efd07454fe1e221225a89 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 00:56:38 -0500 Subject: [PATCH 102/127] manage.conf.j2 --- roles/network/tasks/NM-debian.yml | 13 ++++++------- roles/network/templates/network/manage.conf.j2 | 4 ++++ 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 roles/network/templates/network/manage.conf.j2 diff --git a/roles/network/tasks/NM-debian.yml b/roles/network/tasks/NM-debian.yml index 625741e09..565a5d42e 100644 --- a/roles/network/tasks/NM-debian.yml +++ b/roles/network/tasks/NM-debian.yml @@ -11,19 +11,18 @@ set_fact: gen_uuid: "{{ uuid_response.stdout_lines[0] }}" -# NM might have a watcher on this path and we don't have to restart NM -- name: Copy the bridge script for NetworkManager +- name: Copy manage.conf for NetworkManager template: - dest: /etc/NetworkManager/system-connections/ - src: network/bridge-br0 - mode: 0600 - when: iiab_network_mode != "Appliance" + dest: /etc/NetworkManager/conf.d/wifi-manage.conf + src: network/manage.conf.j2 + mode: 0644 + when: discovered_wireless_iface != "none" and not wifi_up_down - name: Remove br0 in Appliance Mode for NetworkManager file: dest: /etc/NetworkManager/system-connections/bridge-br0 state: absent - when: iiab_network_mode == "Appliance" +# when: iiab_network_mode == "Appliance" - name: Removing static for NetworkManager file: diff --git a/roles/network/templates/network/manage.conf.j2 b/roles/network/templates/network/manage.conf.j2 new file mode 100644 index 000000000..fb5c25f55 --- /dev/null +++ b/roles/network/templates/network/manage.conf.j2 @@ -0,0 +1,4 @@ +# IIAB WiFi +[device] +match-device=interface-name:{{ discovered_wireless_iface }} +managed=0 From 5dd283f84e14ee098d9a4b05084df4efb2105e7a Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 00:58:24 -0500 Subject: [PATCH 103/127] hotspots --- .../templates/network/iiab-hotspot-off | 23 +++++++++++-------- .../network/templates/network/iiab-hotspot-on | 23 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/roles/network/templates/network/iiab-hotspot-off b/roles/network/templates/network/iiab-hotspot-off index 8b7eb5bbc..7cc396dac 100755 --- a/roles/network/templates/network/iiab-hotspot-off +++ b/roles/network/templates/network/iiab-hotspot-off @@ -1,13 +1,5 @@ #!/bin/bash - -{% if wifi_up_down %} -systemctl disable hostapd -systemctl stop hostapd -sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} -echo " IIAB hotspot access point Disabled" -exit 0 - -{% else %} +{% if is_raspbian %} # hotspot-off before ap0_updown sed -i -e "s/^denyinterfaces/#denyinterfaces/" /etc/dhcpcd.conf systemctl disable hostapd @@ -18,7 +10,6 @@ systemctl daemon-reload systemctl restart dhcpcd #systemctl restart networking 6/15/2019 TFM removed sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} - # Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" # Set wlan0 to promiscuous when AP's OFF (for possible WiFi gateway) # SEE ALSO iiab-hotspot-on + /usr/libexec/iiab-startup.sh @@ -26,4 +17,16 @@ sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} #if grep -qi raspbian /etc/*release; then # ip link set dev wlan0 promisc on #fi +{% else %} +systemctl disable hostapd +systemctl stop hostapd +sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=False/" {{ iiab_env_file }} +echo " IIAB hotspot access point Disabled" +{% if wifi_up_down %} +exit 0 +{% else %} +sed -i -e "s|managed=0|managed=1|" /etc/NetworkManager/conf.d/wifi-manage.conf +echo -e "\nPlease reboot to enable upstream WiFi access.\n" +exit 0 +{% endif %} {% endif %} diff --git a/roles/network/templates/network/iiab-hotspot-on b/roles/network/templates/network/iiab-hotspot-on index 47250ce56..03c038197 100755 --- a/roles/network/templates/network/iiab-hotspot-on +++ b/roles/network/templates/network/iiab-hotspot-on @@ -1,12 +1,6 @@ #!/bin/bash -{% if wifi_up_down %} -systemctl enable hostapd -sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} -echo -e "\nPlease reboot to activate hostapd feature.\n" -exit 0 - -{% else %} +{% if is_raspbian %} # just do what we have always done in hotspot-on cp -f /etc/hostapd/hostapd.conf.iiab /etc/hostapd/hostapd.conf sed -i -e "s/^#denyinterfaces/denyinterfaces/" /etc/dhcpcd.conf @@ -20,7 +14,6 @@ systemctl start hostapd systemctl start dnsmasq sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} - # Temporary promiscuous-mode workaround for RPi's WiFi "10SEC disease" # Disable "promiscuous" on wlan0 when AP (i.e. no WiFi gateway) # SEE ALSO iiab-hotspot-off + /usr/libexec/iiab-startup.sh @@ -28,6 +21,16 @@ sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} #if grep -qi raspbian /etc/*release; then # ip link set dev wlan0 promisc off #fi -{% endif %} -echo -e "\nPlease consider rebooting now.\n" +{% else %} +systemctl enable hostapd +sed -i -e "s/^HOSTAPD_ENABLED.*/HOSTAPD_ENABLED=True/" {{ iiab_env_file }} +{% if wifi_up_down %} +echo -e "\nPlease reboot to activate hostapd feature.\n" +exit 0 +{% else %} +sed -i -e "s|managed=1|managed=0|" /etc/NetworkManager/conf.d/wifi-manage.conf +echo -e "\nPlease reboot to activate hostapd feature.\n" +exit 0 +{% endif %} +{% endif %} From 56ba4d0d1984c9c04186a527ff4835bace1f0207 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 00:59:54 -0500 Subject: [PATCH 104/127] static ip systemd-networkd --- roles/network/tasks/sysd-netd-debian.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index 2bcfd86bb..c10b015fb 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -36,11 +36,12 @@ wan_cidr: "{{ CIDR.stdout }}" when: wan_ip != "dhcp" -- name: Supply static WAN template (ubuntu-16) +- name: Supply static WAN template when network_manager_active is False template: dest: /etc/systemd/network/IIAB-Static.network src: network/systemd-static-net.j2 - when: wan_ip != "dhcp" and is_ubuntu_16 + when: wan_ip != "dhcp" and ( is_ubuntu_16 or not network_manager_active ) + #when: wan_ip != "dhcp" and not is_ubuntu_18 - name: Stopping services @@ -54,6 +55,7 @@ systemd: name: systemd-networkd enabled: yes + masked: no state: restarted #when: (netplan.stdout is undefined or netplan.stdout.find("yaml") == -1) and not no_net_restart when: not no_net_restart From f83e615b407c63659a516e90ebc0133245f34e1e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 01:00:58 -0500 Subject: [PATCH 105/127] netplan --- roles/network/tasks/netplan.yml | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index a9f977faf..0d8663848 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -4,11 +4,9 @@ with_items: - "{{ netplan.stdout_lines }}" -- name: Remove stock netplan template - file: - state: absent - path: /etc/netplan/{{ item }} - when: netplan.stdout.find("yaml") != -1 and item|trim != "02-iiab-config.yaml" +- name: Moving 50-cloud-init.yaml to 02-iiab-config.yaml + shell: mv /etc/netplan/50-cloud-init.yaml /etc/netplan/02-iiab-config.yaml + when: netplan.stdout.find("yaml") != -1 and item|trim == "50-cloud-init.yaml" with_items: - "{{ netplan.stdout_lines }}" @@ -25,6 +23,11 @@ - systemd-networkd-wait-online when: systemd_networkd_active | bool +- name: Ensure systemd-networkd gets enabled for br0 + set_fact: + systemd_networkd_active: True + when: network_manager_active | bool and iiab_lan_iface == "br0" + # ICO will always set gui_static_wan_ip away from the default of 'unset' while # gui_static_wan turns dhcp on/off through wan_ip in computed_network and # overrides gui_static_wan_ip that is present. Changing wan_ip in local_vars @@ -39,12 +42,20 @@ wan_cidr: "{{ CIDR.stdout }}" when: wan_ip != "dhcp" -- name: Supply netplan template - template: - dest: /etc/netplan/01-iiab-config.yaml - src: network/netplan.j2 - backup: no - when: iiab_wan_iface != discovered_wireless_iface +- name: Remove stock netplan template + file: + state: absent + path: /etc/netplan/{{ item }} + when: netplan.stdout.find("yaml") != -1 and item|trim != "02-iiab-config.yaml" and wan_ip != "dhcp" + with_items: + - "{{ netplan.stdout_lines }}" + +#- name: Supply netplan template +# template: +# dest: /etc/netplan/01-iiab-config.yaml +# src: network/netplan.j2 +# backup: no +# when: iiab_wan_iface != discovered_wireless_iface and wan_ip != "dhcp" # should blow up here if we messed up the yml file #- name: Generate netplan config From 8751b33271fb56bc1817424b992dec5ad9e62b55 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 10:32:09 -0500 Subject: [PATCH 106/127] can't start hostapd when ap0 is in use needs reboot --- roles/network/tasks/restart.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index 0634bdc63..6cecec5c4 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -2,7 +2,8 @@ systemd: name: hostapd state: restarted - when: iiab_wireless_lan_iface is defined and hostapd_enabled and discovered_wireless_iface != iiab_wan_iface +# when: iiab_wireless_lan_iface is defined and hostapd_enabled and discovered_wireless_iface != iiab_wan_iface + when: hostapd_enabled and iiab_wireless_lan_iface is defined and discovered_wireless_iface == iiab_wireless_lan_iface - name: Start named service systemd: @@ -79,6 +80,6 @@ systemd: name: "{{ dhcp_service2 }}" state: restarted - when: not no_net_restart + when: not no_net_restart and discovered_wireless_iface == "none" #when: (iiab_network_mode != "Appliance") # Sufficient b/c br0 exists thanks to /etc/network/interfaces.d/iiab #when: iiab_network_mode != "Appliance" and iiab_wan_iface != discovered_wireless_iface From 3d4b23f2fe59f66dfc12ae441098ce6557762d14 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 19:28:51 -0500 Subject: [PATCH 107/127] exclude NM from touching ap0 --- roles/network/tasks/NM-debian.yml | 33 +++++++++++++------ .../network/templates/network/ap0-manage.conf | 3 ++ 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 roles/network/templates/network/ap0-manage.conf diff --git a/roles/network/tasks/NM-debian.yml b/roles/network/tasks/NM-debian.yml index 565a5d42e..7b3a356f5 100644 --- a/roles/network/tasks/NM-debian.yml +++ b/roles/network/tasks/NM-debian.yml @@ -3,26 +3,39 @@ include_tasks: down-debian.yml # provide keyfile layout like the XO's used way back. -- name: Create uuid for NM's keyfile store - shell: uuidgen - register: uuid_response +#- name: Create uuid for NM's keyfile store +# shell: uuidgen +# register: uuid_response -- name: Put the uuid in place - set_fact: - gen_uuid: "{{ uuid_response.stdout_lines[0] }}" +#- name: Put the uuid in place +# set_fact: +# gen_uuid: "{{ uuid_response.stdout_lines[0] }}" -- name: Copy manage.conf for NetworkManager +# systemd-networkd handles br0 except for Raspbian +- name: Remove stale br0 for NetworkManager + file: + dest: /etc/NetworkManager/system-connections/bridge-br0 + state: absent + +- name: Copy ap0-manage.conf for NetworkManager + template: + dest: /etc/NetworkManager/conf.d/ap0-manage.conf + src: network/ap0-manage.conf + mode: 0644 + when: wifi_up_down + +- name: Copy manage.conf for NetworkManager when wifi_up_down False template: dest: /etc/NetworkManager/conf.d/wifi-manage.conf src: network/manage.conf.j2 mode: 0644 when: discovered_wireless_iface != "none" and not wifi_up_down -- name: Remove br0 in Appliance Mode for NetworkManager +- name: Remove manage.conf for NetworkManager when wifi_up_down True file: - dest: /etc/NetworkManager/system-connections/bridge-br0 + dest: /etc/NetworkManager/conf.d/wifi-manage.conf state: absent -# when: iiab_network_mode == "Appliance" + when: wifi_up_down - name: Removing static for NetworkManager file: diff --git a/roles/network/templates/network/ap0-manage.conf b/roles/network/templates/network/ap0-manage.conf new file mode 100644 index 000000000..400832df1 --- /dev/null +++ b/roles/network/templates/network/ap0-manage.conf @@ -0,0 +1,3 @@ +# IIAB WiFi +[keyfile] +unmanaged-devices=interface-name:ap0 From 4ab0e6321419e67d84e2b4dc2caff778e1e0d8fc Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 19:31:51 -0500 Subject: [PATCH 108/127] wifi routines needed on non-rpi hardware --- roles/network/tasks/hostapd.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 8e12593c7..2905e6159 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -1,4 +1,4 @@ -- name: Turn off hostapd when not using ap0 and wifi gateway present +- name: Disable hostapd when not using ap0 and wifi gateway present set_fact: hostapd_enabled: False when: not wifi_up_down and discovered_wireless_iface == iiab_wan_iface @@ -8,10 +8,10 @@ register: current_host_channel when: discovered_wireless_iface != "none" -- name: Setting WiFi channel to {{ current_host_channel.stdout }} on RPi hardware +- name: Setting WiFi channel to {{ current_host_channel.stdout }} set_fact: host_channel: "{{ current_host_channel.stdout }}" - when: current_host_channel.stdout is defined and current_host_channel.stdout != "" and current_host_channel.stdout|int <= 13 and discovered_wireless_iface != "none" and rpi_model != "none" + when: current_host_channel.stdout is defined and current_host_channel.stdout != "" and current_host_channel.stdout|int <= 13 - name: Create /etc/hostapd/hostapd.conf from template template: @@ -104,7 +104,7 @@ - { 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 on RPi hardware +- name: Create networkd-dispatcher hook for hostapd template: owner: root group: root @@ -115,7 +115,7 @@ - { 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-disp', dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi' } - when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and wifi_up_down + when: systemd_networkd_active and discovered_wireless_iface != "none" and wifi_up_down - name: Remove networkd-dispatcher hook for hostapd on RPi hardware and not up/down file: From 325db43473557569797994c9c4e3d9cd82e10ba1 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 19:33:00 -0500 Subject: [PATCH 109/127] netplan - let backends handle static ip --- roles/network/tasks/netplan.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index 0d8663848..41d017180 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -32,15 +32,15 @@ # gui_static_wan turns dhcp on/off through wan_ip in computed_network and # overrides gui_static_wan_ip that is present. Changing wan_ip in local_vars # is a oneway street to static. -- name: Static IP computing CIDR - shell: netmask {{ wan_ip }}/{{ wan_netmask }} | awk -F "/" '{print $2}' - register: CIDR - when: wan_ip != "dhcp" +#- name: Static IP computing CIDR +# shell: netmask {{ wan_ip }}/{{ wan_netmask }} | awk -F "/" '{print $2}' +# register: CIDR +# when: wan_ip != "dhcp" -- name: Static IP setting CIDR - set_fact: - wan_cidr: "{{ CIDR.stdout }}" - when: wan_ip != "dhcp" +#- name: Static IP setting CIDR +# set_fact: +# wan_cidr: "{{ CIDR.stdout }}" +# when: wan_ip != "dhcp" - name: Remove stock netplan template file: From 63c64271af0def50caae76605c473605e7db1a13 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 30 Apr 2020 19:35:15 -0500 Subject: [PATCH 110/127] move netplan before hostapd to pick up set_fact sysd-netd-active --- roles/network/tasks/main.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index 4071d53f3..fe61a9c0f 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -47,6 +47,11 @@ include_tasks: squid.yml when: squid_install and FQDN_changed and iiab_stage|int == 9 +#preprep for backends +- name: Netplan in use on Ubuntu 18.04+ + include_tasks: netplan.yml + when: is_ubuntu and not is_ubuntu_16 + #### Start services - include_tasks: avahi.yml @@ -63,12 +68,6 @@ when: is_redhat | bool #and not installing -- name: Netplan in use on Ubuntu 18.04+ - include_tasks: netplan.yml - when: is_ubuntu and not is_ubuntu_16 - #when: is_ubuntu_18 | bool - #and not installing - - name: NetworkManager in use include_tasks: NM-debian.yml when: is_debuntu and network_manager_active From 117e40f5bc97a5ba8464aaa426558ba95dde4dfe Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 1 May 2020 00:05:35 -0500 Subject: [PATCH 111/127] hostapd.yml - missed rpi_model != 'none', touchups --- roles/network/tasks/hostapd.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 2905e6159..8800edc95 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -1,3 +1,9 @@ +- name: Unmask the Access Point 'hostapd' service + systemd: + name: hostapd + enabled: no + masked: no + - name: Disable hostapd when not using ap0 and wifi gateway present set_fact: hostapd_enabled: False @@ -73,7 +79,7 @@ group: root mode: 0755 -- name: Create dhcpcd hook for hostapd +- 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 @@ -82,7 +88,7 @@ mode: 0644 when: is_raspbian and wifi_up_down -- name: Remove dhcpcd hook for hostapd if WiFi is not split +- name: Remove dhcpcd hook for hostapd if WiFi is not split using ap0 file: path: /lib/dhcpcd/dhcpcd-hooks/50-hostapd state: absent @@ -104,7 +110,7 @@ - { 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 +- name: Create networkd-dispatcher hook for hostapd wifi_up_down True template: owner: root group: root @@ -117,7 +123,7 @@ - { src: 'hostapd/netd-disp', dest: '/etc/networkd-dispatcher/routable.d/iiab-wifi' } when: systemd_networkd_active and discovered_wireless_iface != "none" and wifi_up_down -- name: Remove networkd-dispatcher hook for hostapd on RPi hardware and not up/down +- name: Remove networkd-dispatcher hook wifi_up_down False file: path: "{{ item.dest }}" state: absent @@ -125,19 +131,11 @@ - { 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' } - when: systemd_networkd_active and discovered_wireless_iface != "none" and rpi_model != "none" and not wifi_up_down - -- 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 + when: systemd_networkd_active and discovered_wireless_iface != "none" and not wifi_up_down - name: Enable the Access Point 'hostapd' service systemd: name: hostapd - masked: no enabled: yes when: hostapd_enabled From f8a59b46bb0b17c77b5f941ab580dc0cb2541346 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 1 May 2020 20:02:05 -0500 Subject: [PATCH 112/127] legacy wifi installs needs iiab_wireless_lan_iface set also --- roles/network/tasks/detected_network.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml index 05c329dbe..c6d73192f 100644 --- a/roles/network/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -149,7 +149,7 @@ - name: Set iiab_wireless_lan_iface to {{ discovered_wireless_iface }} if not none set_fact: iiab_wireless_lan_iface: "{{ discovered_wireless_iface }}" - when: discovered_wireless_iface != "none" and discovered_wireless_iface != iiab_wan_iface + when: discovered_wireless_iface != "none" and not wifi_up_down - name: Set iiab_wireless_lan_iface to ap0 if WiFi device is present set_fact: From 784d89d3a9390962f68ac1588e1a4f6911a994c8 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 1 May 2020 20:51:28 -0500 Subject: [PATCH 113/127] default manage.conf to enabled for wifi installs --- roles/network/templates/network/manage.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/templates/network/manage.conf.j2 b/roles/network/templates/network/manage.conf.j2 index fb5c25f55..ddd857e52 100644 --- a/roles/network/templates/network/manage.conf.j2 +++ b/roles/network/templates/network/manage.conf.j2 @@ -1,4 +1,4 @@ # IIAB WiFi [device] match-device=interface-name:{{ discovered_wireless_iface }} -managed=0 +managed=1 From 9ee93d7e0178bab9bd23ce6af804ffc7a561c916 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 1 May 2020 21:22:41 -0500 Subject: [PATCH 114/127] sysd-netd-debian - split unmask/enable and restart --- roles/network/tasks/sysd-netd-debian.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index c10b015fb..c153f2116 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -1,4 +1,10 @@ # sysd-netd-debian.yml +- name: Unmask and enable the systemd-networkd service + systemd: + name: systemd-networkd + enabled: yes + masked: no + - name: Copy the bridge script - Creates br0 template: dest: /etc/systemd/network/IIAB-Bridge.netdev @@ -54,8 +60,6 @@ - name: Restart the systemd-networkd service systemd: name: systemd-networkd - enabled: yes - masked: no state: restarted #when: (netplan.stdout is undefined or netplan.stdout.find("yaml") == -1) and not no_net_restart when: not no_net_restart From e9f9364a90bf77b79012cdbd12d613010a3d0e0d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 1 May 2020 21:35:49 -0500 Subject: [PATCH 115/127] netplan needs the unmasking|enable for sysd-netd --- roles/network/tasks/netplan.yml | 7 +++++++ roles/network/tasks/sysd-netd-debian.yml | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index 41d017180..0eb96166b 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -23,6 +23,13 @@ - systemd-networkd-wait-online when: systemd_networkd_active | bool +- name: Unmask and enable the systemd-networkd service for br0 + systemd: + name: systemd-networkd + enabled: yes + masked: no + when: network_manager_active | bool and iiab_lan_iface == "br0" + - name: Ensure systemd-networkd gets enabled for br0 set_fact: systemd_networkd_active: True diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index c153f2116..a1a904cfa 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -1,10 +1,4 @@ # sysd-netd-debian.yml -- name: Unmask and enable the systemd-networkd service - systemd: - name: systemd-networkd - enabled: yes - masked: no - - name: Copy the bridge script - Creates br0 template: dest: /etc/systemd/network/IIAB-Bridge.netdev From e027dbe2507656fb1fe87ec3a7d401ba21f7e515 Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 2 May 2020 03:21:59 -0400 Subject: [PATCH 116/127] Update local_vars_big.yml --- vars/local_vars_big.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/local_vars_big.yml b/vars/local_vars_big.yml index 24f67e278..e69e4c303 100644 --- a/vars/local_vars_big.yml +++ b/vars/local_vars_big.yml @@ -46,8 +46,8 @@ host_wifi_mode: g host_channel: 6 hostapd_secure: False hostapd_password: changeme -wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet - # as well as classroom hotspot, use iiab_gateway_enabled for pass through +wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet + # as well as classroom hotspot, use iiab_gateway_enabled for pass through # See "How do I set a static IP address?" for Ethernet, in http://FAQ.IIAB.IO wan_ip: dhcp # wan_ip: 192.168.1.99 From a38eaabd093037ebdb7681b8627176335cdfbc5e Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 2 May 2020 03:22:46 -0400 Subject: [PATCH 117/127] Update local_vars_medium.yml --- vars/local_vars_medium.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/local_vars_medium.yml b/vars/local_vars_medium.yml index d43af20dc..d2a33a1a6 100644 --- a/vars/local_vars_medium.yml +++ b/vars/local_vars_medium.yml @@ -46,8 +46,8 @@ host_wifi_mode: g host_channel: 6 hostapd_secure: False hostapd_password: changeme -wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet - # as well as classroom hotspot, use iiab_gateway_enabled for pass through +wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet + # as well as classroom hotspot, use iiab_gateway_enabled for pass through # See "How do I set a static IP address?" for Ethernet, in http://FAQ.IIAB.IO wan_ip: dhcp # wan_ip: 192.168.1.99 From 8eed1c0c25812a3ee41768a0f4140b8426508b9a Mon Sep 17 00:00:00 2001 From: A Holt Date: Sat, 2 May 2020 03:23:14 -0400 Subject: [PATCH 118/127] Update local_vars_min.yml --- vars/local_vars_min.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/local_vars_min.yml b/vars/local_vars_min.yml index 2f982d59b..eb8cb8ca3 100644 --- a/vars/local_vars_min.yml +++ b/vars/local_vars_min.yml @@ -46,8 +46,8 @@ host_wifi_mode: g host_channel: 6 hostapd_secure: False hostapd_password: changeme -wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet - # as well as classroom hotspot, use iiab_gateway_enabled for pass through +wifi_up_down: True # Creates a second virtual wifi adapter for WiFi upstream to internet + # as well as classroom hotspot, use iiab_gateway_enabled for pass through # See "How do I set a static IP address?" for Ethernet, in http://FAQ.IIAB.IO wan_ip: dhcp # wan_ip: 192.168.1.99 From c2730635a64d229c53c483925ecc3b3b3cd68a07 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 3 May 2020 14:00:20 -0500 Subject: [PATCH 119/127] override 'vars' if the hardware is not present --- roles/network/tasks/hostapd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 8800edc95..5ce1ff2e2 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -4,10 +4,10 @@ enabled: no masked: no -- name: Disable hostapd when not using ap0 and wifi gateway present +- name: Disable hostapd when not using ap0 and wifi gateway present or no WiFi hardware present set_fact: hostapd_enabled: False - when: not wifi_up_down and discovered_wireless_iface == iiab_wan_iface + when: (not wifi_up_down and discovered_wireless_iface == iiab_wan_iface) or discovered_wireless_iface == "none" - name: Detect current Wifi channel shell: iw {{ discovered_wireless_iface }} info | grep channel | cut -d' ' -f2 From 5bd975db5e9b7f9d12f189b4cad0ac3466dc8b2b Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 3 May 2020 14:02:14 -0500 Subject: [PATCH 120/127] the intent is to not restart hostapd during wifi installs --- roles/network/tasks/restart.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index 6cecec5c4..f75b27dae 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -1,9 +1,14 @@ -- name: Restart hostapd when WiFi is present +#iiab_wireless_lan_iface(wlan0) - wifi_up_down False needs hw +#iiab_wireless_lan_iface(ap0) - wifi_up_down True needs hw +#hostapd_enabled False - set in hostapd.yml to avoid the enable with wifi_up_down False +#no_net_restart: True - main.yml discovered_wireless_iface == iiab_wan_iface +- name: Restart hostapd when WiFi is present but not when using WiFi as gateway systemd: name: hostapd state: restarted # when: iiab_wireless_lan_iface is defined and hostapd_enabled and discovered_wireless_iface != iiab_wan_iface - when: hostapd_enabled and iiab_wireless_lan_iface is defined and discovered_wireless_iface == iiab_wireless_lan_iface +# when: hostapd_enabled and iiab_wireless_lan_iface is defined and discovered_wireless_iface == iiab_wireless_lan_iface + when: hostapd_enabled and not no_net_restart - name: Start named service systemd: From b1f6c8176e98fcf32d631c349e0d8b24fd39f9c2 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 3 May 2020 19:18:20 -0500 Subject: [PATCH 121/127] for the most part restart dnsmasq --- roles/network/tasks/restart.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index f75b27dae..6aa34c733 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -81,10 +81,13 @@ state: restarted when: hostapd_enabled and wifi_slave.stdout is defined and wifi_slave.stdout == 0 +#both interfaces.d and systemd-networkd should have br0 available and Appliance lacks br0 - name: User choice of dnsmasq or dhcpd - restarting {{ dhcp_service2 }} systemd: name: "{{ dhcp_service2 }}" state: restarted - when: not no_net_restart and discovered_wireless_iface == "none" + when: (not no_net_restart and not wifi_up_down) or wifi_up_down #when: (iiab_network_mode != "Appliance") # Sufficient b/c br0 exists thanks to /etc/network/interfaces.d/iiab #when: iiab_network_mode != "Appliance" and iiab_wan_iface != discovered_wireless_iface +#keep an eye on legacy wifi installs where br0 is present but not 'online' with an ip address +#due to hostapd didn't go to a carrier state. All others should get dnsmasq restarted From 5c402848dd8bbd3bfb02c7efcf374a834a6a5ecd Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 4 May 2020 12:11:26 -0500 Subject: [PATCH 122/127] just restart systemd-networkd --- roles/network/tasks/sysd-netd-debian.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/roles/network/tasks/sysd-netd-debian.yml b/roles/network/tasks/sysd-netd-debian.yml index a1a904cfa..1b652e831 100644 --- a/roles/network/tasks/sysd-netd-debian.yml +++ b/roles/network/tasks/sysd-netd-debian.yml @@ -55,5 +55,3 @@ systemd: name: systemd-networkd state: restarted - #when: (netplan.stdout is undefined or netplan.stdout.find("yaml") == -1) and not no_net_restart - when: not no_net_restart From 9142cde8ff82310e4ff7777cb584f044e007e58b Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 4 May 2020 15:32:34 -0400 Subject: [PATCH 123/127] Update roles/network/tasks/restart.yml --- roles/network/tasks/restart.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index 6aa34c733..c87609893 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -86,7 +86,7 @@ systemd: name: "{{ dhcp_service2 }}" state: restarted - when: (not no_net_restart and not wifi_up_down) or wifi_up_down + when: (not no_net_restart) or wifi_up_down #when: (iiab_network_mode != "Appliance") # Sufficient b/c br0 exists thanks to /etc/network/interfaces.d/iiab #when: iiab_network_mode != "Appliance" and iiab_wan_iface != discovered_wireless_iface #keep an eye on legacy wifi installs where br0 is present but not 'online' with an ip address From ffe33ac76dc588a370a5e9f4e9e6f70782061caa Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 4 May 2020 15:32:43 -0400 Subject: [PATCH 124/127] Update roles/network/tasks/hostapd.yml --- roles/network/tasks/hostapd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 5ce1ff2e2..8ecd42cd1 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -4,7 +4,7 @@ enabled: no masked: no -- name: Disable hostapd when not using ap0 and wifi gateway present or no WiFi hardware present +- name: Disable hostapd when not using ap0 and wifi gateway present, or no WiFi hardware present set_fact: hostapd_enabled: False when: (not wifi_up_down and discovered_wireless_iface == iiab_wan_iface) or discovered_wireless_iface == "none" From 37d11413715689dc93c674dbc1e66a3a1acb5622 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 5 May 2020 14:56:09 -0400 Subject: [PATCH 125/127] Calibre-Web 0.6.6 -> 0.6.7 --- roles/calibre-web/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/calibre-web/defaults/main.yml b/roles/calibre-web/defaults/main.yml index 4403d1e32..51f05937f 100644 --- a/roles/calibre-web/defaults/main.yml +++ b/roles/calibre-web/defaults/main.yml @@ -14,7 +14,7 @@ # All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! -calibreweb_version: 0.6.6 # WAS: master, 0.6.4, 0.6.5 +calibreweb_version: 0.6.7 # WAS: master, 0.6.4, 0.6.5 calibreweb_venv_path: /usr/local/calibre-web-py3 calibreweb_exec_path: "{{ calibreweb_venv_path }}/cps.py" From 34da31d81c979acc94a02f3827c65af3c0fc8be2 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 5 May 2020 14:58:21 -0400 Subject: [PATCH 126/127] Update main.yml --- roles/calibre-web/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/calibre-web/defaults/main.yml b/roles/calibre-web/defaults/main.yml index 51f05937f..70a67d517 100644 --- a/roles/calibre-web/defaults/main.yml +++ b/roles/calibre-web/defaults/main.yml @@ -14,7 +14,7 @@ # All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! -calibreweb_version: 0.6.7 # WAS: master, 0.6.4, 0.6.5 +calibreweb_version: 0.6.7 # WAS: master, 0.6.4, 0.6.5, 0.6.7 calibreweb_venv_path: /usr/local/calibre-web-py3 calibreweb_exec_path: "{{ calibreweb_venv_path }}/cps.py" From 927ad1b176c58119e56fc04861bf18a105019344 Mon Sep 17 00:00:00 2001 From: A Holt Date: Thu, 7 May 2020 10:02:49 -0400 Subject: [PATCH 127/127] Ansible comment --- roles/2-common/tasks/udev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/2-common/tasks/udev.yml b/roles/2-common/tasks/udev.yml index 2e16038d2..618c414b1 100644 --- a/roles/2-common/tasks/udev.yml +++ b/roles/2-common/tasks/udev.yml @@ -34,7 +34,7 @@ state: restarted when: udev_unit.stat.exists is defined and udev_unit.stat.exists -- name: Enable the udev-reload service during boot. +- name: Enable the udev-reload service during boot systemd: name: udev-reload enabled: yes