Topic: https://russell.ballestrini.net/filter-salt-stack-return-data-output/
hide preview

What's next? verify your email address for reply notifications!

someguy-rb 9y, 216d ago

Thank you. I set up a local Salt on a server using salt-call, using your script in crontab, so for anyone else who might want to do the same thing:

In order to run salt-call every 20 minutes from crontab and get mail when something gets changed, comment out line 13 and 14, the ones that print minion_id and "=" signs, and add this line to /etc/crontab: */20 * * * * root salt-call --local state.highstate --out=json -l quiet | /path/to/filter.py

hide preview

What's next? verify your email address for reply notifications!

atejedadev-rb 9y, 74d ago

Thanks for the post, useful!

I changed a little bit to have the parsing when a new line gets in (for long term operations) instead to wait for the end stream and then parse the data.

BTW: I used the raw output.

r = { 
    "True"  : "true", 
    "False" : "false", 
    "\""    : "\\\"",
    "\'"    : "\"" 
}

for l in fileinput.input():
    for k in r: l = l.replace(k,r[k])
    j = loads(l)
    print j
remark link
hide preview

What's next? verify your email address for reply notifications!

atejedadev-rb 9y, 74d ago

Related to my previous comment, there's probably missing replacements that can be added down the road. The code is just an example but you will get it.

hide preview

What's next? verify your email address for reply notifications!

russell 9y, 72d ago

Welcome!

hide preview

What's next? verify your email address for reply notifications!