1、为什么要分组
使用saltstack可以在很大程度上简化我们的工作,特别是在机器特别多的场景,并且业务较复杂的情况下,因此分组就显得非常重要了。
2、定义分组
1
2
3
4
5
|
root@master salt] # vim /etc/salt/master
nodegroups: group01: 'L@node01.saltstack.com,node02.saltstack.com'
group02: 'S@10.10.10.0/24'
group03: 'E@node0[1-2].saltstack.com'
|
3、根据自己定义的分组进行测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@master salt] # /etc/init.d/salt-master restart
Stopping salt-master daemon: [确定] Starting salt-master daemon: [确定] [root@master salt] # salt -N group01 test.ping
node02.saltstack.com: True
node01.saltstack.com: True
[root@master salt] # salt -N group02 test.ping
node01.saltstack.com: True
node02.saltstack.com: True
[root@master salt] # salt -N group03 test.ping
node01.saltstack.com: True
node02.saltstack.com: True
[root@master salt] # salt -N group01 cmd.run 'uptime'
node02.saltstack.com: 22:34:22 up 4:25, 0 users , load average: 0.00, 0.00, 0.00
node01.saltstack.com: 22:34:22 up 4:25, 1 user, load average: 0.00, 0.00, 0.00
|
4、关于saltstack分组的补充信息
参数 | 含义 | 举例 |
G | Grains glob匹配 | G:os:ubuntu |
E | PCRE Minion id匹配 | E@web\d+\. (dev|qa|prod)\.loc |
P | Grains PCRE匹配 | P@os:(RedHat|Fedora|CentOS) |
L | minions列表 | L@node01.saltstack.com,node02.saltstack.com or openstack*.saltstack.com |
I | Pillar glob匹配 | I@pdata:foobar |
S | 子网/IP地址匹配 | S@10.10.10.0/24 or S@10.10.10.140 |
R | Range cluster匹配 | R@foo.bar |
D | Minion Data匹配 | D@key:value |
本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1899375,如需转载请自行联系原作者