saltstack实战-6
為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??
saltstack除了salt命令外還有一些其他命令也可以用來(lái)輔助管理客戶端節(jié)點(diǎn),例如:salt-run、salt-key、salt-cp、salt-call、salt-ssh、salt-api
salt-run
????salt-run是一個(gè)前端命令,用來(lái)執(zhí)行salt runners。salt runners是在master上執(zhí)行的一些簡(jiǎn)單的模塊,重點(diǎn)是在master上執(zhí)行的,不是在minion端
--version 打印當(dāng)前運(yùn)行的salt版本 --versions-report 打印程序的依賴性和版本號(hào) -h, --help 查看幫助信息 -c CONFIG_DIR, --config-dir=CONFIG_dir 設(shè)置配置文件的目錄,這個(gè)目錄默認(rèn)在master和minion上市通用的。默認(rèn)的配置文件目錄是/etc/salt。 -t TIMEOUT, --timeout=TIMEOUT 等待minion回復(fù)消息的超時(shí)時(shí)間,超時(shí)時(shí)間指定了命令行客戶端等待多長(zhǎng)時(shí)間去向minion查詢并檢查執(zhí)行的job,默認(rèn)是1。 -d, --doc, --documentation 顯示runner的幫助文檔。 -l LOG_LEVEL, --log-level=LOG_LEVEL 設(shè)置日志相關(guān)信息,在命令行設(shè)置的log信息會(huì)覆蓋配置文件的日志配置,該參數(shù)設(shè)置在console中顯示的日志級(jí)別,主要有以下級(jí)別 all, garbage, trace, debug, info, warning, error, quiet. 默認(rèn)是: warning. --log-file=LOG_FILE 設(shè)置日志文件的位置,默認(rèn)是:/var/log/salt/master. --log-file-level=LOG_LEVEL_LOGFILE 該參數(shù)設(shè)置在日志文件中顯示日志的級(jí)別,主要有以下級(jí)別 all, garbage, trace, debug, info, warning, error, quiet. 默認(rèn)是: warning.
salt-key
salt-key:簡(jiǎn)單的管理salt服務(wù)器端的公鑰
-q, --quiet 安靜模式,取消輸出內(nèi)容 -y, --yes 對(duì)所問(wèn)的問(wèn)題回答yes,默認(rèn)是False --log-file=LOG_FILE 默認(rèn)是 /var/log/salt/minion. --log-file-level=LOG_LEVEL_LOGFILE 該參數(shù)設(shè)置在日志文件中顯示日志的級(jí)別,主要有以下級(jí)別 all, garbage, trace, debug, info, warning, error, quiet. 默認(rèn)是: warning. --out 替換默認(rèn)的返回?cái)?shù)據(jù)的顯示格式,主要支持以下格式:grains, highstate, json, key, overstatestage, pprint, raw, txt, yaml 如果你的返回?cái)?shù)據(jù)不支持你指定的顯示數(shù)據(jù)的格式,則salt默認(rèn)使用pprint格式 如果你使用 --out=json返回格式,,你可能希望使用--static模式.。如果沒(méi)有使用static選項(xiàng),你會(huì)在所有的minion客戶端得到JSON字符串,這取決于你是否使用了一個(gè)迭代的outputter,所以建議你使用 --static --out-indent OUTPUT_INDENT, --output-indent OUTPUT_INDENT 打值印輸出值中的縮進(jìn), 負(fù)值則禁用縮進(jìn),只適用于支持縮進(jìn)的 outputters --out-file=OUTPUT_FILE, --output-file=OUTPUT_FILE 指定輸出到一個(gè)文件 --no-color 不顯示顏色 --force-color 強(qiáng)制顯示顏色 綠色表示成功,紅色表示失敗,藍(lán)色表示有改動(dòng),但是成功執(zhí)行,黃色表示配置未來(lái)會(huì)改變 -l ARG, --list=ARG 列出公鑰,參數(shù) pre, un, 和unaccepted 會(huì)列出 unaccepted/unsigned keys, acc oraccepted 會(huì)列出accepted/signed keys.,rej or rejected會(huì)列出rejected keys,最后, all 列出所有keys -L, --list-all 列出所有的公鑰 -a ACCEPT, --accept=ACCEPT 接受一個(gè)指定的客戶端公鑰 -A, --accept-all 接受所有被阻止的客戶端公鑰 -r REJECT, --reject=REJECT 拒絕指定的客戶端公鑰 -R, --reject-all 拒絕所有被阻止的客戶端公鑰 -p PRINT, --print=PRINT 打印指定的客戶端公鑰 -P, --print-all 打印所有的客戶端公鑰 -d DELETE, --delete=DELETE 刪除指定的客戶端公鑰 -D, --delete-all 刪除所有的客戶端公鑰 -f FINGER, --finger=FINGER 打印指定公鑰的指紋 -F, --finger-all 打印所有公鑰的指紋 --gen-keys=GEN_KEYS Set a name to generate a keypair for use with salt --gen-keys-dir=GEN_KEYS_DIR Set the directory to save the generated keypair. Only works with 'gen_keys_dir' option; default is the current directory. --keysize=KEYSIZE Set the keysize for the generated key, only works with the '--gen-keys' option, the key size must be 2048 or higher, otherwise it will be rounded up to 2048. The default is 2048.
salt-cp
????salt-cp:拷貝一個(gè)本地文件到所有匹配的minion客戶端
-t TIMEOUT, --timeout=TIMEOUT 超時(shí)時(shí)間,默認(rèn)是5 -E, --pcre 使用PCRE正則配置minion客戶端 -L, --list 具體列出要拷貝到的minion客戶端名稱 -G, --grain 根據(jù)minion客戶端的grain來(lái)區(qū)分拷貝地址 --grain-pcre 使用PCRE正則匹配grain的返回值來(lái)確定要拷貝的minion客戶端 -N, --nodegroup 根據(jù)分配的組來(lái)確定拷貝地址 -R, --range Instead of using shell globs to evaluate the target, use a range expression to identify targets. Range expressions look like %cluster. Using the Range option requires that a range server is set up and the location of the range server is referenced in the master configuration file.
salt-call
????salt-call:在minion本地運(yùn)行module的功能,而不是在master上遠(yuǎn)程控制minion來(lái)運(yùn)行module
-g, --grains 返回grains生成的信息 -m MODULE_DIRS, --module-dirs=MODULE_DIRS 從一個(gè)指定的目錄獲取模塊,多個(gè)目錄可以用逗號(hào)分開(kāi) --master=MASTER 設(shè)置一個(gè)master,該minion客戶端必須在這個(gè)master上經(jīng)過(guò)認(rèn)證,如果沒(méi)有進(jìn)行設(shè)置,則默認(rèn)會(huì)從minion的配置文件中獲取master地址,如果有多個(gè)master,則第一個(gè)生效 --return RETURNER 設(shè)置salt-call把返回的數(shù)據(jù)發(fā)送到一個(gè)或者多個(gè)returner接口,如果返回到多個(gè)returnners接口,多個(gè)接口之間用逗號(hào)分隔即可 --local 在本地運(yùn)行salt-call,就好像沒(méi)有master在運(yùn)行一樣。
salt-ssh
? ? salt-ssh:允許你使用ssh協(xié)議在客戶端執(zhí)行命名,而不需要安裝master
-r, --raw, --raw-shell 執(zhí)行一個(gè)原始的shell命令 --priv 指定一個(gè)私鑰進(jìn)行驗(yàn)證 --roster 指定哪個(gè)roster系統(tǒng)要被使用,可以是database、scanner、custom roster,默認(rèn)是平面文件roster系統(tǒng) --roster-file 指定默認(rèn)的roster本地文件位置,默認(rèn)的文件名是roster,位置在master的/etc/salt//roster --refresh, --refresh-cache q強(qiáng)制刷新master上的緩存數(shù)據(jù),這種情況一般出現(xiàn)在minion的grains已經(jīng)變化了的情況 --max-procs 同時(shí)和多少minion進(jìn)行通訊,啟動(dòng)的進(jìn)程越多則通訊的速度越快,默認(rèn)是25 -i, --ignore-host-keys 忽視ssh主機(jī)keys,默認(rèn)情況下連接要征求同意 --passwd 在連接進(jìn)行認(rèn)證時(shí)設(shè)置默認(rèn)的密碼 --key-deploy Set this flag to attempt to deploy the authorized ssh key with all minions. This combined with --passwd can make initial deployment of keys very fast and easy. ???? /etc/salt/roster文件的格式如下:
web1:host: IP # The IP addr or DNS hostnameuser: test # Remote executions will be executed as user fredpasswd: xxxxx
轉(zhuǎn)載于:https://my.oschina.net/guol/blog/337200
總結(jié)
以上是生活随笔為你收集整理的saltstack实战-6的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【转】JCR期刊分区及其检索方法
- 下一篇: 【沟通的艺术】你能勾住你的听众么?