saltstack初窥——targeting

targeting:引号中以实现很强大的minion的过滤与匹配技术

官方文档:http://docs.saltstack.com/topics/targeting/compound.html

几种不同的匹配方式:

###

默认:shell通配符

salt ‘*’ test.ping

G: Grains glob

salt -G ‘os:redhat’ test.ping

salt -G ‘osrelease:5.2’ test.ping

salt ‘*’ grains.items 获取更多Grains glob

E: 正则表达式

salt -E ‘web5-8(8|9)’ test.ping

salt -E ‘web\d’ test.ping

L: List of minions (列表)

salt -L ‘minion1,minion2’ test.ping

#注:只能针对多个minion,不能针对多个组

N: nodegroup (分组)

salt -N ‘group1’ test.ping

S: Subnet/IP address(IP/子网)

salt -S ‘10.0.1.0/24’ test.ping

salt -S ‘10.0.1.1’ test.ping

C: 复合匹配

salt -C ‘webserv and G@os:Debian or E@web-dc1-srv.‘ test.ping

I: Pillar glob

salt -I ‘apache:httpd’ test.ping

R: Range cluster

暂时没有搞明白

P: Grains PCRE

测试不存在