2017-05-27 18:09:50 +00:00
# rpi_debian.yml
2017-10-19 06:33:02 +00:00
# Start out making simplifying assumptions
2017-05-27 18:09:50 +00:00
# 1. we are dealing with a rpi3
# 2. Gui inputs define the config -- auto config is more difficult
# a. gui_desired_network_role
# b. hostapd_enabled
2017-10-19 06:33:02 +00:00
# c. gui_static_wan_ip
2017-11-22 19:10:53 +00:00
# 3. In appliance mode: wan is either wired dhcp/static or wlan0 and hostapd off
2017-05-27 18:09:50 +00:00
# 4. In lan_controller: wan is off, eth0 and wlan0 under br0
2017-11-22 19:10:53 +00:00
# 5. In gateway: user gateway is wan, and wlan0 under br0 if not acting as
# the gateway
- name : Supply resolvconf.conf
template :
dest : /etc/resolvconf.conf
src : network/resolvconf.j2
- name : Supply dhcpcd.conf
template :
dest : /etc/dhcpcd.conf
src : network/dhcpcd.conf.j2
2022-10-05 13:23:34 +00:00
- name : Create dhcpcd hook for hostapd and ap0 when wifi_up_down True
template :
src : hostapd/50-hostapd
dest : /lib/dhcpcd/dhcpcd-hooks/50-hostapd
owner : root
group : root
mode : 0644
when : wifi_up_down
- name : Remove dhcpcd hook for hostapd if WiFi is not split using ap0
file :
path : /lib/dhcpcd/dhcpcd-hooks/50-hostapd
state : absent
when : not wifi_up_down
2018-10-09 21:21:25 +00:00
- name : New Raspbian requires country code -- check for it
2022-04-16 00:21:53 +00:00
shell : grep country /etc/wpa_supplicant/wpa_supplicant.conf | awk -F = '{print $2}'
2018-03-29 20:39:20 +00:00
register : country_code
2018-03-30 00:17:56 +00:00
ignore_errors : True
2023-04-23 13:02:57 +00:00
when : wifi_up_down and can_be_ap
2018-03-29 20:39:20 +00:00
2022-04-14 13:21:41 +00:00
- name : Set country code for hostapd to value found in /etc/wpa_supplicant/wpa_supplicant.conf
set_fact :
host_country_code : "{{ country_code.stdout }}"
2023-04-26 22:57:05 +00:00
when : country_code.stdout is defined and country_code.stdout | length > 0
2022-04-14 13:21:41 +00:00
2018-10-09 21:21:25 +00:00
- name : Put country code ({{ host_country_code }}) in /etc/wpa_supplicant/wpa_supplicant.conf if nec
2022-07-08 06:16:36 +00:00
lineinfile :
2018-10-09 21:21:25 +00:00
path : /etc/wpa_supplicant/wpa_supplicant.conf
2018-03-29 20:39:20 +00:00
regexp : "^country.*"
line : country={{ host_country_code }}
2023-04-26 22:57:05 +00:00
when : country_code.stdout is defined and country_code.stdout | length == 0
2018-03-30 00:17:56 +00:00
2023-04-23 13:02:57 +00:00
# This should go away, should only be unblocked by raspi-config
2018-10-09 21:21:25 +00:00
- name : Enable the WiFi with rfkill
2018-03-30 00:17:56 +00:00
shell : rfkill unblock 0
ignore_errors : True
2018-03-29 20:39:20 +00:00
2017-11-22 19:10:53 +00:00
- name : Copy the bridge script for RPi
template :
dest : /etc/network/interfaces.d/iiab
2019-02-05 17:56:51 +00:00
src : network/rpi.j2
2019-02-05 18:10:19 +00:00
#src: network/iiab.j2 2019-02-05: caused ./iiab-network to fail repeatedly in recent days on one particular RPi 3, even after reboot ("Unable to start service networking: Job for networking.service failed..." at "Restart the networking service if appropriate") ...leaving dnsmasq off (#1452)
2020-07-24 03:41:39 +00:00
when : iiab_wired_lan_iface is defined
- name : Use bind-dynamic for dnsmasq
template :
dest : /etc/dnsmasq.d/dnsmasq-iiab
src : network/dnsmasq-iiab
2017-11-22 19:10:53 +00:00
when : iiab_lan_iface == "br0"
2022-07-08 06:16:36 +00:00
#- name: Stopping services
# include_tasks: down-debian.yml
2017-11-22 19:10:53 +00:00
- name : Reload systemd
2018-04-07 21:45:04 +00:00
systemd :
daemon_reload : yes
2017-05-27 18:09:50 +00:00
2017-12-29 06:08:01 +00:00
- name : Restart the networking service if appropriate
2020-05-04 12:57:40 +00:00
systemd :
2017-11-22 19:10:53 +00:00
name : networking
enabled : yes
state : restarted
2020-07-24 03:41:39 +00:00
when : iiab_wired_lan_iface is defined
2020-05-06 19:51:40 +00:00
2020-05-07 13:47:47 +00:00
#- name: Stop wpa_supplicant on Raspbian
# shell: killall wpa_supplicant
2020-05-06 19:51:40 +00:00
# now pick up denyinterfaces and respawn wpa_supplicant
- name : Restart dhcpcd on Raspbian
systemd :
name : dhcpcd
state : restarted