Skip to content

Commit

Permalink
Dismantling to manage_selinux to false by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Betz committed Jul 25, 2024
1 parent be363f1 commit 4538a79
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Data type: `Boolean`
If set to true the icinga selinux package is installed if selinux is enabled. Also requires a
`selinux_package_name` (icinga2::globals) and `manage_packages` has to be set to true.

Default value: `true`
Default value: `false`

##### <a name="-icinga2--manage_service"></a>`manage_service`

Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
Boolean $enable = true,
Boolean $manage_repos = false,
Boolean $manage_packages = true,
Boolean $manage_selinux = true,
Boolean $manage_selinux = false,
Boolean $manage_service = true,
Boolean $purge_features = true,
Hash $constants = {},
Expand Down
18 changes: 18 additions & 0 deletions spec/classes/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@
end
end

if facts[:os]['family'] == 'RedHat'
context 'with icinga2::manage_selinux => true, bind_port => 1234' do
let(:pre_condition) do
[
"class { 'icinga2': manage_selinux => true, features => [], constants => {'NodeName' => 'host.example.org'} }",
]
end

let(:params) do
{
bind_port: 1234,
}
end

it { is_expected.to contain_exec('Add port 1234 for icinga2_port_t') }
end
end

context "with pki => 'puppet'" do
let(:params) do
{
Expand Down
19 changes: 14 additions & 5 deletions spec/classes/icinga2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

context 'with defaults' do
it { is_expected.to contain_package('icinga2').with({ 'ensure' => 'installed' }) }
it { is_expected.not_to contain_package('icinga2-selinux') }

it {
is_expected.to contain_service('icinga2').with(
Expand All @@ -44,17 +45,25 @@
end

if facts[:os]['family'] == 'RedHat'
context 'with fact os.selinux.enabled => false' do
context 'with manage_selinux => true, fact os.selinux.enabled => true' do
let(:facts) do
super().merge({ os: { family: 'RedHat', selinux: { enabled: false } } })
super().merge({ os: { family: 'RedHat', selinux: { enabled: true } } })
end

it { is_expected.not_to contain_package('icinga2-selinux') }
let(:params) do
{ manage_selinux: true }
end

it { is_expected.to contain_package('icinga2-selinux') }
end

context 'with manage_selinux => false' do
context 'with manage_selinux => true, fact os.selinux.enabled => false' do
let(:facts) do
super().merge({ os: { family: 'RedHat', selinux: { enabled: false } } })
end

let(:params) do
{ manage_selinux: false }
{ manage_selinux: true }
end

it { is_expected.not_to contain_package('icinga2-selinux') }
Expand Down

0 comments on commit 4538a79

Please sign in to comment.