Using jq with SaltStack Output

Many of the windows-oriented or windows-themed exec and state modules in SaltStack return large, indivisible units of data back to the command line. I know the "real solution" here is to plug salt into an advanced/complex returner mechanism with it's own DB and UI, but not everybody is on the outscaling growth trajectory and destined for legions of minions. For the rest of us small-time ops/admins, there's a nice, obscure tool called jq that will filter the salt data for you right inline: a real unix paradigm conformer. Suppose you want to know only about which of your windows minions are set to auto update and watch for updates for other Microsoft products:

salt -G 'kernel:Windows' win_wua.get_wu_settings --out=json | jq -r 'keys[] as $k | "\($k):\n  level:     \(.[$k] | ."Notification Level")\n  MS update: \(.[$k] | . "Microsoft Update")"'
jerry:
  level:     1
  MS update: false
kevin:
  level:     4
  MS update: true
stuart:
  level:     4
  MS update: false
dave:
  level:     2
  MS update: false
carl:
  level:     3
  MS update: true

Also characteristic of traditional command line utilities, jq's syntax is not amenable to quick comprehension or mastery. Indeed here are the resources I used to construct the above query:

  • jq Manual: Well-appearing but mostly designed for someone with much more open and/or flexible time than I. Perhaps you would read this if you were a college student with no friends or family during winter break.
  • Selecting object values: found via jq select -jquery.

Obliquely topical obligatory XKCD (Bonus: 4!):

Posted: | Source