summaryrefslogtreecommitdiff
path: root/ansible/roles/hotspot
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles/hotspot')
-rw-r--r--ansible/roles/hotspot/defaults/main.yml17
-rw-r--r--ansible/roles/hotspot/files/hostapd1
-rw-r--r--ansible/roles/hotspot/handlers/main.yml5
-rw-r--r--ansible/roles/hotspot/tasks/main.yml15
-rw-r--r--ansible/roles/hotspot/templates/hostapd.conf.j220
5 files changed, 58 insertions, 0 deletions
diff --git a/ansible/roles/hotspot/defaults/main.yml b/ansible/roles/hotspot/defaults/main.yml
new file mode 100644
index 0000000..a413af9
--- /dev/null
+++ b/ansible/roles/hotspot/defaults/main.yml
@@ -0,0 +1,17 @@
+# Your network SSID
+ssid: Caprica
+# Your country code
+country: FI
+# Your passphrase
+passphrase: "{{ lookup('pipe', 'pass show office_network/wifi') }}"
+# Wireless device, check `iwconfig`
+interface: wlan0
+# Set if interface is a bridge, leave empty otherwise
+bridge: br0
+# IEEE 802.11 operation mode
+# Supported modes: a, b, g, ad
+mode: g
+# Enable 802.11n, if supported by chipset
+ieee80211n: 1
+# Channel to use, check `iw list`
+channel: 2
diff --git a/ansible/roles/hotspot/files/hostapd b/ansible/roles/hotspot/files/hostapd
new file mode 100644
index 0000000..b63c3ae
--- /dev/null
+++ b/ansible/roles/hotspot/files/hostapd
@@ -0,0 +1 @@
+DAEMON_CONF="/etc/hostapd/hostapd.conf"
diff --git a/ansible/roles/hotspot/handlers/main.yml b/ansible/roles/hotspot/handlers/main.yml
new file mode 100644
index 0000000..05dfcd6
--- /dev/null
+++ b/ansible/roles/hotspot/handlers/main.yml
@@ -0,0 +1,5 @@
+- name: restart hostapd
+ service: name=hostapd state=restarted enabled=yes
+
+- name: restart dnsmasq
+ service: name=dnsmasq state=restarted
diff --git a/ansible/roles/hotspot/tasks/main.yml b/ansible/roles/hotspot/tasks/main.yml
new file mode 100644
index 0000000..b2be8ee
--- /dev/null
+++ b/ansible/roles/hotspot/tasks/main.yml
@@ -0,0 +1,15 @@
+- name: install hotspot dependencies
+ apt: name={{ item }} state=present
+ with_items:
+ - firmware-ralink
+ - iw
+ - wireless-tools
+ - hostapd
+
+- name: copy hostapd conf
+ template: src=hostapd.conf.j2 dest=/etc/hostapd/hostapd.conf
+ notify: restart hostapd
+
+- name: copy default hostapd conf
+ copy: src=hostapd dest=/etc/default/hostapd
+ notify: restart hostapd
diff --git a/ansible/roles/hotspot/templates/hostapd.conf.j2 b/ansible/roles/hotspot/templates/hostapd.conf.j2
new file mode 100644
index 0000000..83ff514
--- /dev/null
+++ b/ansible/roles/hotspot/templates/hostapd.conf.j2
@@ -0,0 +1,20 @@
+# hostapd sample config with documentation:
+# http://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
+interface={{ interface }}
+bridge={{ bridge }}
+driver=nl80211
+ssid={{ ssid }}
+country_code={{ country }}
+hw_mode={{ mode }}
+ieee80211n={{ ieee80211n }}
+channel={{ channel }}
+macaddr_acl=0
+auth_algs=1
+ignore_broadcast_ssid=0
+wmm_enabled=1
+# bit1: WPA2 only
+wpa=1
+wpa_passphrase={{ passphrase }}
+wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256
+wpa_pairwise=TKIP
+rsn_pairwise=CCMP