Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3517d22
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Oct 31, 2013
c2f54c4
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Nov 24, 2013
42cc7b5
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Dec 9, 2013
a853140
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Apr 15, 2014
62ca8d2
Update to new Debian's init script name
javierbertoli May 18, 2014
ebc5c02
Typo
javierbertoli May 18, 2014
84eb4af
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Jun 10, 2014
f31a90b
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Jun 16, 2014
36813c7
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Jul 10, 2014
88b0e42
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Jul 14, 2014
73551a1
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Sep 29, 2014
e4db158
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Nov 26, 2014
e5527ed
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Nov 26, 2014
20a4964
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Dec 5, 2014
9bb2902
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Jan 31, 2015
c6e5c44
Merge branch 'master' of https://github.com/example42/puppet-iptables
javierbertoli Feb 23, 2015
8eb9e9f
Add multiport support
javierbertoli Feb 28, 2015
c45c4ba
Add multiport support to rules
javierbertoli Feb 28, 2015
0d2b938
Add syn match support for TCP
javierbertoli Feb 28, 2015
cfe164b
true_source is not used anywhere
javierbertoli Feb 28, 2015
04b5b6d
Fix ipv6 source and destination checks
javierbertoli Feb 28, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}

$service = $::operatingsystem ? {
/(?i:Debian|Ubuntu|Mint)/ => 'iptables-persistent',
/(?i:Debian|Ubuntu|Mint)/ => 'netfilter-persistent',
default => 'iptables',
}

Expand Down
38 changes: 29 additions & 9 deletions manifests/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# $table - The iptables table to work on (default filter)
# $chain - The iptables chain to work on (default INPUT).
# Write it UPPERCASE coherently with iptables syntax
# $syn - Add tcp/syn match mark
# Defaults to true if rule matches TCP
# $in_interface - The inbound interface for the rule
# $out_interface - The outbound interface for the rule
# $target - The iptables target for the rule (default ACCEPT)
Expand Down Expand Up @@ -49,6 +51,7 @@
$port = '',
$order = '',
$rule = '',
$syn = true,
$enable = true,
$enable_v6 = false,
$debug = false ) {
Expand Down Expand Up @@ -83,9 +86,18 @@
default => "-p ${protocol}",
}

if $protocol == 'tcp' {
$bool_syn = any2bool($syn)
$match_syn = $bool_syn? {
true => '--syn',
default => '',
}
}

$true_port = $port ? {
'' => '',
default => "--dport ${port}",
'' => '',
/(?i:\w*[,:]\w*)/ => "--match multiport --dports ${port}",
default => "--dport ${port}",
}

$true_in_interface = $in_interface ? {
Expand All @@ -98,11 +110,6 @@
default => "-o ${out_interface}",
}

$true_source = $source ? {
'' => '',
default => "-s ${source}",
}

$true_destination = $destination ? {
'' => '',
default => "-d ${destination}",
Expand All @@ -126,8 +133,21 @@
default => $destination,
}

$array_source_v6 = any2array($source_v6)
$array_destination_v6 = any2array($destination_v6)
$array_source_v6 = is_array($source_v6) ? {
false => $source_v6 ? {
'' => [],
default => [$source_v6],
},
default => $source_v6,
}

$array_destination_v6 = is_array($destination_v6) ? {
false => $destination_v6 ? {
'' => [],
default => [$destination_v6],
},
default => $destination_v6,
}

if $debug {
iptables::debug{ "debug params ${name}":
Expand Down
1 change: 0 additions & 1 deletion spec/defines/iptables_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@

it { should contain_iptables__debug( "debug params iptable1" ).with(
'true_protocol' => '-p tcp',
'true_source' => '',
'array_source_v6' => [],
'array_source' => []
) }
Expand Down
6 changes: 3 additions & 3 deletions templates/concat/rule.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<% scope.lookupvar('array_source').each do |s| -%>
<% if scope.lookupvar('array_destination').length > 0 -%>
<% scope.lookupvar('array_destination').each do |d| -%>
<%= @command %> <%= @chain %> <%= @true_in_interface %> <%= @true_out_interface %> <%= scope.lookupvar('true_protocol') %> <%= scope.lookupvar('true_port') %> -s <%= s %> -d <%= d %> -j <%= scope.lookupvar('target') %><%= comment %>
<%= @command %> <%= @chain %> <%= @true_in_interface %> <%= @true_out_interface %> <%= scope.lookupvar('true_protocol') %> <%= scope.lookupvar('match_syn') %> <%= scope.lookupvar('true_port') %> -s <%= s %> -d <%= d %> -j <%= scope.lookupvar('target') %><%= comment %>
<% end -%>
<% else -%>
<%= @command %> <%= @chain %> <%= @true_in_interface %> <%= @true_out_interface %> <%= scope.lookupvar('true_protocol') %> <%= scope.lookupvar('true_port') %> -s <%= s %> -j <%= scope.lookupvar('target') %><%= comment %>
<%= @command %> <%= @chain %> <%= @true_in_interface %> <%= @true_out_interface %> <%= scope.lookupvar('true_protocol') %> <%= scope.lookupvar('match_syn') %> <%= scope.lookupvar('true_port') %> -s <%= s %> -j <%= scope.lookupvar('target') %><%= comment %>
<% end -%>
<% end -%>
<% else -%>
<%= @command %> <%= @chain %> <%= @true_in_interface %> <%= @true_out_interface %> <%= scope.lookupvar('true_protocol') %> <%= scope.lookupvar('true_port') %> -j <%= scope.lookupvar('target') %><%= comment %>
<%= @command %> <%= @chain %> <%= @true_in_interface %> <%= @true_out_interface %> <%= scope.lookupvar('true_protocol') %> <%= scope.lookupvar('match_syn') %> <%= scope.lookupvar('true_port') %> -j <%= scope.lookupvar('target') %><%= comment %>
<% end -%>
<% end -%>