盐堆:谷物与支柱 [英] salt stack: grains vs pillars

查看:32
本文介绍了盐堆:谷物与支柱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

盐系统中有谷物和支柱.我了解如何分配自定义谷物,但什么时候考虑使用支柱更好?

In the Salt system there are grains and pillars. I understand how I can assign custom grains, but when would it be better to consider using pillars?

推荐答案

这里的根本区别在于,您可以将自定义粒度设置为 minion 的固有属性,而 pillar 需要在某个时候分配给 minion.

The fundamental difference here is that you can set a custom grain as an innate property of a minion, versus pillar which needs to be assigned to a minion at some point.

例如,有两种实用的方法可以为 minion 分配角色:minion id 或使用自定义谷物.然后,您可以像这样匹配 top.sls 文件中的 minion id 或自定义谷物:

For example, there are two practical ways to assign a role to a minion: the minion id or using custom grains. You can then match against the minion id or custom grains inside your top.sls file like so:

# salt/top.sls
base:
  # match against custom grain
  'G@role:webserver':
    - match: compound
    - webserver
  'G@role:search':
    - match: compound
    - elasticsearch
  # match against minion id
  'minion_db*':
    - database

你不能用柱子做这个.虽然你确实可以用柱子瞄准,但你首先需要一种方法来将柱子分配给你的仆从(这必须是仆从 id,或者上面提到的谷物).考虑如何在 pillar 顶部文件中分配 pillar,您需要使用 minion 的先天属性来分配此 pillar 数据.

You CANNOT do this with pillar. While you can indeed target with pillar, you first need a way to assign pillar to to your minions (this must be minion id, or grains as stated above). Think about how you would assign pillar in the pillar top file, you need to assign this pillar data using an innate attribute of the minion.

# pillar/top.sls
base:
  'G@env:dev':
    - match: compound
    - dev_settings
  'G@env:prod':
    - match: compound
    - prod_settings

这里的模式是您使用谷物(或小黄人 ID)作为设置小黄人的类型/角色/环境的最小方式.之后,您使用支柱数据为其提供所有适当的详细设置.

The pattern here is that you use grains (or minion id) as a minimal way to set type/role/environment of your minion. After that, you use pillar data to feed it all the appropriate detailed settings.

这篇关于盐堆:谷物与支柱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆