Skip to content

Commit

Permalink
rework pull request #602 from b3n4kh/selinux
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Feb 21, 2020
1 parent d96f713 commit d8f962d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 21 deletions.
1 change: 0 additions & 1 deletion data/Linux-kernel.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
icinga2::globals::package_name: icinga2
icinga2::globals::service_name: icinga2
icinga2::globals::selinux_name: icinga2-selinux
icinga2::globals::service_reload: service icinga2 reload
icinga2::globals::ido_mysql_package_name: icinga2-ido-mysql
icinga2::globals::ido_mysql_schema: /usr/share/icinga2-ido-mysql/schema/mysql.sql
Expand Down
1 change: 1 addition & 0 deletions data/RedHat-family-5.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
icinga2::globals::icinga2_bin: /usr/sbin/icinga2
icinga2::manage_selinux: false
1 change: 1 addition & 0 deletions data/RedHat-family-6.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
icinga2::globals::icinga2_bin: /usr/sbin/icinga2
icinga2::manage_selinux: false
2 changes: 0 additions & 2 deletions data/RedHat-family-7.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions data/RedHat-family-8.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions data/RedHat-family.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
icinga2::globals::user: icinga
icinga2::globals::group: icinga
icinga2::globals::icinga2_bin: /sbin/icinga2
icinga2::globals::selinux_package_name: icinga2-selinux
icinga2::repo:
baseurl: 'http://packages.icinga.com/epel/%{facts.os.release.major}/release/'
descr: ICINGA (stable release for epel)
enabled: 1
gpgcheck: 1
gpgkey: http://packages.icinga.com/icinga.key
icinga2::manage_selinux: "%{facts.os.selinux.enforced}"
8 changes: 4 additions & 4 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
# [*package_name*]
# The name of the icinga package to manage.
#
# [*selinux_name*]
# The name of the icinga selinux package.
#
# [*service_name*]
# The name of the icinga service to manage.
#
Expand All @@ -27,6 +24,9 @@
# CAUTION: This does not manage the group context for the runnig icinga 2 process!
# The parameter is only used for group membership of files or directories.
#
# [*selinux_package_name*]
# The name of the icinga selinux package.
#
# [*ido_mysql_package_name*]
# The name of the icinga package that's needed for MySQL.
#
Expand Down Expand Up @@ -99,10 +99,10 @@
Array[String] $reserved,
Optional[String] $user = undef,
Optional[String] $group = undef,
Optional[String] $selinux_package_name = undef,
Optional[String] $ido_mysql_package_name = undef,
Optional[String] $ido_pgsql_package_name = undef,
Optional[String] $service_reload = undef,
Optional[String] $selinux_name = unde,
) {

assert_private()
Expand Down
3 changes: 2 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# If set to false packages aren't managed. Defaults to true.
#
# [*manage_selinux*]
# If set to true the icinga selinux package is installed. Defaults to false.
# If set to true the icinga selinux package is installed. Default on RedHat family is `facts.os.selinux.enforcing`
# otherwise set to false. Requires a `selinux_package_name` (icinga2::globals) and `manage_package` has to be set to true.
#
# [*manage_service*]
# If set to true the service is managed otherwise the service also
Expand Down
28 changes: 17 additions & 11 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

assert_private()

$package_name = $::icinga2::globals::package_name
$manage_package = $::icinga2::manage_package
$selinux_name = $::icinga2::globals::selinux_name
$manage_selinux = $::icinga2::manage_selinux
$cert_dir = $::icinga2::globals::cert_dir
$conf_dir = $::icinga2::globals::conf_dir
$user = $::icinga2::globals::user
$group = $::icinga2::globals::group
$package_name = $::icinga2::globals::package_name
$manage_package = $::icinga2::manage_package
$selinux_package_name = $::icinga2::globals::selinux_package_name
$manage_selinux = $::icinga2::manage_selinux
$cert_dir = $::icinga2::globals::cert_dir
$conf_dir = $::icinga2::globals::conf_dir
$user = $::icinga2::globals::user
$group = $::icinga2::globals::group

if $manage_package {
if $::osfamily == 'windows' { Package { provider => chocolatey, } }
Expand All @@ -33,15 +33,21 @@
before => File[$cert_dir, $conf_dir],
}

if str2bool($manage_selinux) {
package { $selinux_name:
if str2bool($manage_selinux) and $selinux_package_name {
package { $selinux_package_name:
ensure => installed,
require => Package[$package_name],
}
}
}

file { [$cert_dir, $conf_dir]:
file { [$conf_dir]:
ensure => directory,
owner => $user,
group => $group,
}

file { [$cert_dir]:
ensure => directory,
owner => $user,
group => $group,
Expand Down

0 comments on commit d8f962d

Please sign in to comment.