Search code examples
automationsalt-projectdevops

targeting salt minions using multiple grains


In our infrastructure, we set multiple grains on the minion including an 'environment' and 'component' grain. Based on this, there can be multiple minions with the same component name, each in a different environment. I want to be able to select minions based on multiple grains instead of having to define several node groups on the master.

I have tried:

salt -G 'component:api,environment:prod' test.ping

Which seems not to work, I have looked their their documentation fairly extensively and have found no examples of this type of minion targeting.

Is this even possible, and if so, how would I go about doing it?


Solution

  • I just came across the info I was looking for but apparently missed earlier. This can be done with compound matching

    salt -C 'G@environment:prod and G@component:accounts' test.ping
    

    More documentation can be found here: http://docs.saltstack.com/en/latest/topics/targeting/compound.html