From 87c231b5f1ff056e9e7f8ff80ad7805cf2226cd4 Mon Sep 17 00:00:00 2001 From: Massimiliano Adamo <maxadamo@gmail.com> Date: Wed, 18 Jan 2023 12:51:00 +0100 Subject: [PATCH] fail on empty hash --- functions/fw_builder_public_ips.pp | 8 ++++++-- manifests/init.pp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/functions/fw_builder_public_ips.pp b/functions/fw_builder_public_ips.pp index c41b988..fbae5b5 100644 --- a/functions/fw_builder_public_ips.pp +++ b/functions/fw_builder_public_ips.pp @@ -32,11 +32,15 @@ function fw_builder::fw_builder_public_ips( $public_ipsets = [] } else { if 'public' in $facts_fw_conf { - # this check is not needed, but it will be necessary if the - # code of fw_builder changes and "public" can be absent + # this check is not needed, but it will be necessary if the + # code of fw_builder changes and "public" can be absent $facts_fw_conf_public = $facts_fw_conf['public'] + if $facts_fw_conf_public.length == 0 { + fail('public is declared but it is empty. Please either delete it or add proper values') + } + # create a list of lists with all the ipsets in public $unflattened_public_ipsets = $facts_fw_conf_public.map |$app_key, $app_value| { if 'ipset' in keys($facts_fw_conf_public[$app_key]) { diff --git a/manifests/init.pp b/manifests/init.pp index 636e50e..e5d75ea 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -55,7 +55,7 @@ class fw_builder ( ipv6_enable => $ipv6_enable, limit => $limit; } - -> anchor { 'fw_builder::begin': } + -> anchor { 'fw_builder::end': } class { 'fw_builder::logrotate': logging => $logging, -- GitLab