A little while ago we switched from Puppet to using SaltStack to orchestrate and manage configuration on our fleet of servers and workstations. The main reason for the switch was Salt’s modular design - everything is pluggable. You don’t like the default Jinja templating language? Switch to Genshi, Mako or, our favourite, PyObjects renderer instead. You don’t want to store job data in files on the master? Send it to a Kafka topic, Elasticsearch, HipChat or one of several databases. Or write your own.
As our state coverage grew, a need arose to easily see what states apply to a given minion. show_highstate function from the state module gives us a verbose output of the highstate in all its glory and we could, with the help of the likes of awk and | get the list of state names alone, but thats tedious. Here’s a snippet of show_highstate call, formatted in YAML (default output format for highstate); the name of the state is the value of the sls associative array:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Instead, we achieve what we need with a few lines of Python, using the Python client API:
Put this script on your master and run it as root, giving it a minion ID as an argument. Here it is in action:
1 2 3
Didn’t I say that Salt is cool?