saltstack自動化運維繫列⑥SaltStack實踐配置管理安裝zabbixvim
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/masterui
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.13spa
5.拷貝模板文件,並修改pillar jinja模板變量值rest
cp /etc/zabbix/zabbix_agentd.conf /srv/salt/base/init/files/
vim /srv/salt/base/init/files/zabbix_agentd.confcode
Server={{ Server }}blog
6.將zabbix_agent配置包括含在初始化文件中
vim /srv/salt/base/init/env_init.slsdns
include: - init.dns - init.history - init.audit - init.sysctl - init.zabbix_agent
7.執行配置變動:
# salt '*' state.highstateit