导航

CentOS7:Puppet推送Zabbix Agent

Posted on 2016-11-17 13:48  eastson  阅读(396)  评论(0编辑  收藏  举报

创建zabbix模块目录:

$ mkdir -p /etc/puppet/modules/zabbix/{manifests,templates}

创建init.pp清单:

$ 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模板:

$ 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:

$# cat /etc/puppet/manifests/site.pp 
Package {
  allow_virtual => true,
}

node default {
  $zabbix_server = "192.168.154.137"
  include zabbix
}