怎么安装salt,我就不多说了,前面有说过
1、首先上框架吧,树结构:
-
[root@host138 salt]# tree
-
.
-
|-- snmp
-
| |-- snmpd.conf
-
| `-- snmp.sls
-
|-- top.sls
-
`-- zabbix
-
|-- conf.sls
-
|-- files
-
| |-- zabbix_agentd
-
| |-- zabbix_agentd.conf
-
| `-- zabbix.tar.gz
-
|-- init.sls
-
`-- install.sls
2、snmp是上次装的,这次装zabbix,先看top.sls
-
[root@host138 salt]# cat top.sls
-
base:
-
'*':
-
- zabbix.init
3、进入zabbix目录,init.sls,相当于一个安装和配置的汇总
-
[root@host138 zabbix]# cat init.sls
-
include:
-
- zabbix.install
-
- zabbix.conf
4、安装zabbix,添加zabbix用户
-
[root@host138 zabbix]# cat init.sls
-
include:
-
- zabbix.install
-
- zabbix.conf
-
[root@host138 zabbix]# cat install.sls
-
zabbix_source:
-
file.managed:
-
- name: /tmp/zabbix.tar.gz
-
- source: salt://zabbix/files/zabbix.tar.gz
-
- user: root
-
- group: root
-
- mode: 644
-
extract_zabbix:
-
cmd.run:
-
- cwd: /tmp
-
- names :
-
- tar zxvf zabbix.tar.gz -C /soft
-
- require:
-
- file: zabbix_source
-
zabbix_user:
-
user.present:
-
- name: zabbix
-
- createhome: False
-
- gid_from_name: True
-
- shell: /sbin/nologin
5、修改配置文件,添加服务
-
[root@host138 zabbix]# cat conf.sls
-
zabbix_conf:
-
file.managed:
-
- name: /soft/zabbix/etc/zabbix_agentd.conf
-
- source: salt://zabbix/files/zabbix_agentd.conf
-
- template: jinja
-
- defaults:
-
Hostname: {{ grains['ip_interfaces']['eth1'][0] }}
-
zabbix_service:
-
file.managed:
-
- name: /etc/init.d/zabbix_agentd
-
- user: root
-
- mode: 755
-
- source: salt://zabbix/files/zabbix_agentd
-
cmd.run:
-
- names:
-
- /sbin/chkconfig --add zabbix_agentd
-
- /sbin/chkconfig zabbix_agentd on
-
service.running:
-
- name: zabbix_agentd
-
- enable: True
-
- watch:
-
- file: /soft/zabbix/etc/zabbix_agentd.conf
ok了,就这样解决了,执行salt -N xxoo state.highstate
关于批量主机会有返回Minion did not return. [No response]的情况,请修改master的timeout=15,默认是5秒
阅读(1325) | 评论(0) | 转发(0) |