summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-03 19:55:36 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-03 20:18:41 +0100
commit513abeec351a66f97be47805cfee8f3f2fa45181 (patch)
tree73c8ab36e86116b49749b83a9e85a48c6e1f8508
parentRework syslinux. (diff)
downloadwebdav_server-513abeec351a66f97be47805cfee8f3f2fa45181.tar.gz
webdav_server-513abeec351a66f97be47805cfee8f3f2fa45181.tar.xz
Add wpa_supplicant.
-rw-r--r--modules/wpa_supplicant/manifests/init.pp6
-rw-r--r--modules/wpa_supplicant/manifests/interface.pp19
-rw-r--r--modules/wpa_supplicant/templates/wpa_supplicant.conf.epp15
3 files changed, 40 insertions, 0 deletions
diff --git a/modules/wpa_supplicant/manifests/init.pp b/modules/wpa_supplicant/manifests/init.pp
new file mode 100644
index 0000000..3125f6c
--- /dev/null
+++ b/modules/wpa_supplicant/manifests/init.pp
@@ -0,0 +1,6 @@
+class wpa_supplicant (
+ String $ctrl_interface = '/run/wpa_supplicant',
+ Hash[String,Hash] $interfaces = {},
+) {
+ create_resources(wpa_supplicant::interface, $interfaces)
+}
diff --git a/modules/wpa_supplicant/manifests/interface.pp b/modules/wpa_supplicant/manifests/interface.pp
new file mode 100644
index 0000000..8254359
--- /dev/null
+++ b/modules/wpa_supplicant/manifests/interface.pp
@@ -0,0 +1,19 @@
+define wpa_supplicant::interface (
+ String $interface = $name,
+ Array[Hash] $networks = [],
+) {
+ service { "wpa_supplicant@${interface}.service":
+ ensure => running,
+ enable => true,
+ }
+
+ file { "/etc/wpa_supplicant/wpa_supplicant-${interface}.conf":
+ ensure => file,
+ content => epp('wpa_supplicant/wpa_supplicant.conf.epp', {
+ networks => $networks
+ }),
+ } ~> exec { "Reload wpa_supplicant for ${interface}":
+ command => [ 'wpa_cli', 'reconfigure', '-i', $interface, ],
+ path => [ '/bin', '/usr/bin', ],
+ }
+}
diff --git a/modules/wpa_supplicant/templates/wpa_supplicant.conf.epp b/modules/wpa_supplicant/templates/wpa_supplicant.conf.epp
new file mode 100644
index 0000000..48680bb
--- /dev/null
+++ b/modules/wpa_supplicant/templates/wpa_supplicant.conf.epp
@@ -0,0 +1,15 @@
+<%- | Array[Hash] $networks | -%>
+# FILE MANAGED BY PUPPET
+
+ctrl_interface=DIR=<%= $wpa_supplicant::ctrl_interface %> GROUP=wheel
+update_config=0
+ap_scan=1
+eapol_version=2
+
+<% $networks.each |$network| { %>
+network={
+ <%- $network.each |$k, $v| { -%>
+ <%= $k %>=<%= $v %>
+ <%- } -%>
+}
+<% } %>