[root@linux-node1 init]# vim /etc/salt/master
536 pillar_roots:
537 base:
538 - /srv/pillar/base
在pillar环境下的top file文件:
[root@linux-node1 base]# cat /srv/pillar/base/top.sls
base:
‘*‘:
- zabbix
在pillar环境下的安装文件zabbix.sls
[root@linux-node1 base]# cat /srv/pillar/base/zabbix.sls
zabbix-agent: ###############################对应salt中base环境下的file.managed模块中的zabbix-agent
Zabbix_Server: 10.0.0.7 ###############################对应salt中base环境下的file.managed模块中的Zabbix_Server
在salt项目的base环境下的文件管理zabbix_agent.sls
[root@linux-node1 base]# cat /srv/salt/base/init/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‘] }} #################################对应pillar中base环境下的zabbix.sls里面的
- require:
- pkg: zabbix-agent-install
service.running:
- enable: True
- watch:
- pkg: zabbix-agent-install
- file: zabbix-agent-install
执行高级状态:
[root@linux-node1 ~]# salt ‘*‘ state.highstate
linux-node1.example.com:
................
Summary
-------------
Succeeded: 32 (changed=1)
Failed: 0
-------------
Total states run: 32
linux-node2.example.com:
................
Summary
-------------
Succeeded: 32 (changed=1)
Failed: 0
-------------
Total states run: 32
老男孩网址:http://www.etiantian.org
qq:406564728
欢迎交流
本文出自 “linux” 博客,请务必保留此出处http://chenjisong.blog.51cto.com/7858025/1714336
原文:http://chenjisong.blog.51cto.com/7858025/1714336