main
Ricard Illa 2022-08-31 17:06:51 +02:00
parent af7737e82d
commit ba275638c2
3 changed files with 60 additions and 0 deletions

View File

@ -6,6 +6,7 @@
- basic - basic
- users - users
- sshd - sshd
- wifi
vars: vars:
users: users:
- rilla - rilla

50
roles/wifi/tasks/main.yml Normal file
View File

@ -0,0 +1,50 @@
- 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
enabled: yes
runlevel: boot
when: ansible_distribution == "Alpine"
- name: enable networking at boot
service:
name: networking
state: started
enabled: yes
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
enabled: yes
runlevel: boot
when: ansible_distribution == "Alpine"

9
roles/wifi/vars/main.yml Normal file
View File

@ -0,0 +1,9 @@
wifi_ssid: CocoPeach
wifi_psk: !vault |
$ANSIBLE_VAULT;1.1;AES256
36313431343136353065616132333266376661613062646231336632393061323039643931353033
3263383336386461373433373437623831386233366565300a666439313931326434303133613030
35336237353762633634646263353466353930326631353235373635333736343765656336346130
3661656334626234660a653661343830666466316334646339386364666438326131396465383066
30646163396134333661613138656632633330633864316238616136643038323038