Skip to content

Commit

Permalink
Merge pull request #159 from vinzent/fix_selinux_fact_usage
Browse files Browse the repository at this point in the history
Fix usage of non-existent $::selinux_enabled fact
  • Loading branch information
bastelfreak authored Dec 28, 2016
2 parents 22580ff + c607c09 commit d134e73
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# a complete relabeling is required when switching from disabled to
# permissive or enforcing. Ensure the autorelabel trigger file is created.
if $mode in ['enforcing','permissive'] and
!$::selinux_enabled {
!$::selinux {
file { '/.autorelabel':
ensure => 'file',
owner => 'root',
Expand Down
23 changes: 20 additions & 3 deletions spec/classes/selinux_config_mode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
facts.merge(
selinux: true,
selinux_config_mode: 'enforcing',
selinux_config_policy: 'targeted',
selinux_current_mode: 'enforcing'
)
end

context 'config' do
Expand Down Expand Up @@ -54,15 +59,27 @@

context 'disabled to permissive creates autorelabel trigger file' do
let(:facts) do
facts.merge(selinux_enabled: false)
hash = facts.merge(
selinux: false
)
hash.delete(:selinux_config_mode)
hash.delete(:selinux_current_mode)
hash.delete(:selinux_config_policy)
hash
end
let(:params) { { mode: 'permissive' } }
it { is_expected.to contain_file('/.autorelabel').with(ensure: 'file') }
end

context 'disabled to enforcing creates autorelabel trigger file' do
let(:facts) do
facts.merge(selinux_enabled: false)
hash = facts.merge(
selinux: false
)
hash.delete(:selinux_config_mode)
hash.delete(:selinux_current_mode)
hash.delete(:selinux_config_policy)
hash
end
let(:params) { { mode: 'enforcing' } }
it { is_expected.to contain_file('/.autorelabel').with(ensure: 'file') }
Expand Down
4 changes: 0 additions & 4 deletions spec/default_module_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
osfamily: RedHat
operatingsystem: RedHat
operatingsystemmajrelease: '7'
selinux_config_mode: enforcing
selinux_current_mode: enforcing
selinux_enabled: true
selinux_config_policy: targeted
# concat facts
id: 0
path: /tmp

0 comments on commit d134e73

Please sign in to comment.