国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 操作系統(tǒng) > 正文

Saltstack 分組管理

2024-06-28 15:59:26
字體:
供稿:網(wǎng)友

在使用 SaltStack 對主機(jī)進(jìn)行批量管理的時(shí)候,因?yàn)椴煌姆?wù)器組所做的業(yè)務(wù)功能不同,因此為了更加方便的管理,勢必要對主機(jī)進(jìn)行分組管理。

參考 SaltStack 的官方文檔

https://docs.saltstack.com/en/latest/topics/targeting/nodegroups.html

Nodegroups are declared using a compound target specification. The compound target documentation can be foundhere.

The nodegroups master config file parameter is used to define nodegroups. Here's an example nodegroup configuration within /etc/salt/master:

nodegroups:  group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com or bl*.domain.com'  group2: 'G@os:Debian and foo.domain.com'  group3: 'G@os:Debian and N@group1'  group4:    - 'G@foo:bar'    - 'or'    - 'G@foo:baz'

Note

The L within group1 is matching a list of minions, while the G in group2 is matching specific grains. See thecompound matchers documentation for more details.

New in version 2015.8.0.

Note

Nodegroups can reference other nodegroups as seen in group3. Ensure that you do not have circular references. Circular references will be detected and cause partial expansion with a logged error message.

New in version 2015.8.0.

Compound nodegroups can be either string values or lists of string values. When the nodegroup is A string value will be tokenized by splitting on whitespace. This may be a PRoblem if whitespace is necessary as part of a pattern. When a nodegroup is a list of strings then tokenization will happen for each list element as a whole.

To match a nodegroup on the CLI, use the -N command-line option:

salt -N group1 test.ping

Note

The N@ classifier cannot be used in compound matches within the CLI or top file, it is only recognized in thenodegroups master config file parameter.

To match a nodegroup in your top file, make sure to put - match: nodegroup on the line directly following the nodegroup name.

base:  group1:    - match: nodegroup    - webserver

Note

When adding or modifying nodegroups to a master configuration file, the master must be restarted for those changes to be fully recognized.

A limited amount of functionality, such as targeting with -N from the command-line may be available without a restart.

DEFINING NODEGROUPS AS LISTS OF MINION IDS

A simple list of minion IDs would traditionally be defined like this:

nodegroups:  - group1: L@host1,host2,host3

They can now also be defined as a YAML list, like this:

nodegroups:  - group1:    - host1    - host2    - host3

New in version 2016.11.0.

USING NODEGROUPS IN SLS FILES

To use Nodegroups in Jinja logic for SLS files, the pillar_opts option in /etc/salt/master must be set to True. This will pass the master's configuration as Pillar data to each minion.

Note

If the master's configuration contains any sensitive data, this will be passed to each minion. Do not enable this option if you have any configuration data that you do not want to get on your minions.

Also, if you make changes to your nodegroups, you might need to run salt '*' saltutil.refresh_pillar after restarting the master.

Once pillar_opts is set to True, you can find the nodegroups under the "master" pillar. To make sure that only the correct minions are targeted, you should use each matcher for the nodegroup definition. For example, to check if a minion is in the 'webserver' nodegroup:

nodegroups:  webserver: 'G@os:Debian and L@minion1,minion2'
{% if grains.id in salt['pillar.get']('master:nodegroups:webserver', [])and grains.os in salt['pillar.get']('master:nodegroups:webserver', []) %}...{% endif %}

Note

If you do not include all of the matchers used to define a nodegroup, Salt might incorrectly target minions that meet some of the nodegroup requirements, but not all of them.


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 金乡县| 那坡县| 宁国市| 扶风县| 和田市| 七台河市| 咸阳市| 崇明县| 宕昌县| 佳木斯市| 交口县| 玉环县| 鹤庆县| 长寿区| 忻城县| 呼伦贝尔市| 吐鲁番市| 紫阳县| 枣庄市| 武邑县| 淳化县| 博湖县| 勐海县| 鄂托克前旗| 岳池县| 武定县| 大港区| 绥滨县| 湖北省| 博爱县| 昌乐县| 涞源县| 邹平县| 英吉沙县| 滦南县| 龙门县| 泊头市| 晋城| 漳州市| 枝江市| 盘山县|