diff --git a/roles/wifi/tasks/main.yaml b/roles/wifi/tasks/main.yaml index a7c5d03..e39b9e4 100755 --- a/roles/wifi/tasks/main.yaml +++ b/roles/wifi/tasks/main.yaml @@ -7,12 +7,13 @@ purge: true tags: wireless_ap - name: configure wlan0 + become: true blockinfile: - path: /etc/dhcpcd.conf - block: | - interface wlan0 - static ip_address=10.250.250.1/29 - nohook wpa_supplicant + path: /etc/dhcpcd.conf + block: | + interface wlan0 + static ip_address=10.250.250.1/29 + nohook wpa_supplicant tags: wireless_ap - name: install hostapd become: true @@ -24,11 +25,22 @@ become: true template: src: "{{ role_path }}/templates/hostapd.conf.j2" - dest: "/etc/hostapd/hostapd.conf + dest: "/etc/hostapd/hostapd.conf" owner: root group: root backup: yes tags: wireless_ap +- name: configure hostapd startup + become: true + tags: wireless_ap + lineinfile: + state: present + path: "{{ item.path }}" + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" + with_items: + - { path: "/etc/init.d/hostapd", regexp: "^DAEMON_CONF=", line: "DAEMON_CONF=/etc/hostapd/hostapd.conf" } + - { path: "/etc/default/hostapd", regexp: "^#DAEMON_CONF=", line: "DAEMON_CONF=\"/etc/hostapd/hostapd.conf\"" } - name: enable hostapd become: true systemd: @@ -55,19 +67,19 @@ - name: enable dnsmasq become: true systemd: - name: dnsmasq - enabled: yes - masked: no - state: restarted + name: dnsmasq + enabled: yes + masked: no + state: restarted tags: wireless_ap - name: enable ipv4.forwarding - lineinfile: - path: "/etc/sysctl.conf" - state: present - regexp: '^#net\.ipv4\.ip_forward=1' - line: 'net.ipv4.ip_forward=1' - validate: 'sysctl -p' become: true + sysctl: + name: net.ipv4.ip_forward + value: 1 + sysctl_set: yes + state: present + reload: yes tags: wireless_ap - name: copy fw config become: true @@ -93,4 +105,4 @@ enabled: yes masked: no state: restarted - tags: wireless_ap \ No newline at end of file + tags: wireless_ap