Files
dsfin-ansible/roles/wifi/tasks/main.yaml
2019-03-20 12:21:49 -04:00

96 lines
2.0 KiB
YAML
Executable File

---
- name: Remove wpasupplicant package
become: yes
apt:
name: ['wpasupplicant']
state: absent
purge: true
tags: wireless_ap
- name: configure wlan0
blockinfile:
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
apt:
name: ['hostapd']
state: present
tags: wireless_ap
- name: configure hostapd
become: true
template:
src: "{{ role_path }}/templates/hostapd.conf.j2"
dest: "/etc/hostapd/hostapd.conf
owner: root
group: root
backup: yes
tags: wireless_ap
- name: enable hostapd
become: true
systemd:
name: hostapd
enabled: yes
masked: no
state: restarted
tags: wireless_ap
- name: install dnsmasq
become: true
apt:
name: ['dnsmasq']
state: present
tags: wireless_ap
- name: configure dnsmasq
become: true
copy:
src: "{{ role_path }}/files/dnsmasq.conf"
dest: "/etc/dnsmasq.conf"
backup: yes
owner: root
group: root
tags: wireless_ap
- name: enable dnsmasq
become: true
systemd:
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
tags: wireless_ap
- name: copy fw config
become: true
copy:
src: "{{ role_path }}/files/iptables.ipv4.nat"
dest: "/etc/iptables.ipv4.nat"
backup: yes
owner: root
group: root
tags: wireless_ap
- name: iptables-restore to rc.local
lineinfile:
path: "/etc/rc.local"
state: present
insertbefore: "exit 0"
line: "iptables-restore < /etc/iptables.ipv4.nat"
become: true
tags: wireless_ap
- name: restart dhcpcd
become: true
systemd:
name: dhcpcd
enabled: yes
masked: no
state: restarted
tags: wireless_ap