OP#436 add user access
This commit is contained in:
@@ -41,6 +41,7 @@ class confdroid_nagios::params (
|
|||||||
# httpd
|
# httpd
|
||||||
Boolean $ng_use_https = false,
|
Boolean $ng_use_https = false,
|
||||||
|
|
||||||
|
|
||||||
) {
|
) {
|
||||||
# Default facts
|
# Default facts
|
||||||
$fqdn = $facts['networking']['fqdn']
|
$fqdn = $facts['networking']['fqdn']
|
||||||
|
|||||||
31
manifests/server/access.pp
Normal file
31
manifests/server/access.pp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
## confdroid_nagios::server::access.pp
|
||||||
|
# Module name: confdroid_nagios
|
||||||
|
# Author: 12ww1160 (12ww1160@confdroid.com)
|
||||||
|
# @summary Class manages access configuration for the confdroid_nagios module.
|
||||||
|
# @param [String] ng_htpasswd_user The username for the Nagios web interface.
|
||||||
|
# @param [String] ng_htpasswd_password The encrypted password for the Nagios web interface.
|
||||||
|
# @example
|
||||||
|
# confdroid_nagios::server::access { 'example':
|
||||||
|
# ng_htpasswd_user => 'example_user',
|
||||||
|
# ng_htpasswd_password => 'example_password_encrypted',
|
||||||
|
# }
|
||||||
|
###############################################################################
|
||||||
|
define confdroid_nagios::server::access (
|
||||||
|
Optional[String] $ng_htpasswd_user = undef,
|
||||||
|
Optional[String] $ng_htpasswd_password = undef,
|
||||||
|
) {
|
||||||
|
$ng_nagios_server = $confdroid_nagios::params::ng_nagios_server
|
||||||
|
$ng_htpasswd_file = $confdroid_nagios::params::ng_htpasswd_file
|
||||||
|
$ng_htpasswd_rule = $confdroid_nagios::params::ng_htpasswd_rule
|
||||||
|
$ng_service = $confdroid_nagios::params::ng_nagios_service
|
||||||
|
|
||||||
|
if $fqdn == $ng_nagios_server {
|
||||||
|
# create password rules
|
||||||
|
|
||||||
|
concat::fragment { $name:
|
||||||
|
target => $ng_htpasswd_file,
|
||||||
|
content => template($ng_htpasswd_rule),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
v
|
||||||
25
manifests/server/access_rules.pp
Normal file
25
manifests/server/access_rules.pp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
## confdroid_nagios::server::access_rules.pp
|
||||||
|
# Module name: confdroid_nagios
|
||||||
|
# Author: 12ww1160 (12ww1160@confdroid.com)
|
||||||
|
# @summary Class manages presence of /etc/nagios/passwd file.
|
||||||
|
#############################################################################
|
||||||
|
class confdroid_nagios::server::access_rules (
|
||||||
|
|
||||||
|
) inherits confdroid_nagios::params {
|
||||||
|
if $fqdn == $ng_nagios_server {
|
||||||
|
# manage /etc/nagios/passwd file
|
||||||
|
|
||||||
|
concat { $ng_htpasswd_file:
|
||||||
|
ensure => present,
|
||||||
|
path => $ng_htpasswd_file,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'apache',
|
||||||
|
mode => '0640',
|
||||||
|
selrange => s0,
|
||||||
|
selrole => object_r,
|
||||||
|
seltype => nagios_etc_t,
|
||||||
|
seluser => system_u,
|
||||||
|
notify => Service[$ng_nagios_service],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
## confdroid_nagios::server::files.pp
|
c
|
||||||
# Module name: confdroid_nagios
|
|
||||||
# Author: 12ww1160 (12ww1160@confdroid.com)
|
|
||||||
# @summary Class manages configuration files for the confdroid_nagios module.
|
|
||||||
###############################################################################
|
|
||||||
class confdroid_nagios::server::files (
|
class confdroid_nagios::server::files (
|
||||||
|
|
||||||
) inherits confdroid_nagios::params {
|
) inherits confdroid_nagios::params {
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ class confdroid_nagios::server::service (
|
|||||||
) inherits confdroid_nagios::params {
|
) inherits confdroid_nagios::params {
|
||||||
require confdroid_nagios::server::files
|
require confdroid_nagios::server::files
|
||||||
if $ng_nagios_server == $fqdn {
|
if $ng_nagios_server == $fqdn {
|
||||||
exec { 'restart_httpd':
|
exec { 'reload_httpd':
|
||||||
command => 'systemctl restart httpd',
|
command => 'systemctl reload httpd',
|
||||||
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
|
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ class confdroid_nagios::server::service (
|
|||||||
enable => true,
|
enable => true,
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
require => Exec['restart_httpd'],
|
require => Exec['reload_httpd'],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user