Quick Tip: Execute a Single State ID from a Named SaltStack Module

Last week, I was working on enabling SaltStack Beacons in our environment to notify my team if one or more of a number of important system configuration files is modified and part of the configuration process involves defining your chosen beacon(s) in the Minon’s configuration file. Manually defining becons on a single Minion is a pretty painless process, but manually defining the same beacons across our entire environment wasn’t something I wanted to do. Thankfully, we manage our Minion configruation file with Salt (yes, Salt can salt itself…with a few caveats) so I was able to define the Beacon configruation once and push it out to our entire environment. However, I didn’t want to execute the entire module the managed file is part of.

So, I dug through the SaltStack documentation until I found state.sls_id. State.sls_id lets you run a single state ID from a module which was exactly what I wanted to do. State.sls_id can be executed from the command line just like any other execution module using the following syntax:

(NOTE: In the example above the state ID is /etc/salt/minion and base is the module name.)

Executing a single state ID from a module can be super useful if you don’t want to execute an entire module to make a simple change in your environment.


Leave a Reply

Your email address will not be published. Required fields are marked *