diff --git a/manifests/main/config.pp b/manifests/main/config.pp index 9dfa0ee..2048324 100644 --- a/manifests/main/config.pp +++ b/manifests/main/config.pp @@ -6,6 +6,10 @@ class confdroid_nagios::main::config ( ) inherits confdroid_nagios::params { - include confdroid_nagios::server::service + if $fqdn == $ng_nagios_server { + include confdroid_nagios::server::service + include confdroid_nagios::nagios::resources::resource + } + include confdroid_nagios::client::target } diff --git a/manifests/nagios/resources/resource.pp b/manifests/nagios/resources/resource.pp new file mode 100644 index 0000000..915c507 --- /dev/null +++ b/manifests/nagios/resources/resource.pp @@ -0,0 +1,48 @@ +## confdroid_nagios::nagios::resources::resource.pp +# Module name: confdroid_nagios +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary Class manages the resource config file header. +# @example concat::fragment { "user_rule_plugins": +# ng_user_arg_name => "$user1$", +# ng_user_arg_value => '/usr/lib64/nagios/plugins', +# ng_user_arg_comment => "Sets $USER1$ to be the path to the plugins", +# } +############################################################################# +class confdroid_nagios::nagios::resources::resource ( + +) inherits confdroid_nagios::params { + if $fqdn == $ng_nagios_server { + concat { $ng_resource_file: + ensure => present, + owner => 'root', + group => $ng_user, + mode => '0640', + selrange => s0, + selrole => object_r, + seltype => nagios_etc_t, + seluser => system_u, + notify => Service[$ng_service], + } + + concat::fragment { 'header': + target => $ng_resource_file, + content => template($ng_resource_erb), + order => '000', + } + + # plugins rule + + confdroid_nagios::nagios::resources::resource_df { 'user_rule_plugins': + ng_user_arg_name => 'USER1', + ng_user_arg_value => '/usr/lib64/nagios/plugins/', + ng_user_arg_comment => 'Sets user1 to be the path to the plugins', + } + + # eventhandlers rule + confdroid_nagios::nagios::resources::resource_df { 'user_rule_eventhandlers': + ng_user_arg_name => 'USER2', + ng_user_arg_value => '/usr/lib64/nagios/plugins/eventhandlers/', + ng_user_arg_comment => 'Sets user2 to be the path to the eventhandlers', + } + } +} diff --git a/manifests/nagios/resources/resource_df.pp b/manifests/nagios/resources/resource_df.pp new file mode 100644 index 0000000..2a90cbb --- /dev/null +++ b/manifests/nagios/resources/resource_df.pp @@ -0,0 +1,28 @@ +## confdroid_nagios::nagios::resources::resource_df.pp +# Module name: confdroid_nagios +# Author: 12ww1160 (12ww1160@ConfDroid.com) +# @summary define manages the resources in/etc/nagios/private/resources.cfg +# @param [String] ng_user_arg_name the name of user argument i.e. $user1$ +# @param [String] ng_user_arg_value the value of t user argument i.e. $user1$ +# @param [String] ng_user_arg_comment the argument i.e. $user1$ +# @param [String] ng_resource_rule_erb resource rule # +############################################################################# +define confdroid_nagios::nagios::resources::resource_df ( + + Optional[String] $ng_user_arg_name = undef, + Optional[String] $ng_user_arg_value = undef, + Optional[String] $ng_user_arg_comment = undef, + String $ng_resource_rule_erb = 'confdroid_nagios/nagios/resource_cfg_rule.erb', + +) { + $ng_nagios_server = $confdroid_nagios::params::ng_nagios_server + $ng_resource_file = $confdroid_nagios::params::ng_resource_file + + if $fqdn == $ng_nagios_server { + concat::fragment { "rule_${name}": + target => $ng_resource_file, + content => template($ng_resource_rule_erb), + order => '000', + } + } +} diff --git a/manifests/params.pp b/manifests/params.pp index beb9a1d..172ffec 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -113,6 +113,8 @@ class confdroid_nagios::params ( $ng_htpasswd_file = "${ng_main_dir}/passwd" $ng_htpasswd_head = 'confdroid_nagios/nagios/htpasswd_head.erb' $ng_htpasswd_rule = 'confdroid_nagios/nagios/htpasswd_rule.erb' + $ng_resource_file = '/etc/nagios/private/resource.cfg' + $ng_resource_erb = 'confdroid_nagios/nagios/resource_cfg.erb' ## old $ng_main_config = "${ng_main_dir}/nagios.cfg" @@ -136,7 +138,6 @@ class confdroid_nagios::params ( $ng_index_html_erb = 'confdroid_nagios/httpd/index_html.erb' $ng_ssl_vhost_file = '/etc/httpd/conf.d/nagios_ssl.conf' $ng_ssl_vhost_erb = 'confdroid_nagios/httpd/nagios_ssl_vhost.erb' - $ng_resource_erb = 'confdroid_nagios/nagios/resource_cfg.erb' $ng_grep_erb = 'confdroid_nagios/selinux/grep.erb' # includes must be last diff --git a/manifests/server/access.pp b/manifests/server/access.pp index 09d702c..afc9dcc 100644 --- a/manifests/server/access.pp +++ b/manifests/server/access.pp @@ -21,7 +21,6 @@ define confdroid_nagios::server::access ( if $fqdn == $ng_nagios_server { # create password rules - concat::fragment { $name: target => $ng_htpasswd_file, content => template($ng_htpasswd_rule), diff --git a/manifests/server/service.pp b/manifests/server/service.pp index e019c6c..bb44dc2 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -9,6 +9,7 @@ class confdroid_nagios::server::service ( require confdroid_nagios::server::files if $ng_nagios_server == $fqdn { require confdroid_nagios::server::access_rules + exec { 'restart_httpd': command => 'systemctl restart httpd', path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],