salt安装zabbix

states文件:

 

 

 

 

 

 

[root@super65 base]# cat top.sls
base:
  '*':
    - init.env_init
[root@super65 base]# cat init/env_init.sls
include:
  - init.zabbix_agent

[root@super65 base]# cat init/zabbix_agent.sls
zabbix-agent:
  pkg.installed:
    - name: zabbix22-agent

  file.managed:
    - name: /etc/zabbix_agentd.conf
    - source: salt://init/files/zabbix_agentd.conf
    - tmplate: jinjia
    - defaults:
      Server: {{ pillar['zabbix-agent']['Zabbix-Server'] }}
    - require:
    - pkg: zabbix-agent

  service.running:
    - enable: True
    - watch:
    - pkg: zabbix-agent
    - file: zabbix-agent

 

 

[root@super65 pillar]# cat base/top.sls
base:
  '*':
    - zabbix
[root@super65 pillar]# cat base/zabbix.sls
zabbix-agent:
  Zabbix-Server: 192.168.1.65

 

[root@super65 files]# grep -Ev "^$|^#" zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server={{Server}}
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix_agentd.conf.d/

 

启动时没这个文件会报错:

mkdri /etc/zabbix_agentd.conf.d

 

 执行:

[root@super65 ~]# salt '*' state.highstate test=True

[root@super65 ~]# salt '*' state.highstate 

 

posted @ 2016-09-17 15:38  xuanhui  阅读(294)  评论(0编辑  收藏  举报