-
正則匹配
# salt -E '192*' test.ping [WARNING ] Cannot resolve address None info via socket: <class 'socket.gaierror'> 192.168.0.62: True
列表匹配
#salt -L Minion,Minion1 test.pingGrians匹配
#salt -G 'os:MacOS' test.ping
其中os:MacOS是一組鍵值對(duì)組匹配
#salt -N groups test.ping.復(fù)合匹配
#salt -C 'G@os:MacOS or L@Minion1'
支持使用and 和or 關(guān)聯(lián)多個(gè)條件Pillar值匹配
#salt -I 'key:value' test.pingCIDR匹配
#salt -s '192.168.1.0/24' test.ping
管理對(duì)象屬性:
Grains是saltstack組件中非常重要的組件之一
Grains是saltstack記錄Minion的一些靜態(tài)信息的組件,可以簡(jiǎn)單理解為Grains里面記錄著每臺(tái)Minion的常用屬性比如:CPU武通,內(nèi)存,磁盤,網(wǎng)絡(luò)信息怔球。
可以通過:grains.items查看某臺(tái)Minion的所有Grains信息
簡(jiǎn)單Grains的命令:
#salt '192.168.0.62' sys.list_functions grains
列出grains開頭的
#salt '192.168.0.62' sys.list_functions
列出所有
# salt '192.168.0.62' sys.doc grains.append
查看幫助信息
數(shù)據(jù)管理中心
Pillar在saltstack中主要作用就是存儲(chǔ)和定義配置管理中需要的一些數(shù)據(jù)敛纲,比如:軟件版本號(hào)遣钳,用戶名密碼等信息荐类。
# cat minion | grep -C 4 pillar_roots
# Salt caches should be cleared.
#hash_type: sha256
# The Salt pillar is searched for locally if file_client is set to local. If
# this is the case, and pillar data is defined, then the pillar_roots need to
# also be configured on the minion:
#pillar_roots:
# base:
# - /srv/pillar
# Set a hard-limit on the size of the files that can be pushed to the master.
知識(shí)補(bǔ)充:
如果在只是想匹配模式的上下幾行肃叶,grep可以實(shí)現(xiàn)蹂随。
$grep -5 'parttern' inputfile //打印匹配行的前后5行
$grep -C 5 'parttern' inputfile //打印匹配行的前后5行
$grep -A 5 'parttern' inputfile //打印匹配行的后5行
$grep -B 5 'parttern' inputfile //打印匹配行的前5行
在Master 配置文件中有一段Pillar setting選項(xiàng)專門定義Pillar相關(guān)的參數(shù):
- 查看所有module列表
#salt '*' sys.list_modules - 查看指定module的所有function
#salt '*' sys.list_functions cmd - 查看指定module用法
#salt '*' sys.doc cmd - saltstack默認(rèn)支持一次執(zhí)行多個(gè)Module
#salt '*' test.echo,cmd.run
states是saltstack中的配置語言
- 查看所有states列表
#salt '*' sys.list_state_modules - 查看指定states的所有function
#salt '*' sys.list_state_functions file - 查看file.states的詳細(xì)用法與例子
#salt '*' sys.state_doc file.rename