四、saltstack如何管理对象?

 

 

实验前环境:

[root@super65 ~]# salt-key -L
[root@super65 ~]# salt-key -a super65.cn -y

 

salt管理对象简介:

saltstack管理的对象叫做target。

管理的对象很多是我们需要对不同的对象进行分类。saltstack是如何做到分类的呢?

saltstack管理对象时能够做到自动化还是要依赖对象的ID的,所有在前期规划好target的ID是非常重要的。

 

1、正则匹配

 

[root@super65 ~]# salt -E "super.*" test.ping
super66:
  True
super65.cn:
  True

[root@super65 ~]# salt -E "super.*cn$" test.ping
super65.cn:
  True

 

2、列表匹配

[root@super65 ~]# salt -L super66,super65.cn test.ping
super66:
  True
super65.cn:
  True
[root@super65 ~]# salt -L super66 test.ping
super66:
  True

 

3、Grians匹配

 

[root@super65 ~]# salt -G "os:CentOS" test.ping
super66:
  True
super65.cn:
  True

 

grians是saltsatack自定义记录minion静态信息的组件(比如记录cpu、内存、、)。

查看grians帮助:

[root@super65 ~]# salt 'super66' sys.doc grains

 

4、组匹配

定义组(需要在master配置文件中定义)

[root@super65 ~]# salt -N group1 test.ping
super66:
  True
[root@super65 ~]# salt -N group2 test.ping
super66:
  True
super65.cn:
  True

 

5、CIRD匹配

[root@super65 ~]# salt -S "192.168.1.0/24" test.ping
super66:
  True
super65.cn:
  True

 

6 、复合匹配(支持上面的匹配规则用and 、or关联)

 

7 、Pillar值匹配(Pillar系统中可以自定义键值对)

 

posted @ 2016-09-17 10:23  xuanhui  阅读(186)  评论(0编辑  收藏  举报