saltstack搭建集群3
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了saltstack搭建集群3相关的知识,希望对你有一定的参考价值。
系统初始化模块--------------zabbix-agent
在配置文件里设置pillar路径
[[email protected] init]# vim /etc/salt/master
pillar_roots:
base:
- /srv/pillar/base
[[email protected] init]# /etc/init.d/salt-master restart
在pillar里建立top.sls和zabbix.sls
[[email protected] init]# mkdir /srv/pillar/base
[[email protected] pillar]# cd base/
[[email protected] base]# cat top.sls
base:
‘*‘:
- zabbix
[[email protected] base]# cat zabbix.sls
zabbix-agent:
Zabbix_Server: 192.168.10.129
[[email protected] init]# cd /srv/salt/base/init/
[[email protected] 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‘] }} #这里将pillar里ID为zabbix-agent,Zabbix_Server的值赋给变量Server
- require:
- pkg: zabbix-agent-install
service.running:
- name: zabbix-agent
- enable: True
- watch:
- pkg: zabbix-agent-install
- file: zabbix-agent-install
编写配置文件利用jinja将Server变量的值传给Server,也就是指定zabbix-Server地址
cp /etc/zabbix/zabbix_agentd.conf /srv/salt/base/init/files/
[[email protected] base]#vim /srv/salt/base/init/files/zabbix_agent.conf
Server={{Server}}
将zabbix_agent.sls include到env_init.sls
[[email protected] init]# cat env_init.sls
include:
- init.dns
- init.history
- init.audit
- init.sysctl
- init.zabbix_agent
[[email protected] init]# salt ‘*‘ state.highstate
本文出自 “feng” 博客,请务必保留此出处http://fengxiaoli.blog.51cto.com/12104465/1958159
以上是关于saltstack搭建集群3的主要内容,如果未能解决你的问题,请参考以下文章