saltstack cheatsheet summary (key && compound matcher)
来源:互联网 发布:如何看b超单数据 编辑:程序博客网 时间:2024/04/27 15:02
Salt key management
Matching the minion id
1.Globbing
example:
Listing all Salt key registration requests1.salt-key -LAccepting all Salt key requests:1.salt-key -AAccepting a single Salt key request, where minion_id is the name of the Minion:1.salt-key -a minion_idRemoving the key of a Salt Minion, where minion_id is the name of the Minion:1.salt-key -d minion_idRemoving all the key of Salt minions1.salt-key -D
Query Salt in order to find out what Minions are online, offline or maybe even show both
salt-run manage.up # Shows what Minions are upsalt-run manage.down # Shows what Minions are down or not connectedsalt-run manage.status # Shows both online and offline Minions
Matching the minion id
1.Globbing
Match all minions:salt '*' test.pingMatch all minions in the example.net domain or any of the example domains:salt '*.example.net' test.pingsalt '*.example.*' test.pingMatch all the webN minions in the example.net domain (web1.example.net, web2.example.net … webN.example.net):salt 'web?.example.net' test.pingMatch the web1 through web5 minions:salt 'web[1-5]' test.pingMatch the web1 and web3 minions:salt 'web[1,3]' test.pingMatch the web-x, web-y, and web-z minions:salt 'web-[x-z]' test.ping2.Regular expressions
Match both web1-prod and web1-devel minions:salt -E 'web1-(prod|devel)' test.pingusing regular expressions in a State's top filebase: 'web1-(prod|devel)': - match: pcre - webserver3.Lists
salt -L 'web1,web2,web3' test.ping
Compound matchers
Letter Match Type Example
G@os:Ubuntu
EPCRE Minion IDE@web\d+\.(dev|qa|prod)\.loc
PGrains PCREP@os:(RedHat|Fedora|CentOS)
LList of minionsL@minion1.example.com,minion3.domain.comor bl*.domain.com
IPillar globI@pdata:foobar
SSubnet/IP addressS@192.168.1.0/24
orS@192.168.1.100
RRange clusterR@%foo.bar
Matchers can be joined using boolean and
,or
, and not
operators.
eg:
salt -C 'webserv* and G@os:Debian or E@web-dc1-srv.*' test.pingThat same example expressed in a top file looks like the following:base: 'webserv* and G@os:Debian or E@web-dc1-srv.*': - match: compound - webserverNote that a leading not is not supported in compound matchessalt -C '* and not G@kernel:Darwin' test.pingExcluding a minion based on its ID is also possible:salt -C '* and not web-dc1-srv' test.pingMatches can be grouped together with parentheses to explicitly declare precedence amongst groups.salt -C '( ms-1 or G@id:ms-3 ) and G@id:ms-3' test.ping
example:
salt '*' sys.docsalt -E '.*' cmd.run 'ls -l | grep foo'salt -L foo.bar.baz,quo.qux cmd.run 'ps aux | grep foo'salt '*' grains.itemssalt -G 'os:Fedora' test.pingsalt '*' pillar.itemssalt 'supply.*' network.ip_addrssalt '*' saltutil.refresh_pillarsalt '*' pillar.item mine_functionssalt '*' mine.get '*' grains.itemssalt -C 'G@circle:live and G@data_volume_attached:True'salt '*' state.sls sfym.appsalt -C 'E@^((?!frontline).)*$' cmd.run 'dpkg --purge nginx'salt -C 'E@^((?!frontline).)*$' cmd.run 'rm -rf /etc/nginx/'salt '*' state.highstate test=Tr
0 0
- saltstack cheatsheet summary (key && compound matcher)
- Selenium learning key points summary
- saltstack实现ssh key公钥分发
- Cassandra中primarykey,composite/compound key,partition key ,clustering key的区别
- saltstack
- saltstack
- Saltstack
- Saltstack
- SaltStack
- saltstack
- SaltStack
- saltstack
- saltstack
- SaltStack
- SaltStack
- Matcher
- Matcher
- Python CheatSheet
- kgtmtfgkmfrtj
- 程序员须知道的11条
- nginx 灰度发布(基于cookies)
- BestCoder Round 38-1002 Greatest Greatest Common Divisor
- ryjejeyj
- saltstack cheatsheet summary (key && compound matcher)
- 每天一点hadoop第六篇(搭建伪分布)
- visual studio 宏不能运行的解决方法
- poj1166
- 2015编程之美资格赛 回文子序列个数
- jghkgtul
- 黑马程序员——IO小结
- front_end面试
- Android设置布局背景为白色的三种方法