'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 1:[1]

We can get the list of minions using the Salt runner manage module.

Since we are targeting the minions by grains, the master would have to send the command to minions to know which of them match.

Using the up function for example:

salt-run manage.up tgt="G@somegrain:value and G@othergrain:value" tgt_type=compound

Then there are some functions that don't send command to minion, and hence they'll be faster to respond. Though they allow filtering only by IP address. One such example is alived.

List all minions that are considered to be up:

salt-run manage.alived

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 seshadri_c