aboutsummaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorKilian Engelhardt <kilian.engelhardt@gmail.com>2019-07-29 10:27:43 +0200
committerKilian Engelhardt <kilian.engelhardt@godaddy.com>2019-08-08 16:43:15 +0200
commita567a8fdcc6f933286a6ce3e497fc0cfb87ec971 (patch)
tree3fc4a87cd82cec332bd43e8be3e2c819d12a62f7 /manifests
parent5eee9cc90593623c8936cf5ee9da2e4ce8c5fa6e (diff)
downloadpuppet-ferm-a567a8fdcc6f933286a6ce3e497fc0cfb87ec971.tar.gz
puppet-ferm-a567a8fdcc6f933286a6ce3e497fc0cfb87ec971.tar.bz2
allow arrays for saddr and daddr
check for data type IP address when using arrays add debug output when it's failing
Diffstat (limited to 'manifests')
-rw-r--r--manifests/rule.pp26
1 files changed, 21 insertions, 5 deletions
diff --git a/manifests/rule.pp b/manifests/rule.pp
index b8ae29a..bd17245 100644
--- a/manifests/rule.pp
+++ b/manifests/rule.pp
@@ -17,8 +17,8 @@ define ferm::rule (
String $comment = $name,
Optional[Variant[Stdlib::Port,String[1]]] $dport = undef,
Optional[Variant[Stdlib::Port,String[1]]] $sport = undef,
- Optional[String[1]] $saddr = undef,
- Optional[String[1]] $daddr = undef,
+ Optional[Variant[Array, String[1]]] $saddr = undef,
+ Optional[Variant[Array, String[1]]] $daddr = undef,
Optional[String[1]] $proto_options = undef,
Optional[String[1]] $interface = undef,
Enum['absent','present'] $ensure = 'present',
@@ -33,13 +33,29 @@ define ferm::rule (
undef => '',
default => "sport ${sport}",
}
+ if $saddr =~ Array {
+ assert_type(Array[Stdlib::IP::Address], flatten($saddr)) |$expected, $actual| {
+ fail( "The data type should be \'${expected}\', not \'${actual}\'. The data is ${flatten($saddr)}." )
+ ''
+ }
+ }
$saddr_real = $saddr ? {
undef => '',
- default => "saddr @ipfilter(${saddr})",
+ Array => "saddr @ipfilter((${join(flatten($saddr).unique, ' ')}))",
+ String => "saddr @ipfilter((${saddr}))",
+ default => '',
+ }
+ if $daddr =~ Array {
+ assert_type(Array[Stdlib::IP::Address], flatten($daddr)) |$expected, $actual| {
+ fail( "The data type should be \'${expected}\', not \'${actual}\'. The data is ${flatten($daddr)}." )
+ ''
+ }
}
$daddr_real = $daddr ? {
- undef => '',
- default => "daddr @ipfilter(${daddr})"
+ undef => '',
+ Array => "daddr @ipfilter((${join(flatten($daddr).unique, ' ')}))",
+ String => "daddr @ipfilter((${daddr}))",
+ default => '',
}
$proto_options_real = $proto_options ? {
undef => '',