Reputation: 2263
Is there an easier way to get a list of minions that match a particular grain or pillar? Let's say I want to know all my Ubuntu 18.x hosts. Today I run:
$ sudo salt -G oscodename:bionic test.ping | awk -F: '/:/{print $1}' | sort
I guess there's two questions (emphasis on the second q):
Hopefully this is a really basic question. Any pointers to the documentation that covers this would be appreciated. My google-fu failed me on this one.
Upvotes: 1
Views: 2446
Reputation: 2213
On the master:
salt -G oscodename:bionic --preview-target
The output is the list of minions matching that grain:
- minion1
- minion2
Any parameter works which works for minion targeting, that includes pillars with -I
or even both grains and pillars at the same time with -C
.
Upvotes: 3
Reputation: 720
Does the master know ahead of time the grains/pillars of the minions or does it blast out the query to all the minions and let them decide if they match?
The master publish a job (test.ping in this case), and all connected minions listen to the master, and check if the job apply to them or not.It's up to each minion to do this check.
Is there a more efficient way of getting to that info?
I don't think so. To filter minions you'll have to publish a job, so i think it's pretty efficient.
Upvotes: 2