diff options
author | Tim Meusel <tim@bastelfreak.de> | 2019-07-12 09:47:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-12 09:47:23 +0200 |
commit | d856acb9f857c80c65285ec3e09a4f9f37475d41 (patch) | |
tree | 29effc4945a9831ce53c18526265c69ee426344b /manifests/rule.pp | |
parent | 92bfbfed2e47ef3ff857623c5c5accda42dbf195 (diff) | |
parent | 885c4b2ec6774d52cee6107dca61566283e3694f (diff) | |
download | puppet-ferm-d856acb9f857c80c65285ec3e09a4f9f37475d41.tar.gz puppet-ferm-d856acb9f857c80c65285ec3e09a4f9f37475d41.tar.bz2 |
Merge pull request #48 from bastelfreak/interface
add support for interface specific rules
Diffstat (limited to 'manifests/rule.pp')
-rw-r--r-- | manifests/rule.pp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/manifests/rule.pp b/manifests/rule.pp index c87ef7f..b8ae29a 100644 --- a/manifests/rule.pp +++ b/manifests/rule.pp @@ -8,6 +8,7 @@ # @param saddr The source address we want to match # @param daddr The destination address we want to match # @param proto_options Optional parameters that will be passed to the protocol (for example to match specific ICMP types) +# @param interface an Optional interface where this rule should be applied # @param ensure Set the rule to present or absent define ferm::rule ( Ferm::Chains $chain, @@ -19,6 +20,7 @@ define ferm::rule ( Optional[String[1]] $saddr = undef, Optional[String[1]] $daddr = undef, Optional[String[1]] $proto_options = undef, + Optional[String[1]] $interface = undef, Enum['absent','present'] $ensure = 'present', ){ $proto_real = "proto ${proto}" @@ -47,9 +49,33 @@ define ferm::rule ( $rule = squeeze("${comment_real} ${proto_real} ${proto_options_real} ${dport_real} ${sport_real} ${daddr_real} ${saddr_real} ${policy};", ' ') if $ensure == 'present' { - concat::fragment{"${chain}-${name}": - target => "/etc/ferm.d/chains/${chain}.conf", - content => "${rule}\n", + if $interface { + unless defined(Concat::Fragment["${chain}-${interface}-aaa"]) { + concat::fragment{"${chain}-${interface}-aaa": + target => "/etc/ferm.d/chains/${chain}.conf", + content => "interface ${interface} {\n", + order => $interface, + } + } + + concat::fragment{"${chain}-${interface}-${name}": + target => "/etc/ferm.d/chains/${chain}.conf", + content => " ${rule}\n", + order => $interface, + } + + unless defined(Concat::Fragment["${chain}-${interface}-zzz"]) { + concat::fragment{"${chain}-${interface}-zzz": + target => "/etc/ferm.d/chains/${chain}.conf", + content => "}\n", + order => $interface, + } + } + } else { + concat::fragment{"${chain}-${name}": + target => "/etc/ferm.d/chains/${chain}.conf", + content => "${rule}\n", + } } } } |