From 4bc6cdc1967ab881af3807025dddb84418dfa7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 6 Nov 2022 22:56:10 +0100 Subject: Fix repack function. --- functions/repack.pp | 12 +++++++----- templates/unit_file.epp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/functions/repack.pp b/functions/repack.pp index 396354c..a4b7815 100644 --- a/functions/repack.pp +++ b/functions/repack.pp @@ -1,7 +1,9 @@ # Normalizes a hash or a list of hashes to a list of hashes -function networking::repack(Variant[Hash, Array[Hash]] $data) >> Array[Hash] { - $data ? { - Hash => [$data], - _ => $data, - } +function networking::repack(Hash[String,Variant[Hash, Array[Hash]]] $data) >> Hash[String, Array[Hash]] { + $data.map |$key, $body| { + [$key, $body ? { + Hash => [$body], + default => $body, + }] + }.convert_to(Hash) } diff --git a/templates/unit_file.epp b/templates/unit_file.epp index 6751058..02e5c32 100644 --- a/templates/unit_file.epp +++ b/templates/unit_file.epp @@ -1,9 +1,9 @@ <%- | Hash[String,Array[Hash]] $data | -%> # File managed by PUPPET -<%- $data.each |$key, $sub| { -%> +<%- $data.each |$key, $subs| { -%> +<%- $subs.each |$sub| { -%> -<%- $sub.each |$sub| { -%> [<%= $key %>] <%- $sub.each |$k, $v| { -%> <%- if $v =~ Array { $v.each |$v| { -%> -- cgit v1.2.3