diff --git a/roles/1-prep/tasks/hardware.yml b/roles/1-prep/tasks/hardware.yml index edf9bb284..c397223e2 100644 --- a/roles/1-prep/tasks/hardware.yml +++ b/roles/1-prep/tasks/hardware.yml @@ -23,6 +23,22 @@ ## DISCOVER PLATFORMS ###### # Put conditional actions for hardware platforms here +- name: Look for any wireless devices present + shell: "ls -la /sys/class/net/*/phy80211 | awk -F / '{print $5}'" + register: has_wifi_device + ignore_errors: True + changed_when: False + +- name: Set has_wireless, if found + set_fact: + has_wireless: True + when: has_wifi_device.stdout is defined and item|trim != "" + with_items: + - "{{ has_wifi_device.stdout_lines }}" + +- include_tasks: wifi.yml + when: has_wireless is defined + - include_tasks: raspberry_pi.yml when: first_run and rpi_model != "none" diff --git a/roles/1-prep/tasks/raspberry_pi.yml b/roles/1-prep/tasks/raspberry_pi.yml index aa71ff426..90a312521 100644 --- a/roles/1-prep/tasks/raspberry_pi.yml +++ b/roles/1-prep/tasks/raspberry_pi.yml @@ -38,29 +38,18 @@ - name: '2021-07-27: SEE ALSO 4-5 networking packages LATER installed by https://github.com/iiab/iiab/blob/master/roles/2-common/tasks/network.yml' meta: noop -# 2021-07-27 explanation from @jvonau: The 3 BELOW (iw, rfkill, wireless-tools) -# are provided by RasPiOS. Ubuntu|Debian on the other hand are hit or miss: -# desktops might have some/all 3 preinstalled, while servers tend not to have -# these present at all, but are needed to be installed if you want to take full -# advantage of WiFi on Ubuntu and friends -- but it's only enforced on RPi -# hardware where we know in advance of the likelihood of WiFi being present. - # 2022-03-15: This section is effectively now useless on RasPiOS (but apparently # serves a purpose on Ubuntu on RPi, where it installs dphys-swapfile and # fake-hwclock). Still: @jvonau's above explanation of other OS's / other HW # suggest this code should possibly move in future, to helps others too? -- name: 'Install packages: dphys-swapfile, fake-hwclock, iw, rfkill, wireless-tools' +- name: 'Install packages: dphys-swapfile, fake-hwclock' package: name: - dphys-swapfile # 2021-03-15: For Ubuntu on RPi? RasPiOS installs this regardless -- autogenerate and use a swap file - fake-hwclock # 2021-03-15: For Ubuntu on RPi? RasPiOS installs this regardless -- save/restore system clock on machines without working RTC hardware - - iw # 2021-07-27: RasPiOS installs this regardless -- configure Linux wireless devices -- hard dependence for ap0 creation, SEE https://github.com/iiab/iiab/blob/master/roles/network/templates/hostapd/iiab-clone-wifi.service.j2 - - rfkill # 2021-07-27: RasPiOS installs this regardless -- enable & disable wireless devices - - wireless-tools # 2021-07-27: RasPiOS installs this regardless -- manipulate Linux Wireless Extensions state: present - - name: Increase swap file size (to CONF_SWAPSIZE={{ pi_swap_file_size }} in /etc/dphys-swapfile) as kalite pip download fails lineinfile: path: /etc/dphys-swapfile diff --git a/roles/1-prep/tasks/wifi.yml b/roles/1-prep/tasks/wifi.yml new file mode 100644 index 000000000..f246fbea0 --- /dev/null +++ b/roles/1-prep/tasks/wifi.yml @@ -0,0 +1,13 @@ +# 2021-07-27 explanation from @jvonau: The 3 BELOW (iw, rfkill, wireless-tools) +# are provided by RaspiOS. Ubuntu|Debian on the other hand are hit or miss: +# desktops might have some/all 3 preinstalled, while servers tend not to have +# these present at all, but are needed to be installed if you want to take full +# advantage of WiFi on Ubuntu and friends + +- name: 'Install packages: iw, rfkill, wireless-tools' + package: + name: + - iw # 2021-07-27: RaspiOS installs this regardless -- configure Linux wireless devices -- hard dependence for ap0 creation, SEE https://github.com/iiab/iiab/blob/master/roles/network/templates/hostapd/iiab-clone-wifi.service.j2 + - rfkill # 2021-07-27: RaspiOS installs this regardless -- enable & disable wireless devices + - wireless-tools # 2021-07-27: RaspiOS installs this regardless -- manipulate Linux Wireless Extensions + state: present