Skip to content

Commit

Permalink
add support for $::operatingsystem == Fedora
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Jun 16, 2015
1 parent f18dba2 commit 76b3e7c
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 72 deletions.
33 changes: 22 additions & 11 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,32 @@

case $::osfamily {
'RedHat': {
case $::operatingsystemmajrelease {
'7': {
$sx_fs_mount = '/sys/fs/selinux'
$package_name = 'policycoreutils-python'
case $::operatingsystem {
'RedHat': {
case $::operatingsystemmajrelease {
'7': {
$sx_fs_mount = '/sys/fs/selinux'
$package_name = 'policycoreutils-python'
}
'6': {
$sx_fs_mount = '/selinux'
$package_name = 'policycoreutils-python'
}
'5': {
$sx_fs_mount = '/selinux'
$package_name = 'policycoreutils'
}
default: {
fail("${::operatingsystem}-${::operatingsystemmajrelease} is not supported")
}
}
}
'6': {
$sx_fs_mount = '/selinux'
'Fedora': {
$sx_fs_mount = '/sys/fs/selinux'
$package_name = 'policycoreutils-python'
}
'5': {
$sx_fs_mount = '/selinux'
$package_name = 'policycoreutils'
}
default: {
fail("${::osfamily}-${::operatingsystemmajrelease} is not supported")
fail("${::operatingsystem} is not supported")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/selinux_config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe 'selinux' do
let(:facts) { { :osfamily => 'RedHat', :operatingsystemmajrelease => '7', :selinux_current_mode => 'enforcing' } }
include_context 'RedHat 7'

context 'config' do

Expand Down
23 changes: 21 additions & 2 deletions spec/classes/selinux_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,38 @@
context 'package' do

context 'on RedHat 5 based OSes' do
let(:facts) { { :osfamily => 'RedHat', :operatingsystemmajrelease => '5', :selinux_current_mode => 'enforcing' } }
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '5',
:selinux_current_mode => 'enforcing',
}
end

it { should contain_package('policycoreutils').with(:ensure => 'installed') }
end

[ '6', '7' ].each do |majrelease|
context "On RedHat #{majrelease} based OSes" do
let(:facts) { { :osfamily => 'RedHat', :operatingsystemmajrelease => majrelease, :selinux_current_mode => 'enforcing' } }
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => majrelease,
:selinux_current_mode => 'enforcing',
}
end

it { should contain_package('policycoreutils-python').with(:ensure => 'installed') }
end
end

context "On Fedora 22 based OSes" do
include_context 'Fedora 22'

it { should contain_package('policycoreutils-python').with(:ensure => 'installed') }
end

end

Expand Down
11 changes: 1 addition & 10 deletions spec/classes/selinux_restorecond_config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
require 'spec_helper'

describe 'selinux::restorecond' do
let(:facts) { {
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:selinux_current_mode => 'enforcing',
# concat facts
:concat_basedir => '/tmp',
:id => 0,
:is_pe => false,
:path => '/tmp',
} }
include_context 'RedHat 7'

it { should contain_concat('/etc/selinux/restorecond.conf') }
it { should contain_concat__fragment('restorecond_config_default') }
Expand Down
11 changes: 1 addition & 10 deletions spec/classes/selinux_restorecond_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
require 'spec_helper'

describe 'selinux::restorecond' do
let(:facts) { {
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:selinux_current_mode => 'enforcing',
# concat facts
:concat_basedir => '/tmp',
:id => 0,
:is_pe => false,
:path => '/tmp',
} }
include_context 'RedHat 7'

it { should contain_service('restorecond') }

Expand Down
11 changes: 1 addition & 10 deletions spec/classes/selinux_restorecond_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
require 'spec_helper'

describe 'selinux::restorecond' do
let(:facts) { {
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:selinux_current_mode => 'enforcing',
# concat facts
:concat_basedir => '/tmp',
:id => 0,
:is_pe => false,
:path => '/tmp',
} }
include_context 'RedHat 7'

it { should contain_class('selinux::restorecond::config') }
it { should contain_class('selinux::restorecond::service') }
Expand Down
14 changes: 11 additions & 3 deletions spec/classes/selinux_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
require 'spec_helper'

describe 'selinux' do
let(:facts) { { :osfamily => 'RedHat', :operatingsystemmajrelease => '7', :selinux_current_mode => 'enforcing' } }
context 'Redhat 7' do
include_context 'RedHat 7'

it { should contain_class('selinux::package') }
it { should contain_class('selinux::config') }
it { should contain_class('selinux::package') }
it { should contain_class('selinux::config') }
end

context 'Fedora 22' do
include_context 'Fedora 22'

it { should contain_class('selinux::package') }
it { should contain_class('selinux::config') }
end
end
6 changes: 1 addition & 5 deletions spec/defines/selinux_boolean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

describe 'selinux::boolean' do
let(:title) { 'mybool' }
let(:facts) { {
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:selinux_current_mode => 'enforcing',
} }
include_context 'RedHat 7'

context 'default' do
it { should contain_exec("setsebool -P 'mybool' true")}
Expand Down
6 changes: 1 addition & 5 deletions spec/defines/selinux_fcontext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

describe 'selinux::fcontext' do
let(:title) { 'myfile' }
let(:facts) { {
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:selinux_current_mode => 'enforcing',
} }
include_context 'RedHat 7'

context 'invalid pathname' do
it { expect { is_expected.to compile }.to raise_error }
Expand Down
6 changes: 1 addition & 5 deletions spec/defines/selinux_port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

describe 'selinux::port' do
let(:title) { 'myapp' }
let(:facts) { {
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:selinux_current_mode => 'enforcing',
} }
include_context 'RedHat 7'

['tcp', 'udp', 'tcp6', 'udp6'].each do |protocol|
context "valid protocol #{protocol}" do
Expand Down
11 changes: 1 addition & 10 deletions spec/defines/selinux_restorecond_fragment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@
describe 'selinux::restorecond::fragment' do
let(:pre_condition) { 'class { "selinux::restorecond": }' }
let(:title) { 'cond' }
let(:facts) { {
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:selinux_current_mode => 'enforcing',
# concat facts
:concat_basedir => '/tmp',
:id => 0,
:is_pe => false,
:path => '/tmp',
} }
include_context 'RedHat 7'

context 'source' do
let(:params) { { :source => 'puppet:///data/cond.txt' } }
Expand Down
32 changes: 32 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'puppetlabs_spec_helper/module_spec_helper'

shared_context 'RedHat 7' do
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemmajrelease => '7',
:selinux_current_mode => 'enforcing',
# concat facts
:concat_basedir => '/tmp',
:id => 0,
:is_pe => false,
:path => '/tmp',
}
end
end

shared_context 'Fedora 22' do
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'Fedora',
:operatingsystemmajrelease => '22',
:selinux_current_mode => 'enforcing',
# concat facts
:concat_basedir => '/tmp',
:id => 0,
:is_pe => false,
:path => '/tmp',
}
end
end

0 comments on commit 76b3e7c

Please sign in to comment.