From 6405936dae74ed336f1421a27c7c22abf6d02d9e Mon Sep 17 00:00:00 2001 From: Keith Burdis Date: Thu, 7 Feb 2013 12:43:50 +0000 Subject: Initial Nagios server-side installation and setup. --- manifests/install.pp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 manifests/install.pp (limited to 'manifests/install.pp') diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..95196b5 --- /dev/null +++ b/manifests/install.pp @@ -0,0 +1,73 @@ +class check_mk::install ( + $filestore, + $version, + $workspace, +) { + package { 'nagios': + ensure => present, + notify => Exec['set-nagiosadmin-password', 'add-apache-to-nagios-group'], + } + exec { 'set-nagiosadmin-password': + command => '/usr/bin/htpasswd -bc /etc/nagios/passwd nagiosadmin letmein', + refreshonly => true, + } + exec { 'add-apache-to-nagios-group': + command => '/usr/sbin/usermod -a -G nagios apache', + refreshonly => true, + } + package { 'nagios-plugins-all': + ensure => present, + require => Package['nagios'], + } + package { [ 'xinetd', 'mod_python', 'make', 'gcc-c++', 'tar', 'gzip' ]: + ensure => present, + } + file { "${workspace}/check_mk-${version}.tar.gz": + ensure => present, + source => "${filestore}/check_mk-${version}.tar.gz", + } + exec { 'unpack-check_mk-tarball': + command => "/bin/tar -zxf ${workspace}/check_mk-${version}.tar.gz", + cwd => $workspace, + creates => "${workspace}/check_mk-${version}", + require => File["${workspace}/check_mk-${version}.tar.gz"], + } + exec { 'change-setup-config-location': + command => "/usr/bin/perl -pi -e 's#^SETUPCONF=.*?$#SETUPCONF=${workspace}/check_mk_setup.conf#' ${workspace}/check_mk-${version}/setup.sh", + unless => "/bin/egrep '^SETUPCONF=${workspace}/check_mk_setup.conf$' ${workspace}/check_mk-${version}/setup.sh", + require => Exec['unpack-check_mk-tarball'], + } + # Avoid header like 'Written by setup of check_mk 1.2.0p3 at Thu Feb 7 12:26:17 GMT 2013' + # that changes every time the setup script is run + exec { 'remove-setup-header': + command => "/usr/bin/perl -pi -e 's#^DIRINFO=.*?$#DIRINFO=#' ${workspace}/check_mk-${version}/setup.sh", + unless => "/bin/egrep '^DIRINFO=$' ${workspace}/check_mk-${version}/setup.sh", + require => Exec['unpack-check_mk-tarball'], + } + file { "${workspace}/check_mk_setup.conf": + ensure => present, + content => template('check_mk/setup.conf.erb'), + notify => Exec['check_mk-setup'], + } + file { '/etc/nagios/check_mk': + ensure => directory, + owner => 'nagios', + group => 'nagios', + recurse => true, + require => Package['nagios'], + } + exec { 'check_mk-setup': + command => "${workspace}/check_mk-${version}/setup.sh --yes", + cwd => "${workspace}/check_mk-${version}", + refreshonly => true, + require => [ + Exec['change-setup-config-location'], + Exec['remove-setup-header'], + Exec['unpack-check_mk-tarball'], + File["${workspace}/check_mk_setup.conf"], + File['/etc/nagios/check_mk'], + Package['nagios'], + ], + notify => Class['check_mk::service'], + } +} -- cgit v1.2.3