首页 > 其他 > 详细

saltstack搭建集群3

时间:2017-08-22 00:07:22      阅读:355      评论:0      收藏:0      [点我收藏+]

系统初始化模块--------------zabbix-agent


在配置文件里设置pillar路径

[root@node1 init]# vim /etc/salt/master

pillar_roots:

  base:

- /srv/pillar/base

[root@node1 init]# /etc/init.d/salt-master restart

 

pillar里建立top.slszabbix.sls

[root@node1 init]# mkdir /srv/pillar/base

[root@node1 pillar]# cd base/

[root@node1 base]# cat top.sls

base:

  ‘*‘:

- zabbix

 

[root@node1 base]# cat zabbix.sls

zabbix-agent:

  Zabbix_Server: 192.168.10.129

 

[root@node1 init]# cd /srv/salt/base/init/

[root@node1 init]# cat zabbix_agent.sls

zabbix-agent-install:

  pkg.installed:

    - name: zabbix-agent

  file.managed:

    - name: /etc/zabbix/zabbix_agentd.conf

    - source: salt://init/files/zabbix_agentd.conf

    - template: jinja

    - defaults:

      Server: {{ pillar[‘zabbix-agent‘][‘Zabbix_Server‘] }}  #这里将pillarIDzabbix-agentZabbix_Server的值赋给变量Server

    - require:

      - pkg: zabbix-agent-install

  service.running:

    - name: zabbix-agent

    - enable: True

    - watch:

      - pkg: zabbix-agent-install

      - file: zabbix-agent-install


编写配置文件利用jinjaServer变量的值传给Server,也就是指定zabbix-Server地址

cp /etc/zabbix/zabbix_agentd.conf /srv/salt/base/init/files/

[root@node1 base]#vim /srv/salt/base/init/files/zabbix_agent.conf

Server={{Server}}

  

zabbix_agent.sls includeenv_init.sls

[root@node1 init]# cat env_init.sls

include:

  - init.dns

  - init.history

  - init.audit

  - init.sysctl

  - init.zabbix_agent

 

[root@node1 init]# salt ‘*‘ state.highstate


本文出自 “feng” 博客,请务必保留此出处http://fengxiaoli.blog.51cto.com/12104465/1958159

saltstack搭建集群3

原文:http://fengxiaoli.blog.51cto.com/12104465/1958159

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!