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

Allow iptables chains parameter to be an array (fix #237) #302

Merged
merged 2 commits into from
Aug 6, 2015
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
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
6 changes: 4 additions & 2 deletions 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
end -%>
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that missing a <% why is Travis not failing?

Edit: Oh you have two ends in the same ruby block. Please don't do that, its confusing and could introduce a bug if someone edits this file in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, now fixed!

</Plugin>
<% end -%>