Chinaunix首页 | 论坛 | 博客
  • 博客访问: 315252
  • 博文数量: 61
  • 博客积分: 365
  • 博客等级: 一等列兵
  • 技术积分: 611
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-04 11:39
文章分类

全部博文(61)

文章存档

2017年(15)

2016年(13)

2015年(19)

2014年(12)

2013年(2)

我的朋友

分类: 系统运维

2015-07-01 17:01:44

怎么安装salt,我就不多说了,前面有说过
1、首先上框架吧,树结构:

点击(此处)折叠或打开

  1. [root@host138 salt]# tree
  2. .
  3. |-- snmp
  4. | |-- snmpd.conf
  5. | `-- snmp.sls
  6. |-- top.sls
  7. `-- zabbix
  8.     |-- conf.sls
  9.     |-- files
  10.     | |-- zabbix_agentd
  11.     | |-- zabbix_agentd.conf
  12.     | `-- zabbix.tar.gz
  13.     |-- init.sls
  14.     `-- install.sls


 2、snmp是上次装的,这次装zabbix,先看top.sls

点击(此处)折叠或打开

  1. [root@host138 salt]# cat top.sls
  2. base:
  3.   '*':
  4.     - zabbix.init


3、进入zabbix目录,init.sls,相当于一个安装和配置的汇总

点击(此处)折叠或打开

  1. [root@host138 zabbix]# cat init.sls
  2. include:
  3.   - zabbix.install
  4.   - zabbix.conf


4、安装zabbix,添加zabbix用户

点击(此处)折叠或打开

  1. [root@host138 zabbix]# cat init.sls
  2. include:
  3.   - zabbix.install
  4.   - zabbix.conf
  5. [root@host138 zabbix]# cat install.sls
  6. zabbix_source:
  7.   file.managed:
  8.     - name: /tmp/zabbix.tar.gz
  9.     - source: salt://zabbix/files/zabbix.tar.gz
  10.     - user: root
  11.     - group: root
  12.     - mode: 644
  13. extract_zabbix:
  14.   cmd.run:
  15.     - cwd: /tmp
  16.     - names :
  17.       - tar zxvf zabbix.tar.gz -C /soft
  18.     - require:
  19.       - file: zabbix_source
  20. zabbix_user:
  21.   user.present:
  22.     - name: zabbix
  23.     - createhome: False
  24.     - gid_from_name: True
  25.     - shell: /sbin/nologin


5、修改配置文件,添加服务

点击(此处)折叠或打开

  1. [root@host138 zabbix]# cat conf.sls
  2. zabbix_conf:
  3.   file.managed:
  4.     - name: /soft/zabbix/etc/zabbix_agentd.conf
  5.     - source: salt://zabbix/files/zabbix_agentd.conf
  6.     - template: jinja
  7.     - defaults:
  8.       Hostname: {{ grains['ip_interfaces']['eth1'][0] }}
  9. zabbix_service:
  10.   file.managed:
  11.     - name: /etc/init.d/zabbix_agentd
  12.     - user: root
  13.     - mode: 755
  14.     - source: salt://zabbix/files/zabbix_agentd
  15.   cmd.run:
  16.     - names:
  17.       - /sbin/chkconfig --add zabbix_agentd
  18.       - /sbin/chkconfig zabbix_agentd on
  19.   service.running:
  20.     - name: zabbix_agentd
  21.     - enable: True
  22.     - watch:
  23.       - file: /soft/zabbix/etc/zabbix_agentd.conf



ok了,就这样解决了,执行salt -N xxoo state.highstate
关于批量主机会有返回Minion did not return. [No response]的情况,请修改master的timeout=15,默认是5秒
阅读(1271) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~