Skip to content

Commit

Permalink
Merge pull request #302 from jonnangle/237-iptables
Browse files Browse the repository at this point in the history
Allow iptables chains parameter to be an array (fix redhat-openstack#237)
  • Loading branch information
blkperl committed Aug 6, 2015
2 parents cee944e + 4eaa664 commit 6baf790
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions spec/classes/collectd_plugin_iptables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@
end
end

context ':ensure => present and :chains has two chains from the same table' do
let :params do
{ :chains => {
'filter' => ['INPUT','OUTPUT'],
} }
end
it 'Will create /etc/collectd.d/10-iptables.conf' do
should contain_file('iptables.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-iptables.conf',
:content => /Chain filter INPUT/,
})
should contain_file('iptables.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-iptables.conf',
:content => /Chain filter OUTPUT/,
})
end
end

context ':ensure => absent' do
let :params do
{:chains => { 'nat' => 'In_SSH' }, :ensure => 'absent'}
Expand Down
4 changes: 3 additions & 1 deletion templates/plugin/iptables.conf.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<% if @chains -%>
<Plugin iptables>
<% @chains.each_pair do |table,chain| -%>
<% @chains.each_pair do |table,chains|
Array(chains).each do |chain| -%>
Chain <%= table %> <%= chain %>
<% end -%>
<% end -%>
</Plugin>
<% end -%>

0 comments on commit 6baf790

Please sign in to comment.