Skip to content

Commit

Permalink
Add $manage_selinux parameter
Browse files Browse the repository at this point in the history
We manage selinux in a few places. There are systems where this is
prohibited for puppet. We will manage it when it is on enforcing. This
parameter allows people to disable it in each class, even if it is on
enforcing.
  • Loading branch information
bastelfreak committed May 21, 2017
1 parent fa6c6ca commit 68e0d61
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
$tlsservercertsubject = $zabbix::params::agent_tlsservercertsubject,
String $agent_config_owner = $zabbix::params::agent_config_owner,
String $agent_config_group = $zabbix::params::agent_config_group,
Boolean $manage_selinux = $zabbix::params::manage_selinux,
) inherits zabbix::params {
# Check some if they are boolean

Expand Down Expand Up @@ -382,11 +383,11 @@
}
# the agent doesn't work perfectly fine with selinux
# https://support.zabbix.com/browse/ZBX-11631
if $facts['os']['selinux']['config_mode'] == 'enforcing' {
if $facts['selinux'] == 'enforcing' and $manage_selinux {
selinux::module{'zabbix-agent':
ensure => 'present',
source_te => 'puppet:///modules/zabbix/zabbix-agent.te',
before => Service['zabbix-agent']
before => Service['zabbix-agent'],
}
}
}
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@
$allowroot = $zabbix::params::server_allowroot,
$include_dir = $zabbix::params::server_include,
$loadmodulepath = $zabbix::params::server_loadmodulepath,
$loadmodule = $zabbix::params::server_loadmodule,) inherits zabbix::params {
$loadmodule = $zabbix::params::server_loadmodule,
Boolean $manage_selinux = $zabbix::params::manage_selinux,
) inherits zabbix::params {
class { '::zabbix::web':
zabbix_url => $zabbix_url,
database_type => $database_type,
Expand Down Expand Up @@ -206,6 +208,7 @@
apache_php_upload_max_filesize => $apache_php_upload_max_filesize,
apache_php_max_input_time => $apache_php_max_input_time,
apache_php_always_populate_raw_post_data => $apache_php_always_populate_raw_post_data,
manage_selinux => $manage_selinux,
require => Class['zabbix::server'],
}

Expand Down Expand Up @@ -283,6 +286,7 @@
include_dir => $include_dir,
loadmodulepath => $loadmodulepath,
loadmodule => $loadmodule,
manage_selinux => $manage_selinux,
require => Class['zabbix::database'],
}

Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
$javagateway_pidfile = '/var/run/zabbix/zabbix_java.pid'
$javagateway_startpollers = '5'
$javagateway_timeout = '3'
$manage_selinux = $facts['selinux']

# Gem provider may vary based on version/type of puppet install.
# This can be a little complicated and may need revisited over time.
Expand Down
3 changes: 2 additions & 1 deletion manifests/proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@
$include_dir = $zabbix::params::proxy_include,
$loadmodulepath = $zabbix::params::proxy_loadmodulepath,
$loadmodule = $zabbix::params::proxy_loadmodule,
Boolean $manage_selinux = $zabbix::params::manage_selinux,
) inherits zabbix::params {

# Find if listenip is set. If not, we can set to specific ip or
Expand Down Expand Up @@ -603,7 +604,7 @@
}

# check if selinux is active and allow zabbix
if $::osfamily == 'RedHat' and getvar('::selinux_config_mode') == 'enforcing' {
if $facts['os']['selinux']['config_mode'] == 'enforcing' and $manage_selinux {
selboolean{'zabbix_can_network':
persistent => true,
value => 'on',
Expand Down
3 changes: 2 additions & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@
$loadmodule = $zabbix::params::server_loadmodule,
$sslcertlocation_dir = $zabbix::params::server_sslcertlocation,
$sslkeylocation_dir = $zabbix::params::server_sslkeylocation,
Boolean $manage_selinux = $zabbix::params::manage_selinux,
) inherits zabbix::params {
# Only include the repo class if it has not yet been included
unless defined(Class['Zabbix::Repo']) {
Expand Down Expand Up @@ -533,7 +534,7 @@
}

# check if selinux is active and allow zabbix
if getvar('::selinux_config_mode') == 'enforcing' {
if $facts['selinux'] == 'enforcing' and $manage_selinux {
selboolean{'zabbix_can_network':
persistent => true,
value => 'on',
Expand Down
3 changes: 2 additions & 1 deletion manifests/web.pp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
$ldap_clientcert = $zabbix::params::ldap_clientcert,
$ldap_clientkey = $zabbix::params::ldap_clientkey,
$puppetgem = $zabbix::params::puppetgem,
Boolean $manage_selinux = $zabbix::params::manage_selinux,
) inherits zabbix::params {

# check osfamily, Arch is currently not supported for web
Expand Down Expand Up @@ -463,7 +464,7 @@
} # END if $manage_vhost

# check if selinux is active and allow zabbix
if $::osfamily == 'RedHat' and getvar('::selinux_config_mode') == 'enforcing' {
if $facts['selinux'] == 'enforcing' and $manage_selinux {
selboolean{'httpd_can_connect_zabbix':
persistent => true,
value => 'on',
Expand Down

0 comments on commit 68e0d61

Please sign in to comment.