Add a new subclass (xymon::server::apache) to manage both Apache2

configuration and vhost for Xymon server. Based on the puppetlabs-apache
module.
This commit is contained in:
gardouille 2015-02-20 16:37:59 +01:00
parent 6e14a376e3
commit 2aa1f978f0
6 changed files with 114 additions and 14 deletions

View File

@ -50,9 +50,14 @@ class xymon::params {
$srv_service_enabled = true $srv_service_enabled = true
$srv_service_managed = true $srv_service_managed = true
$srv_service_name = 'xymon' $srv_service_name = 'xymon'
# If the server subclass should manage the client one # If the server subclass should manage the client one
$manage_client = true $manage_client = true
## Web service
# Apache2
$manage_apache_conf = true
$manage_apache_vhost = true
} }
default: { default: {
fail('This Puppet module has been tested only on Debian OS family.') fail('This Puppet module has been tested only on Debian OS family.')

View File

@ -29,20 +29,24 @@ class xymon::server (
$package_name = $xymon::params::srv_package_name, $package_name = $xymon::params::srv_package_name,
$pkg_ensure = $xymon::params::srv_pkg_ensure, $pkg_ensure = $xymon::params::srv_pkg_ensure,
$pkg_provider = $xymon::params::srv_pkg_provider, $pkg_provider = $xymon::params::srv_pkg_provider,
$manage_client = $xymon::params::manage_client,
$service_enabled = $xymon::params::srv_service_enabled, $service_enabled = $xymon::params::srv_service_enabled,
$service_managed = $xymon::params::srv_service_managed, $service_managed = $xymon::params::srv_service_managed,
$service_name = $xymon::params::srv_service_name, $service_name = $xymon::params::srv_service_name,
$manage_client = $xymon::params::manage_client,
$manage_apache_conf = $xymon::params::manage_apache_conf,
$manage_apache_vhost = $xymon::params::manage_apache_vhost,
) inherits xymon::params { ) inherits xymon::params {
include '::xymon::server::preconfig' include '::xymon::server::preconfig'
include '::xymon::server::install' include '::xymon::server::install'
#include '::xymon::server::config' #include '::xymon::server::config'
include '::xymon::server::service' include '::xymon::server::service'
include '::xymon::server::apache'
Class['::xymon::server::preconfig'] -> Class['::xymon::server::preconfig'] ->
Class['::xymon::server::install'] -> Class['::xymon::server::install'] ->
#Class['::xymon::server::config'] -> #Class['::xymon::server::config'] ->
Class['::xymon::server::service'] Class['::xymon::server::service'] ->
Class['::xymon::server::apache']
} # Public class: xymon::server } # Public class: xymon::server

View File

@ -0,0 +1,91 @@
# == Class: xymon::server::apache
#
# Manage Apache2 configuration and vhost for Xymon
#
class xymon::server::apache {
if (! defined(Class['::apache'])) and ($xymon::server::manage_apache_conf == true) {
include apache::mod::rewrite
class { '::apache':
mpm_module => 'prefork',
default_vhost => false,
}
}
if ($xymon::server::manage_apache_vhost == true) {
apache::vhost { 'xymon':
servername => "${::fqdn}",
port => 80,
docroot => '/var/lib/xymon/www',
directories => [
{ path => '/var/lib/xymon/www',
options => ['Indexes','FollowSymLinks','Includes','MultiViews'],
},
{ path => '/usr/lib/xymon/cgi-bin',
allow_override => ['None'],
options => ['ExecCGI','Includes'],
},
{ path => '/usr/lib/xymon/cgi-secure',
allow_override => ['None'],
options => ['ExecCGI','Includes'],
auth_user_file => '/etc/xymon/xymonpasswd',
auth_group_file => '/etc/xymon/xymongroups',
auth_type => 'Basic',
auth_name => 'Xymon Administration',
auth_require => 'valid-user',
},
],
priority => '10',
aliases => [
{ alias => '/xymon/',
path => '/var/lib/xymon/www/',
},
{ scriptalias => '/xymon-cgi/',
path => '/usr/lib/xymon/cgi-bin/',
},
{ scriptalias => '/xymon-seccgi/',
path => '/usr/lib/xymon/cgi-secure/',
},
],
rewrites => [
{ rewrite_rule => ['^/xymon/bb2.html /xymon/nongreen.html [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon/bbnk.html /xymon/critical.html [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-hist.sh /xymon-cgi/history.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-eventlog.sh /xymon-cgi/eventlog.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-rep.sh /xymon-cgi/report.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-replog.sh /xymon-cgi/reportlog.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-snapshot.sh /xymon-cgi/snapshot.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-findhost.sh /xymon-cgi/findhost.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-csvinfo.sh /xymon-cgi/csvinfo.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbitcolumn.sh /xymon-cgi/columndoc.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-datepage.sh /xymon-cgi/datepage.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbitgraph.sh /xymon-cgi/showgraph.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-hostsvc.sh /xymon-cgi/svcstatus.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/bb-histlog.sh /xymon-cgi/historylog.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-confreport.sh /xymon-cgi/confreport.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-confreport-critical.sh /xymon-cgi/confreport-critical.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-nkview.sh /xymon-cgi/criticalview.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-certreport.sh /xymon-cgi/certreport.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-nongreen.sh /xymon-cgi/nongreen.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-hostgraphs.sh /xymon-cgi/hostgraphs.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-ghosts.sh /xymon-cgi/ghostlist.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-notifylog.sh /xymon-cgi/notifications.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-hostlist.sh /xymon-cgi/hostlist.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-perfdata.sh /xymon-cgi/perfdata.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-cgi/hobbit-topchanges.sh /xymon-cgi/topchanges.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-seccgi/bb-ack.sh /xymon-seccgi/acknowledge.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-seccgi/hobbit-enadis.sh /xymon-seccgi/enadis.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-seccgi/hobbit-nkedit.sh /xymon-seccgi/criticaleditor.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-seccgi/hobbit-ackinfo.sh /xymon-seccgi/ackinfo.sh [R=permanent,L]'], },
{ rewrite_rule => ['^/xymon-seccgi/hobbit-useradm.sh /xymon-seccgi/useradm.sh [R=permanent,L]'], },
],
access_log_syslog => '|/usr/bin/tee -a /var/log/apache2/defaults_access.log | /usr/bin/logger -thttpd -plocal1.notice',
error_log_syslog => '|/usr/bin/tee -a /var/log/apache2/defaults_error.log | /usr/bin/logger -thttpd -plocal1.notice',
}
}
} # Private class: xymon::server::apache

View File

@ -4,21 +4,17 @@
# #
class xymon::server::install { class xymon::server::install {
Exec {
path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ],
logoutput => 'on_failure',
}
## Packages ## Packages
# Install dependencies¬ # Install dependencies¬
ensure_resource('package', $xymon::server::dep_pkg_name , {'ensure' => 'present'}) ensure_resource('package', $xymon::server::dep_pkg_name , {'ensure' => 'present'})
# Download the latest Xymon server package # Download the latest Xymon server package
exec { 'Download Xymon Server': exec { 'Download Xymon Server':
command => "wget ${xymon::server::preconfig::dl_url}/${xymon::server::preconfig::pkg_name} -O ${xymon::server::preconfig::pkg_name}", path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ],
cwd => $xymon::server::download_dir, command => "wget ${xymon::server::preconfig::dl_url}/${xymon::server::preconfig::pkg_name} -O ${xymon::server::preconfig::pkg_name}",
creates => "${xymon::server::download_dir}/${xymon::server::preconfig::pkg_name}", cwd => $xymon::server::download_dir,
creates => "${xymon::server::download_dir}/${xymon::server::preconfig::pkg_name}",
logoutput => 'on_failure',
} }
-> ->
# Install Xymon server package # Install Xymon server package

View File

@ -1,4 +1,7 @@
# Private class: xymon::server::service # == Class: xymon::server::service
#
# Manage Xymon service
#
class xymon::server::service { class xymon::server::service {
if $xymon::server::service_enabled == true { if $xymon::server::service_enabled == true {

View File

@ -14,6 +14,7 @@
} }
], ],
"dependencies": [ "dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":"4.x"} {"name":"puppetlabs/stdlib","version_requirement":"4.x"},
{"name":"puppetlabs/apache","version_requirement":"1.3.x"}
] ]
} }