jtyhrew222 发表于 2017-2-21 09:32:52

saltstack 分组

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.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
# /etc/init.d/salt-master restart
Stopping salt-master daemon:                               [确定]
Starting salt-master daemon:                               [确定]
# salt -N group01 test.ping
node02.saltstack.com:
    True
node01.saltstack.com:
    True
# salt -N group02 test.ping
node01.saltstack.com:
    True
node02.saltstack.com:
    True
# salt -N group03 test.ping
node01.saltstack.com:
    True
node02.saltstack.com:
    True
# salt -N group01 cmd.run 'uptime'
node02.saltstack.com:
   22:34:22 up4:25,0 users,load average: 0.00, 0.00, 0.00
node01.saltstack.com:
   22:34:22 up4: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
PGrains PCRE匹配P@os:(RedHat|Fedora|CentOS)
Lminions列表L@node01.saltstack.com,node02.saltstack.com or openstack*.saltstack.com
IPillar glob匹配I@pdata:foobar
S子网/IP地址匹配S@10.10.10.0/24 or S@10.10.10.140
RRange cluster匹配R@foo.bar
DMinion Data匹配D@key:value

页: [1]
查看完整版本: saltstack 分组