From f207e3ccc89c85bd4131003af94bec0fe0dc32a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 3 Jan 2022 19:55:36 +0100 Subject: Add wpa_supplicant. --- manifests/init.pp | 6 ++++++ manifests/interface.pp | 19 +++++++++++++++++++ templates/wpa_supplicant.conf.epp | 15 +++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 manifests/init.pp create mode 100644 manifests/interface.pp create mode 100644 templates/wpa_supplicant.conf.epp 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 %> + <%- } -%> +} +<% } %> -- cgit v1.2.3