Thursday, March 26, 2015

Cron with Saltstack

I was wanting to only be emailed changes, errors and other oddities from within saltstack.

salt * state.highstate | sed -n '/domain.suffix/{:start /Total states run:/!{N;b start};/Total states run:     [^0]/p}'

Replace domain.suffix with your domain suffix to get this going.
-n Don't print every line
domain.suffix - Mark this line as the start of the block.
Total states run: - End of the block
Total states run:     [^0] - Match all that have not 0 changes

Now that we have that let's cron that and it'll send emails about what has changed.