puppet nagios

写了一个puppet的nagios 模块,写的不怎么样,但是也是自己写的第一个模块,记录下来。

#install&config nagios init.pp
class nagios::params {
     file {"/usr/local/src/nagios-plugins-1.4.15.tar.gz":
	     source =>"puppet://$puppetserver/nagios/nagios-plugins-1.4.15.tar.gz",
		 }
	 file {"/usr/local/src/nrpe-2.12.tar.gz":
	     source =>"puppet://$puppetserver/nagios/nrpe-2.12.tar.gz",
		 }
	 user {"nagios":
	     ensure =>present,
		 comment => "nagios user",
		 gid => "nagios",
		 shell => "/bin/bash",
		 home =>"/home/nagios",
		 require => Group["nagios"],
		 }
	 group {"nagios":
	     ensure =>present,
		 }
	}
class nagios::install {
     exec {"install-nagios":
	     cwd =>"/usr/local/src",
		 command =>"tar -zxvf nagios-plugins-1.4.15.tar.gz&&tar -zxvf nrpe-2.12.tar.gz&&cd nagios-plugins-1.4.15&&./configure&&make&&make install&&chown -R nagios.nagios /usr/local/nagios&&cd nrpe-2.12&&./configure&&make all&&make install-plugin&&make install-daemon&&make install-daemon-config",
		 logoutput => on_failure,
		 timeout => 0,
		 require => Class["nagios::params"]
	     }
	 }
class nagios::config {
     file { "/usr/local/nagios/etc/nrpe.cfg":
	     ensure => present,
	     owner => 'nagios',
	     group => 'nagios',
	     mode => 0622,
	     source => "puppet://$puppetserver/nagios/nrpe.cfg",
	     require => class["nagios::install"],
	     notify => class["nagios::service"],
	    }
	}
class nagios::service {
     exec{"start-nagios":
	     command=>"/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d",
		 require => Class["nagios::config"],
		 }
	}
class nagios {
     include nagios::params,nagios::install,nagios::config,nagios::service
	 }


你可能感兴趣的:(puppet nagios)