diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-03 19:55:36 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-03 20:18:41 +0100 |
commit | f207e3ccc89c85bd4131003af94bec0fe0dc32a2 (patch) | |
tree | bb3067797f7feaa8efbdcd129c51411aa7e301d7 | |
download | wpa_supplicant-f207e3ccc89c85bd4131003af94bec0fe0dc32a2.tar.gz wpa_supplicant-f207e3ccc89c85bd4131003af94bec0fe0dc32a2.tar.xz |
Add wpa_supplicant.
-rw-r--r-- | manifests/init.pp | 6 | ||||
-rw-r--r-- | manifests/interface.pp | 19 | ||||
-rw-r--r-- | templates/wpa_supplicant.conf.epp | 15 |
3 files changed, 40 insertions, 0 deletions
diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..3125f6c --- /dev/null +++ b/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/manifests/interface.pp b/manifests/interface.pp new file mode 100644 index 0000000..8254359 --- /dev/null +++ b/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/templates/wpa_supplicant.conf.epp b/templates/wpa_supplicant.conf.epp new file mode 100644 index 0000000..48680bb --- /dev/null +++ b/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 %> + <%- } -%> +} +<% } %> |