Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODULES-1309 - Make package and service names configurable
This was motivated by a need to make this work on Debian Jessie.
- Loading branch information
Morgan Haskel
committed
Dec 3, 2014
1 parent
b0daa9d
commit c6e4a9c
Showing
10 changed files
with
171 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class firewall::params { | ||
case $::osfamily { | ||
'RedHat': { | ||
case $::operatingsystem { | ||
'Archlinux': { | ||
$service = ['iptables','ip6tables'] | ||
$package = undef | ||
} | ||
'Fedora': { | ||
if versioncmp($::operatingsystemrelease, '15') >= 0 { | ||
$package = 'iptables-services' | ||
} else { | ||
$package = undef | ||
} | ||
$service = 'iptables' | ||
} | ||
default: { | ||
if versioncmp($::operatingsystemrelease, '7.0') >= 0 { | ||
$package = 'iptables-services' | ||
} else { | ||
$package = undef | ||
} | ||
$service = 'iptables' | ||
} | ||
} | ||
} | ||
'Debian': { | ||
if $::operatingsystemrelease =~ /^6\./ and versioncmp($::iptables_persistent_version, '0.5.0') < 0 { | ||
$service = undef | ||
$package = 'iptables-persistent' | ||
} elsif $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '8') >= 0 { | ||
$service = 'netfilter-persistent' | ||
$package = 'netfilter-persistent' | ||
} else { | ||
$service = 'iptables-persistent' | ||
$package = 'iptables-persistent' | ||
} | ||
} | ||
default: { | ||
$package = undef | ||
$service = 'iptables' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,59 @@ | ||
require 'spec_helper' | ||
|
||
describe 'firewall::linux::debian', :type => :class do | ||
it { should contain_package('iptables-persistent').with( | ||
:ensure => 'present' | ||
)} | ||
it { should contain_service('iptables-persistent').with( | ||
:ensure => nil, | ||
:enable => 'true', | ||
:require => 'Package[iptables-persistent]' | ||
)} | ||
context "Debian 7" do | ||
let(:facts) {{ | ||
:osfamily => 'Debian', | ||
:operatingsystem => 'Debian', | ||
:operatingsystemrelease => '7.0' | ||
}} | ||
it { should contain_package('iptables-persistent').with( | ||
:ensure => 'present' | ||
)} | ||
it { should contain_service('iptables-persistent').with( | ||
:ensure => nil, | ||
:enable => 'true', | ||
:require => 'Package[iptables-persistent]' | ||
)} | ||
end | ||
|
||
context 'enable => false' do | ||
context 'deb7 enable => false' do | ||
let(:facts) {{ | ||
:osfamily => 'Debian', | ||
:operatingsystem => 'Debian', | ||
:operatingsystemrelease => '7.0' | ||
}} | ||
let(:params) {{ :enable => 'false' }} | ||
it { should contain_service('iptables-persistent').with( | ||
:enable => 'false' | ||
)} | ||
end | ||
|
||
context "Debian 8" do | ||
let(:facts) {{ | ||
:osfamily => 'Debian', | ||
:operatingsystem => 'Debian', | ||
:operatingsystemrelease => '8.0' | ||
}} | ||
it { should contain_package('netfilter-persistent').with( | ||
:ensure => 'present' | ||
)} | ||
it { should contain_service('netfilter-persistent').with( | ||
:ensure => nil, | ||
:enable => 'true', | ||
:require => 'Package[netfilter-persistent]' | ||
)} | ||
end | ||
|
||
context 'deb8 enable => false' do | ||
let(:facts) {{ | ||
:osfamily => 'Debian', | ||
:operatingsystem => 'Debian', | ||
:operatingsystemrelease => '8.0' | ||
}} | ||
let(:params) {{ :enable => 'false' }} | ||
it { should contain_service('netfilter-persistent').with( | ||
:enable => 'false' | ||
)} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters