saltstack自动化运维系列⑥SaltStack实践配置管理安装zabbix
1.添加管理zabbix的sls文件
# vim /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'] }}
- require:
- pkg: zabbix-agent-install service.running:
- name: zabbix-agent
- enable: True
- watch:
- pkg: zabbix-agent-install
- file: zabbix-agent-install
2.编辑master配置文件
# vim /etc/salt/master
pillar_roots:
base:
- /srv/pillar/base # mkdir /srv/pillar/base # /etc/init.d/salt-master restart 3.编写top文件
# vim /srv/pillar/base/top.sls
base:
'*':
- zabbix
4.编写zabbix.sls
# vim /srv/pillar/base/zabbix.sls
zabbix-agent:
Zabbix_Server: 192.168.3.13
5.拷贝模板文件,并修改pillar jinja模板变量值
cp /etc/zabbix/zabbix_agentd.conf /srv/salt/base/init/files/
vim /srv/salt/base/init/files/zabbix_agentd.conf
Server={{ Server }}
6.将zabbix_agent配置包括含在初始化文件中
vim /srv/salt/base/init/env_init.sls
include:
- init.dns
- init.history
- init.audit
- init.sysctl
- init.zabbix_agent
7.执行配置变更:
# salt '*' state.highstate