SaltStack:有没有办法只在输出中显示失败和警告?


9

小兵上运行state.applystate.highstate可能导致数百行输出。有时只有一个小兵就足够了。

...
Summary for my_minion
--------------
Succeeded: 112 (changed=78)
Failed:      6
Warnings:    1
--------------
Total states run:     118
Total run time:     4.958 s

有没有办法只在输出中显示失败和警告?

Answers:


9

更改state_output主机的配置文件。

也可以覆盖从命令行输出的状态,例如:

salt '*' state.apply --state-output=mixed

请参阅文档,以获取有关的更多信息state-output


4

我通常使用:

salt '*' state.apply -l quiet --state-verbose=false

仅显示更改/失败状态


2

您可以使用JSON输出,然后使用过滤掉成功的条目jq

salt-run jobs.lookup_jid 20180318whatever --out=json | \
jq 'map_values(with_entries(select(.value.result|not)))'
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.