saltstack - 如何获得与谷物或柱子相匹配的仆从?

saltstack - how to get minions that match a grain or pillar?

有没有更简单的方法来获取与特定谷物或柱子匹配的仆从列表?假设我想知道我所有的 Ubuntu 18.x 主机。今天我运行:

$ sudo salt -G oscodename:bionic test.ping | awk -F: '/:/{print }' | sort 

我想有两个问题(强调第二个问题):

希望这是一个非常基本的问题。任何指向涵盖此内容的文档的指针都将不胜感激。我的 google-fu 在这一点上让我失望了。

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?

master 发布一个工作(在本例中为 test.ping),所有连接的 minions 都听从 master,并检查该工作是否适用于它们或 not.It 是否适用于每个 minion做这个检查。

Is there a more efficient way of getting to that info?

我不这么认为。要过滤小兵,你必须发布一个工作,所以我认为它非常有效。

关于高手:

salt -G oscodename:bionic --preview-target

输出是匹配该粒度的 minions 列表:

- minion1
- minion2

任何适用于 minion targeting 的参数都有效,包括 -I 的支柱,甚至同时具有 -C 的谷物和支柱。