自动化运维工具--Saltstack写sls语法批量部署zabbix_agent

Posted by Yancy on 2015-11-01

Saltstack批量部署zabbix_agent服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
epel_install:
file.managed:
- name: /root/zabbix-release-2.4-1.el6.noarch.rpm ## 指定节点的epel安装包的存放路径
- source: salt://epel/zabbix-release-2.4-1.el6.noarch.rpm ## 指定从master的哪个位置拷贝epel的rpm包
- user: root ## 文件的拥有者
- group: root ## 文件的所属组
- mode: 777
- backup: minion
cmd.run:
- name: rpm -ivh /root/zabbix-release-2.4-1.el6.noarch.rpm ## 执行rpm包的安装
- unless: test -f /etc/yum.repos.d/epel.repo ## 如果存在这个文件就不再执行安装程序
- require:
- file: epel_install
SELINUX:
cmd.run:
- name: service iptables stop && chkconfig iptables off && setenforce 0
#sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
- require:
- file: epel_install
cache_yum:
cmd.run:
- name: yum makecache ## 生成yum的缓存
- require:
- file: epel_install ## 生成缓存要在epel安装之后
zabbix-agentd:
pkg.installed: []
service.running:
# - name: zabbix-agent
# - running
- enable: True
- reload: True
- watch:
- file: /etc/zabbix/zabbix_agentd.conf
- require:
- file: epel_install
/etc/zabbix/zabbix_agentd.conf:
file.managed:
- source: salt://zabbix/zabbix_agentd.conf
- user: zabbix ## 文件的拥有者
- group: zabbix ## 文件的所属组
- mode: 644
- backup: minion
- template: jinja
- require:
- file: epel_install
ntp:
pkg.installed: [] ## 安装ntp
# name: ntp
service.running:
# name: ntpd
# running
enable: True
reload: True
watch:
file: /etc/ntp.conf
require: ## 安装ntp要在epel安装之后
file: epel_install
/etc/ntp.conf:
file.managed:
- source: salt://ntp/ntp.conf
- user: root ## 文件的拥有者
- group: root ## 文件的所属组
- mode: 644
- backup: minion
- require:
- file: epel_install