OP#436 add user access

This commit is contained in:
2026-02-14 21:05:02 +01:00
parent c62ff78711
commit 0273e9553a
5 changed files with 61 additions and 8 deletions

View File

@@ -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']

View 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

View 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],
}
}
}

View File

@@ -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 {

View File

@@ -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'],
} }
} }
} }