52

I have quite extensive salt config and I want to be able to see what has changed. If I just run salt '*' state.highstate I got the whole list with things that were present and not changed - like 3 to 4 screens of log. But I'd really like to see only things that changed in the last job.

It doesn't have to work for the salt call, it can also employ salt-run jobs.lookup_jid.

Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82

6 Answers6

39

You can set state_verbose: False in /etc/salt/master or /etc/salt/minion. If you want to shorten the output to one line per state, set state_output: terse.

You can also pass these filters on command line:

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

If you only want to see changes, you can use state-output=changes or state-output=mixed. The latter one will show more information on a failure.

See the following answers fore more detail: basepi, psarossy

Michael Krupp
  • 2,042
  • 3
  • 19
  • 36
38

We've also added state_output: mixed which will give you the same output as terse, except if there's a failure, in which case it will give you the more verbose output.

Colton Myers
  • 1,321
  • 9
  • 12
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
  <...>
psarossy
  • 340
  • 3
  • 6
  • 1
    what's the difference between state_output=mixed and state_output=changes? – eMBee Aug 25 '18 at 07:11
  • 2
    @eMBee `mixed` output has a terse output for changes. You should see a single line for all results. `changes` shows the full diff for a change at the end of the run. You probably want `changes`. – J.W.F. Jun 04 '19 at 16:09
  • @eMBee - you should ask this as a new question. It's documented in `/etc/salt/master` on your salt-master host. – keithpjolley Jul 06 '20 at 13:55
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
Alex Simenduev
  • 846
  • 7
  • 6
5

As of the following PR that was merged into Salt 2015.8.0 (https://github.com/saltstack/salt/pull/26962) it is now possible to toggle the state_verbose flag from command line when running highstate. This overrides the config you can set in /etc/salt/master that was mentioned in previous answers.

The following command should now display only the changes and errors from a highstate run salt '*' state.highstate --state-verbose=False

Grokzen
  • 81
  • 1
  • 2
2

You can use the below to shorten the output in one line and then filter that output to show only the changes:

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

Pier
  • 351
  • 2
  • 4
  • 16
  • Please help fighting the misconception that StackOverflow is a free code writing service, by augmenting your code-only answer with some explanation. Also, have a look here https://stackoverflow.com/editing-help – Yunnosch Jun 14 '19 at 06:46