建立zabbix模塊目錄:node
$ mkdir -p /etc/puppet/modules/zabbix/{manifests,templates}
建立init.pp清單:spa
$ cat /etc/puppet/modules/zabbix/manifests/init.pp class zabbix { package { 'epel-release': ensure => installed, } package { 'zabbix22-agent': ensure => installed, } file { '/etc/zabbix/zabbix_agentd.conf': content => template("zabbix/zabbix_agentd.conf.erb"), ensure => file, } service { 'zabbix-agent': ensure => "running", hasstatus => true, enable => true, } Package["zabbix22-agent"] -> File["/etc/zabbix/zabbix_agentd.conf"] -> Service["zabbix-agent"] }
建立zabbix_agentd.conf.erb模板:code
$ cp /etc/zabbix/zabbix_agentd.conf /etc/puppet/modules/zabbix/templates/zabbix_agentd.conf.erb $ cat /etc/puppet/modules/zabbix/templates/zabbix_agentd.conf.erb Server=<%= zabbix_server %> ServerActive=<%= zabbix_server %> Hostname=<%= fqdn %> ... ... ... ...
編輯site.pp:server
$# cat /etc/puppet/manifests/site.pp Package { allow_virtual => true, } node default { $zabbix_server = "192.168.154.137" include zabbix }