From c7ecf4dc205dc66829c60b147abe4df18140fb3f Mon Sep 17 00:00:00 2001 From: Lars Bahner Date: Wed, 3 Nov 2021 14:31:12 +0100 Subject: [PATCH 1/6] Provide hiera integration --- manifests/init.pp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 59077a4..efc4350 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -6,6 +6,7 @@ # @param package_ensure the ensure state of the package # @param config_directory the path to the wireguard directory # @param purge_unknown_keys by default Puppet will purge unknown wireguard keys from `$config_directory` +# @param interfaces hash of interfaces to create. Provides hiera integration. # # @author Tim Meusel # @@ -15,6 +16,7 @@ Enum['installed', 'latest', 'absent'] $package_ensure = 'installed', Stdlib::Absolutepath $config_directory = '/etc/wireguard', Boolean $purge_unknown_keys = true, + Hash $interfaces = {}, ) { if $manage_package { package { 'wireguard-tools': @@ -39,4 +41,6 @@ group => 'systemd-network', * => $options, } + + create_resources(wireguard::interface, $interfaces) } From 3d44e9e9305d42397adbaadafafc08da3ceb85a7 Mon Sep 17 00:00:00 2001 From: Lars Bahner Date: Wed, 3 Nov 2021 16:51:50 +0100 Subject: [PATCH 2/6] Narrow type definition for interfaces. --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index efc4350..7844d46 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,7 +16,7 @@ Enum['installed', 'latest', 'absent'] $package_ensure = 'installed', Stdlib::Absolutepath $config_directory = '/etc/wireguard', Boolean $purge_unknown_keys = true, - Hash $interfaces = {}, + Hash[String[1], Any] $interfaces = {}, ) { if $manage_package { package { 'wireguard-tools': From e4d2e02fc2aa2e6fc925f5fa674b16fe68597b48 Mon Sep 17 00:00:00 2001 From: Lars Bahner Date: Thu, 17 Feb 2022 23:02:27 +0100 Subject: [PATCH 3/6] Use new resource syntax --- manifests/init.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 7844d46..2033052 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,5 +42,9 @@ * => $options, } - create_resources(wireguard::interface, $interfaces) + $interfaces.each | $interfacename, $interfaceattributes { + wireguard::interface { $interfacename: + * => $interfaceattributes + } + } } From b6bd31d5c871fa567520a63197dcf4690e8be48a Mon Sep 17 00:00:00 2001 From: Lars Bahner Date: Thu, 17 Feb 2022 23:04:41 +0100 Subject: [PATCH 4/6] Fix syntax error --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2033052..0188c5d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,7 +42,7 @@ * => $options, } - $interfaces.each | $interfacename, $interfaceattributes { + $interfaces.each | $interfacename, $interfaceattributes| { wireguard::interface { $interfacename: * => $interfaceattributes } From 92669a1dbb144eefab354ffce782c196173d969d Mon Sep 17 00:00:00 2001 From: Lars Bahner Date: Thu, 17 Feb 2022 23:07:35 +0100 Subject: [PATCH 5/6] Satisfy strict syntax check. --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 0188c5d..61ac0b1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -44,7 +44,7 @@ $interfaces.each | $interfacename, $interfaceattributes| { wireguard::interface { $interfacename: - * => $interfaceattributes + * => $interfaceattributes, } } } From 4deaadd0b49747bb4e13d2381aa18b6d0971ad30 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Fri, 18 Feb 2022 10:35:20 +0100 Subject: [PATCH 6/6] Update manifests/init.pp --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 61ac0b1..8c5e38c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,7 +42,7 @@ * => $options, } - $interfaces.each | $interfacename, $interfaceattributes| { + $interfaces.each |$interfacename, $interfaceattributes| { wireguard::interface { $interfacename: * => $interfaceattributes, }