50

我有相当广泛的盐配置,我希望能够看到发生了什么变化。如果我只是运行,salt '*' state.highstate我会得到整个列表,其中包含存在且未更改的内容 - 例如 3 到 4 个日志屏幕。但我真的很想只看到在上一份工作中发生变化的事情。

它不必为盐调用工作,它也可以使用salt-run jobs.lookup_jid.

4

6 回答 6

38

我们还添加state_output: mixed了它将为您提供与 相同的输出terse,除非出现故障,在这种情况下,它将为您提供更详细的输出。

于 2013-06-11T23:32:08.577 回答
38

您可以设置state_verbose: False/etc/salt/master/etc/salt/minion。如果要将输出缩短为每个状态一行,请设置state_output: terse.

您还可以在命令行上传递这些过滤器:

salt --state-output=terse '*' state.highstate

如果您只想查看更改,可以使用state-output=changesstate-output=mixed。后一个将显示有关失败的更多信息。

有关更多详细信息,请参阅以下答案:basepipsarossy

于 2013-04-13T03:10:59.010 回答
24

To actually answer the question, yes, there is an output filter for changes only:

salt '*' state.highstate --state-output=changes

This will display one liners for things that are in the right state and the proper output for the changes. ie:

  <...>
  Name: /etc/sudoers - Function: file.managed - Result: Clean
  Name: /etc/timezone - Function: file.managed - Result: Clean
  Name: /etc/pki/tls/certs/logstash-forwarder.crt - Function: file.managed - Result: Clean
  Name: /etc/init.d/logstash-forwarder - Function: file.managed - Result: Clean
----------
          ID: /etc/logstash-forwarder
    Function: file.managed
      Result: True
     Comment: File /etc/logstash-forwarder updated
     Started: 14:14:28.580950
    Duration: 65.664 ms
     Changes:
              ----------
              diff:
                  ---
                  +++
                  @@ -1,6 +1,6 @@
                   {
                     "network": {
                  -    "servers": [ "10.0.0.104:5000" ],
                  +    "servers": [ "10.0.0.72:5000" ],
                       "timeout": 15,
                       "ssl ca": "/etc/pki/tls/certs/logstash-forwarder.crt"
                     },

  Name: deb http://packages.elasticsearch.org/logstashforwarder/debian stable main - Function: pkgrepo.managed - Result: Clean
  Name: logstash-forwarder - Function: pkg.installed - Result: Clean
  <...>
于 2015-02-03T12:20:59.900 回答
14

There are 2 options, first is to change the state_output in master's configuration file, like mentioned in the accepted answer, and it also possible to override the state output in command line, like:

salt --state-output=mixed \* test.version
于 2014-04-25T22:32:38.327 回答
5

从以下合并到 Salt 2015.8.0 ( https://github.com/saltstack/salt/pull/26962 ) 的 PR 开始,现在可以state_verbose在运行 highstate 时从命令行切换标志。这会覆盖您可以/etc/salt/master在之前的答案中提到的配置。

以下命令现在应该只显示来自 highstate 运行的更改和错误salt '*' state.highstate --state-verbose=False

于 2015-11-18T18:09:09.917 回答
1

您可以使用以下内容将输出缩短为一行,然后过滤该输出以仅显示更改:

salt -v 'minion' state.highstate test=True --state-output=terse --state-verbose=False

于 2019-06-14T06:44:17.147 回答