OP#436 add negios section resources
This commit is contained in:
@@ -6,6 +6,10 @@
|
|||||||
class confdroid_nagios::main::config (
|
class confdroid_nagios::main::config (
|
||||||
|
|
||||||
) inherits confdroid_nagios::params {
|
) inherits confdroid_nagios::params {
|
||||||
|
if $fqdn == $ng_nagios_server {
|
||||||
include confdroid_nagios::server::service
|
include confdroid_nagios::server::service
|
||||||
|
include confdroid_nagios::nagios::resources::resource
|
||||||
|
}
|
||||||
|
|
||||||
include confdroid_nagios::client::target
|
include confdroid_nagios::client::target
|
||||||
}
|
}
|
||||||
|
|||||||
48
manifests/nagios/resources/resource.pp
Normal file
48
manifests/nagios/resources/resource.pp
Normal file
@@ -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',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
manifests/nagios/resources/resource_df.pp
Normal file
28
manifests/nagios/resources/resource_df.pp
Normal file
@@ -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',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -113,6 +113,8 @@ class confdroid_nagios::params (
|
|||||||
$ng_htpasswd_file = "${ng_main_dir}/passwd"
|
$ng_htpasswd_file = "${ng_main_dir}/passwd"
|
||||||
$ng_htpasswd_head = 'confdroid_nagios/nagios/htpasswd_head.erb'
|
$ng_htpasswd_head = 'confdroid_nagios/nagios/htpasswd_head.erb'
|
||||||
$ng_htpasswd_rule = 'confdroid_nagios/nagios/htpasswd_rule.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
|
## old
|
||||||
$ng_main_config = "${ng_main_dir}/nagios.cfg"
|
$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_index_html_erb = 'confdroid_nagios/httpd/index_html.erb'
|
||||||
$ng_ssl_vhost_file = '/etc/httpd/conf.d/nagios_ssl.conf'
|
$ng_ssl_vhost_file = '/etc/httpd/conf.d/nagios_ssl.conf'
|
||||||
$ng_ssl_vhost_erb = 'confdroid_nagios/httpd/nagios_ssl_vhost.erb'
|
$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'
|
$ng_grep_erb = 'confdroid_nagios/selinux/grep.erb'
|
||||||
|
|
||||||
# includes must be last
|
# includes must be last
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ define confdroid_nagios::server::access (
|
|||||||
|
|
||||||
if $fqdn == $ng_nagios_server {
|
if $fqdn == $ng_nagios_server {
|
||||||
# create password rules
|
# create password rules
|
||||||
|
|
||||||
concat::fragment { $name:
|
concat::fragment { $name:
|
||||||
target => $ng_htpasswd_file,
|
target => $ng_htpasswd_file,
|
||||||
content => template($ng_htpasswd_rule),
|
content => template($ng_htpasswd_rule),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class confdroid_nagios::server::service (
|
|||||||
require confdroid_nagios::server::files
|
require confdroid_nagios::server::files
|
||||||
if $ng_nagios_server == $fqdn {
|
if $ng_nagios_server == $fqdn {
|
||||||
require confdroid_nagios::server::access_rules
|
require confdroid_nagios::server::access_rules
|
||||||
|
|
||||||
exec { 'restart_httpd':
|
exec { 'restart_httpd':
|
||||||
command => 'systemctl restart httpd',
|
command => 'systemctl restart httpd',
|
||||||
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
|
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
|
||||||
|
|||||||
Reference in New Issue
Block a user