5

Is it possible to run a SaltStack command that, say, looks to see if a process is running on a machine, and aggregate the results of running that command on multiple minions?

Essentially, I'd like to see all the results that are returned from the minions displayed in something like an ASCII table. Is it possible to have an uber-result formatter that waits for all the results to come back, then applies the format? Perhaps there's another approach?

Bryan
  • 2,205
  • 1
  • 23
  • 43

2 Answers2

3

If you want to do this entirely within Salt, I would recommend creating an "outputter" that displays the data how you want.

A "highstate" outputter was recently created that might give you a good starting point. The highstate outputter creates a small summary table of the returned data. It can be found here:

https://github.com/saltstack/salt/blob/develop/salt/output/highstate.py

I'd recommend perusing the code of the other outputters as well.

If you want to use another tool to create this report, I would recommend adding "--out json" to your command at the cli. This will cause Salt to return the data in json format which you can then pipe to another application for processing.

Utah_Dave
  • 4,531
  • 24
  • 23
  • Also, for states specifically, you might look into `terse` or `mixed` state output. Check out the master config template for more information, the option is in there. – Colton Myers Aug 08 '13 at 16:12
  • Thanks for the link! Does indeed look like a good starting point. Can you also provide a link to where this outputter is called? I need to understand how the return data from all the minions is getting aggregated before being passed to the outputter. – Bryan Aug 09 '13 at 13:27
1

This was asked a long time ago, but I stumbled across it more than once, and I thought another approach might be useful – use the survey Salt runner:

$ salt-run survey.hash '*' cmd.run 'dpkg -l python-django'
|_
  ----------
  pool:
      - machine2
      - machine4
      - machine5
  result:
      dpkg-query: no packages found matching python-django
|_
  ----------
  pool:
      - machine1
      - machine3
  result:
      Desired=Unknown/Install/Remove/Purge/Hold
      | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
      |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
      ||/ Name           Version      Architecture Description
      +++-==============-============-============-=================================
      ii  python-django  1.4.22-1+deb all          High-level Python web development
M Somerville
  • 4,499
  • 30
  • 38