三、关于zabbix安装的配置
目的是通过puppet自动化的配置zabbix,只要服务器加入puppet管理后,自动化进行zabbix的安装和配置,保证配置完成后,在zabbix server端增加相应的host就可以管理该服务器。
1、需要资源及顺序
zabbix用户和组 user
zabbix配置文件 file
zabbix安装过程过程
zabbix启动关闭脚本 file
zabbix的源包
4、zabbix 类
class zabbix {
file {
"/home/zabbix/zabbix-1.8.9.tar.gz":
source => "puppet://master/zabbix/zabbix-1.8.9.tar.gz",
owner => "zabbix",
group => "zabbix",
ensure => present
}
file {
"/home/zabbix/zabbix_install.sh":
source => "puppet://master/zabbix/zabbix_install.sh",
owner => "zabbix",
group => "zabbix",
ensure => present
}
file {
"/etc/zabbix/zabbix_agentd.conf":
source => "puppet://master/zabbix/zabbix_agentd.conf",
owner => "zabbix",
group => "zabbix",
ensure => present
}
exec {
"./zabbix_install.sh":
cwd=>"/home/zabbix",
#command => "./zabbix_install.sh",
path=>["/bin","/sbin","/usr/bin","/usr/sbin"],
creates=>"/usr/local/sbin/zabbix_agentd"
}
exec {
"groupadd zabbix;useradd -g zabbix zabbix":
cwd=>"/root",
# command => "groupadd zabbix;useradd -g zabbix zabbix",
path=>["/bin","/sbin","/usr/bin","/usr/sbin"],
onlyif=> "test `grep zabbix /etc/passwd | awk -F : '{print $1}' ` = zabbix"
}
}
-------------------------------------------------------
最终版本 /etc/puppet/modules/zabbix/manifests/init.pp
class zabbix {
group {
"zabbix":
name => "zabbix",
ensure => present
}
user {
"zabbix":
name => "zabbix",
shell => "/sbin/nologin",
groups => "zabbix",
home => "/home/zabbix",
ensure => present
}
file {
"/home/zabbix/zabbix-1.8.9.tar.gz":
source => "puppet://master/zabbix/zabbix-1.8.9.tar.gz",
owner => "zabbix",
group => "zabbix",
ensure => present,
require => User["zabbix"]
}
file {
"/home/zabbix/zabbix_install.sh":
source => "puppet://master/zabbix/zabbix_install.sh",
owner => "zabbix",
group => "zabbix",
ensure => present
}
file {
"/etc/zabbix/zabbix_agentd.conf":
source => "puppet://master/zabbix/zabbix_agentd.conf",
owner => "zabbix",
group => "zabbix",
ensure => present
}
file {
"/etc/init.d/zabbix_agentd":
source => "puppet://master/zabbix/zabbix_agentd",
owner => "root",
group => "root",
mode => 744,
ensure => present
}
service {
"zabbix_agentd":
ensure => running
}
exec {
"bash zabbix_install.sh":
cwd=>"/home/zabbix",
#command => "./zabbix_install.sh",
path=>["/bin","/sbin","/usr/bin","/usr/sbin"],
creates=>"/usr/local/sbin/zabbix_agentd"
}
exec {
"mkdir /home/zabbix":
creates => "/home/zabbix",
path=>["/bin","/sbin","/usr/bin","/usr/sbin"]
}
exec {
"mkdir /etc/zabbix":
creates => "/etc/zabbix",
path=>["/bin","/sbin","/usr/bin","/usr/sbin"]
}
}
待续。。。。。。。
阅读(3132) | 评论(0) | 转发(1) |