Search code examples
salt-project

How do I check what minions a command will target, without running it?


Consider this command line: salt -C 'G@some:grain:value and G@other:grain:value' state.highstate

I want to check that the targeting string will hit the minions I expect it to hit. Highstate is quite slow even in test mode. The obvious alternative is to run test.ping instead, but even that can take a very long time if some minions are down. Salt must have some way to get this information (otherwise it wouldn't know to stop when all targeted minions have returned), but I can't figure out how to get it myself.


Solution

  • Apparently there is an option that does this, it's just not documented in the man page: salt $target --preview-target will show you the minions expected to match $target, without running anything against them or otherwise blocking. Also works fine in conjunction with the target-mode options (e.g. -N, -G, or -C).

    Credit to this answer for enlightening me.