Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Chain6 directive #694

Merged
merged 3 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
6 changes: 5 additions & 1 deletion examples/plugins/iptables.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
include ::collectd

class { '::collectd::plugin::iptables':
chains => {
chains => {
'nat' => 'In_SSH',
'filter' => 'HTTP',
},
chains6 => {
'nat' => 'In6_SSH',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nat example for IPv6 is odd. I'd just leave this line out

'filter' => 'HTTP6',
},
}
2 changes: 2 additions & 0 deletions manifests/plugin/iptables.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$ensure_package = 'present',
$manage_package = undef,
$chains = {},
$chains6 = {},
$interval = undef,
) {

Expand All @@ -12,6 +13,7 @@
$_manage_package = pick($manage_package, $::collectd::manage_package)

validate_hash($chains)
validate_hash($chains6)

if $::osfamily == 'RedHat' {
if $_manage_package {
Expand Down
14 changes: 14 additions & 0 deletions spec/classes/collectd_plugin_iptables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
end
end

context ':ensure => present and :chains6 => { \'nat\' => \'In6_SSH\' }' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also use filter instead of nat? I know it doesn't matter that much, but it feels wrong :)

let :params do
{ chains6: { 'nat' => 'In6_SSH' } }
end

it "Will create #{options[:plugin_conf_dir]}/10-iptables.conf" do
is_expected.to contain_file('iptables.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-iptables.conf",
content: %r{Chain6 nat In6_SSH}
)
end
end

context ':ensure => present and :chains has two chains from the same table' do
let :params do
{ chains: {
Expand Down
11 changes: 9 additions & 2 deletions templates/plugin/iptables.conf.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<% if @chains -%>
<Plugin iptables>
<% if @chains -%>
<% @chains.each_pair do |table,chains|
Array(chains).each do |chain| -%>
Chain <%= table %> <%= chain %>
<% end -%>
<% end -%>
</Plugin>
<% end -%>
<% if @chains6 -%>
<% @chains6.each_pair do |table6,chains6|
Array(chains6).each do |chain6| -%>
Chain6 <%= table6 %> <%= chain6 %>
<% end -%>
<% end -%>
<% end -%>
</Plugin>