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[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,如需转载请自行联系原作者
目录
相关文章
|
消息中间件 监控 网络协议
SaltStack安装Apache/Mysql/PHP部署Wordpress
SaltStack是一个服务器基础架构集中化管理平台,具备配置管理、远程执行、监控等功能,基于Python语言实现,结合轻量级消息队列(ZeroMQ)与Python第三方模块(Pyzmq、PyCrypto、Pyjinjia2、python-msgpack和PyYAML等)构建。 SaltStack 采用 C/S模式,server端就是salt的master,client端就是minion,minion与master之间通过ZeroMQ消息队列通信。 master监听4505和4506端口,4505对应的是ZMQ的PUB system,用来发送消息,4506对应的是REP system是来接受
234 0
|
关系型数据库 应用服务中间件 测试技术