Skip to content

Commit

Permalink
Readd param manage_selinux, but set default ro true
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Betz committed Jul 1, 2024
1 parent e1461ad commit f4126d1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
10 changes: 10 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ The following parameters are available in the `icinga2` class:
* [`enable`](#-icinga2--enable)
* [`manage_repos`](#-icinga2--manage_repos)
* [`manage_packages`](#-icinga2--manage_packages)
* [`manage_selinux`](#-icinga2--manage_selinux)
* [`manage_service`](#-icinga2--manage_service)
* [`features`](#-icinga2--features)
* [`purge_features`](#-icinga2--purge_features)
Expand Down Expand Up @@ -243,6 +244,15 @@ If set to false packages aren't managed.

Default value: `true`

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

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`

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

Data type: `Boolean`
Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
# @param manage_packages
# If set to false packages aren't managed.
#
# @param manage_selinux
# 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.
#
# @param manage_service
# If set to true the service is managed otherwise the service also
# isn't restarted if a config file changed.
Expand Down Expand Up @@ -114,6 +118,7 @@
Boolean $enable = true,
Boolean $manage_repos = false,
Boolean $manage_packages = true,
Boolean $manage_selinux = true,
Boolean $manage_service = true,
Boolean $purge_features = true,
Hash $constants = {},
Expand Down
3 changes: 2 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

$package_name = $icinga2::globals::package_name
$manage_packages = $icinga2::manage_packages
$manage_selinux = $icinga2::manage_selinux
$selinux_package_name = $icinga2::globals::selinux_package_name
$cert_dir = $icinga2::globals::cert_dir
$conf_dir = $icinga2::globals::conf_dir
Expand All @@ -23,7 +24,7 @@
before => File[$cert_dir, $conf_dir],
}

if fact('os.selinux.enabled') and $facts['os']['selinux']['enabled'] and $selinux_package_name {
if $manage_selinux and fact('os.selinux.enabled') and $facts['os']['selinux']['enabled'] and $selinux_package_name {
package { $selinux_package_name:
ensure => installed,
require => Package[$package_name],
Expand Down
20 changes: 19 additions & 1 deletion spec/classes/icinga2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,30 @@
it { is_expected.to contain_icinga2__feature('notification').with({ 'ensure' => 'present' }) }
end

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

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

context 'with manage_selinux => false' do
let(:params) do
{ manage_selinux: false }
end

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

context 'with manage_packages => false' do
let(:params) do
{ manage_packages: false }
end

it { is_expected.not_to contain_package('icinga2').with({ 'ensure' => 'installed' }) }
it { is_expected.not_to contain_package('icinga2') }
end

context 'with confd => false' do
Expand Down

0 comments on commit f4126d1

Please sign in to comment.