标签:lis col 远程 alt tar class nio 开发 cut
1.通配符匹配
2.正则表达式匹配
3.List支持
4.Grains匹配
5.IP地址匹配
6.混合匹配
7.Node groups
salt ‘<target>‘ <function> [arguments]
[root@linux-node1 salt]# salt "*" test.ping linux-node1.example.com: True linux-node2.example.com: True [root@linux-node1 salt]# salt "*node1*" test.ping linux-node1.example.com: True
[root@linux-node1 salt]# salt -E "linux-node[0-1].example.com" test.ping linux-node1.example.com: True [root@linux-node1 salt]# salt -E "linux-node[0-2].example.com" test.ping linux-node1.example.com: True linux-node2.example.com: True
[root@linux-node1 salt]# salt -L "linux-node1.example.com,linux-node2.example.com" "test.ping" linux-node2.example.com: True linux-node1.example.com: True
[root@linux-node1 salt]# salt -G ‘os:CentOS‘ test.ping linux-node1.example.com: True linux-node2.example.com: True [root@linux-node1 salt]# salt -G ‘cpuarch:x86_64‘ test.ping linux-node1.example.com: True linux-node2.example.com: True
root@linux-node1 salt]# salt -S "192.168.56.0/255.255.255.0" test.ping #注意不支持 255.255.255.0子网掩码写法 No minions matched the target. No command was sent, no jid was assigned. ERROR: No return received [root@linux-node1 salt]# salt -S "192.168.56.0/24" test.ping linux-node1.example.com: True linux-node2.example.com: True [root@linux-node1 salt]# salt -S "192.168.56.11" test.ping linux-node1.example.com: True
[root@linux-node1 salt]# salt -C ‘S@192.168.56.11 or E@linux-node[0-2].example.com‘ test.ping linux-node1.example.com: True linux-node2.example.com: True
nodegroups: group1: ‘L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com‘ group2: ‘G@os:Debian and foo.domain.com‘ group3: ‘G@os:Debian and N@group1‘
1.混合匹配不建议使用,看起来有些乱
2.List模式在平时维护的时候用的少,但是在二次开发建议用Grains采集到数据,然后select拼接成list再调用后端api去执行
3.控制并发可以使用 batch size,简写 -b 如果是1就串行,也支持百分比如 -b 50%
[root@linux-node1 salt]# salt ‘*‘ -b 1 test.ping Executing run on [‘linux-node2.example.com‘] linux-node2.example.com: True retcode: 0 Executing run on [‘linux-node1.example.com‘] linux-node1.example.com: True retcode: 0
百分比使用方法
[root@linux-node1 salt]# salt ‘*‘ -b 50% test.ping Executing run on [‘linux-node2.example.com‘] linux-node2.example.com: True retcode: 0 Executing run on [‘linux-node1.example.com‘] linux-node1.example.com: True retcode: 0
附:英文参考文档
https://www.unixhot.com/docs/saltstack/topics/tutorials/modules.html#target
https://www.unixhot.com/docs/saltstack/topics/targeting/index.html
标签:lis col 远程 alt tar class nio 开发 cut
原文地址:http://www.cnblogs.com/xiewenming/p/7711977.html