Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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.

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
  <...>

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

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top