diff options
author | Tim Meusel <tim@bastelfreak.de> | 2019-08-12 22:55:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-12 22:55:52 +0200 |
commit | 15153bd994f4715d37b398264581914692a93c45 (patch) | |
tree | 46a981008420953c768e23c05ca340497b1f3d59 /manifests/rule.pp | |
parent | 5eee9cc90593623c8936cf5ee9da2e4ce8c5fa6e (diff) | |
parent | a0d72d5947030fc2dc4332652e5868fa15b906e4 (diff) | |
download | puppet-ferm-15153bd994f4715d37b398264581914692a93c45.tar.gz puppet-ferm-15153bd994f4715d37b398264581914692a93c45.tar.bz2 |
Merge pull request #51 from kBite/allow-array-for-saddr-daddr
Allow array for saddr and daddr
Diffstat (limited to 'manifests/rule.pp')
-rw-r--r-- | manifests/rule.pp | 26 |
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 => '', |