ansible/roles/wifi/tasks/main.yml

52 lines
1.2 KiB
YAML
Raw Normal View History

2022-09-04 17:25:14 +02:00
---
2022-08-31 17:06:51 +02:00
- name: install wpa-supplicant (alpine)
apk:
name: wpa_supplicant
when: ansible_distribution == "Alpine"
- name: create wpa_supplicant.conf
shell:
cmd: |
wpa_passphrase "{{ wifi_ssid }}" "{{ wifi_psk }}" \
> /etc/wpa_supplicant/wpa_supplicant.conf
creates: /etc/wpa_supplicant/wpa_supplicant.conf
- name: add wifi interface
blockinfile:
path: /etc/network/interfaces
block: |
auto wlan0
iface wlan0 inet dhcp
- name: enable wpa_supplicant at boot
service:
name: wpa_supplicant
state: started
2022-09-04 17:25:14 +02:00
enabled: true
2022-08-31 17:06:51 +02:00
runlevel: boot
when: ansible_distribution == "Alpine"
- name: enable networking at boot
service:
name: networking
state: started
2022-09-04 17:25:14 +02:00
enabled: true
2022-08-31 17:06:51 +02:00
runlevel: boot
when: ansible_distribution == "Alpine"
- name: add config block to enable reconnection when wifi signal is lost
blockinfile:
path: /etc/wpa_supplicant/wpa_supplicant.conf
block: |
ap_scan=1
autoscan=periodic:10
disable_scan_offload=1
- name: enable wpa_cli at boot
service:
name: wpa_cli
state: started
2022-09-04 17:25:14 +02:00
enabled: true
2022-08-31 17:06:51 +02:00
runlevel: boot
when: ansible_distribution == "Alpine"