## Run
# keep only last line in apt sources
salt -C '*' cmd.run "sed -i '$ ! s/^.*$//g' /etc/apt/sources.list.d/*"
# run command on all hosts except dbs*
salt -C '* and not E@dbs*' cmd.run 'apt-get update; apt-get dist-upgrade -y'
## handy
# upgradable packages
salt \* cmd.run "apt-get --just-print upgrade |grep 'upgraded' |grep 'installed'"|xargs | sed -e 's/upgraded\./upgraded\n/g' |sort | grep -v '0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded'
## Aggregate output
#http://russell.ballestrini.net/filter-salt-stack-return-data-output/
cat <<-EOF > filter.py
#!/usr/bin/python
from json import loads
from json import dumps
import fileinput
stdin_lines = [line for line in fileinput.input()]
ret = loads(''.join(stdin_lines))
for minion_id, data in ret.items():
print(minion_id)
print('='*len(minion_id))
for key, value in ret[minion_id].items():
if value['changes'] or value['result'] == False:
print('')
print(dumps(value, indent=4))
print('')
EOF
chmod +x $_
sudo salt-call --out=json state.highstate | ./filter.py
sudo salt '*' --out=json --timeout=60 --static state.highstate | ./filter.py