puppet模塊-zabbix-agentnode
目錄結構oracle
# pwd dom
/etc/puppet/modules/zabbix ide
[root@puppet zabbix]# tree ui
. url
├── files spa
├── manifests server
│ └── init.pp 資源
├── readme it
└── templates
└── zabbix_agentd.conf.erb
3 directories, 3 files
模塊資源結構
# cat manifests/init.pp
class zabbix {
package { 'zabbix-agent':
ensure => installed,
require => Yumrepo["zabbix"],
}
yumrepo { 'zabbix':
baseurl => "http://repo.zabbix.com/zabbix/2.2/rhel/6/\$basearch/",
descr => "zabbix repo",
gpgcheck => 0,
enabled => 1,
}
file { '/etc/zabbix/zabbix_agentd.conf':
content => template("zabbix/zabbix_agentd.conf.erb"),
ensure => file,
}
service { 'zabbix-agent':
ensure => "running",
hasstatus => true,
enable => true,
subscribe => File["/etc/zabbix/zabbix_agentd.conf"],
}
Package ["zabbix-agent"] -> File["/etc/zabbix/zabbix_agentd.conf"] -> service["zabbix-agent"]
}
配置文件模板erb
# cat templates/zabbix_agentd.conf.erb
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
EnableRemoteCommands=1
LogRemoteCommands=1
LogFileSize=0
Server=<%= zabbix_server %>
Include=/etc/zabbix/zabbix_agentd.d/
節點配置添加
# cat server-oracle02.pp
node 'server-oracle02' {
$zabbix_server = "puppet.domain.com"
include zabbix
}