Profile photo

from miller import blake

Hello, I'm a Seattle-based site reliabililty engineering manager, I get paid to do what I love, I like Python, I'm in an abusive relationship with JavaScript, I'm a fan of good design, and I don't think things always have to be so stupid.
You can follow me @bltmiller, subscribe via RSS, and email me.

Diff Files Across Salt Minions

Simple file management in Salt is trivial with the file.managed function, and it can quickly get extended with some Jinja templating. Say, for instance, each collection of minions for a given data center has its own NTP server it needs to hit, then you might like a way to check that each minion’s NTP config file is identical without having to run a high state. Of course templating abstracts problems like this away, but in environments where it’s possible for manual changes to sneak in, this becomes useful.

Seeing a single file’s contents from many minions is trivial with:

salt 'web*' 'cat /etc/ntp.conf'

Now, to quickly get a diff across each of those files, use:

salt-run survey.diff 'web*' 'cat /etc/ntp.conf'

The survey runner will take the results of the selected execution module, in this case, and will aggregate the results into pools of the unique results.

The only limitation I ran into is that this runner only supports globbing on targets, so targeting by grains, pillar data, or node groups isn’t really straightforward. Check the SaltStack documentation for more information on how the survey runner works.

comments powered by Disqus

Copyright © 2020, Blake Miller. All rights reserved. | Sitemap · RSS