在使用 SaltStack 对主机进行批量管理的时候,因为不同的服务器组所做的业务功能不同,因此为了更加方便的管理,势必要对主机进行分组管理。

参考 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.

Saltstack 分组管理相关推荐

  1. 介绍 Saltstack批量管理文件和计划任务

    saltstack是由thomas Hatch于创建的一个开源项目,设计初衷是为了实现一个快速的远程执行系统.用来管理你的基础架构,可轻松管理成千上万台服务器.本文主要演示使用saltstack来管理 ...

  2. android qq分组展开,Android仿qq分组管理的第三方库

    本文实例为大家分享了Android仿qq分组管理的第三方库,供大家参考,具体内容如下 下面先看效果 我们点击展开与折叠分组的功能在库里面是已经封装好的,只能把它已入到项目中,就可以直接用了,十分的方便 ...

  3. c#扩展方法奇思妙用高级篇四:对扩展进行分组管理

    从系列文章开篇到现在,已经实现的很多扩展了,但过多的扩展会给我们带来很多麻烦,试看下图: 面对这么多"泛滥"的扩展,很多人都会感到很别扭,的确有种"喧宾夺主"的 ...

  4. 城市智慧路灯综合管理平台、图监控、灯箱实时监控、策略管理、故障报警、灯具管理、数据统计、故障分析、开关灯记录分析、区域管理、分组管理、DIV+CSS布局设计、HTML/Bootstrp/jQuery

    源码类别: 后台模板     文件大小: 21.5 MB    源码内容:城市智慧路灯综合管理平台后台模板 前端技术: HTML/CSS/Bootstrap/jQuery    模板语言: 简体中文  ...

  5. 资源组 —— 助你轻松解决单账户内的资源分组管理难题

    最近,阿里云ResourceManager服务新增了"资源组管理"功能,以帮助客户解决企业内部多用户.多项目的资源分级管理难题.使用资源组管理,您可以对单个云账号下多个地域.多种资 ...

  6. 领英工具:如何使用领英精灵在领英上有序归类分组管理客户?

    领英精灵专业针对全球最大的职场社交平台LinkedIn领英设计研发,专注于帮助每一位用户正确高效的在LinkedIn领英上积累开发客户. 强大的领英精灵为每一位用户赋能,让每一位用户借助领英精灵最大化 ...

  7. PC免费简约开源的TXT小说阅读器(提取章节、书籍分组管理、记忆阅读进度、换肤、换字体、换主题)仅支持Windows

    最近自己做了个小说阅读器,就是下面这个东西啦,目前仅支持Window系统 个人喜欢在电脑.平板上等大屏幕设备上阅读小说或电子书籍.原因其一是屏幕足够大,可以选择更舒服的字体大小:其二是觉得小屏幕看字体 ...

  8. saltstack 分组

    1.为什么要分组 使用saltstack可以在很大程度上简化我们的工作,特别是在机器特别多的场景,并且业务较复杂的情况下,因此分组就显得非常重要了. 2.定义分组 1 2 3 4 5 root@mas ...

  9. 腾讯QQ分组管理小分析——陌生人加入讨论组

    今天在想分组管理的问题,无意间看到了QQ的分组,感觉QQ的分组管理的挺方便的,想学习学习,于是就做了一次实验测试了一番,哈哈,发现了QQ讨论组的"陌生人加入"问题.这绝对是个问题, ...

最新文章

  1. [转]ISTQB FL初级认证考试资料(中文)
  2. Cell子刊:中科院遗传发育所周俭民组发现特异靶向病原菌致病力的植物天然产物并阐明作用机制
  3. 安装截图软件shutter
  4. Spring+hibernate里使用jdbc connection
  5. Spring+SpringMVC项目搭建
  6. CMSampleBufferRef 转换为UIImage
  7. MySQL的索引及优化方案
  8. [Bzoj4260]Codechef REBXOR(trie树)
  9. html 完全复制div中的内容_LOL手游现在远非完全体,未来还有哪些端游内容会加入手游中?...
  10. 通过mvn dependency:tree 查看依赖树,解决依赖jar冲突问题
  11. 天然气表怎么看多少方_上海考大学难度怎么样?看2019上海高考“成绩分布表”和“本科分数线”就知道了!...
  12. 信息学奥赛一本通C++语言——1105:数组逆序重存放
  13. Sendmail邮件服务器搭建与配置笔记
  14. big sur java home_无法在macOS Big Sur上运行Eclipse
  15. 冒险岛无敌外挂代码诠释
  16. artDialog | 经典的网页对话框组件
  17. 让Excel工作簿中宏自动运行的两种方法
  18. Java整合PayPal支付结账和支出
  19. 怎么进入 BAT 的研发部门?
  20. 【案例练习】13—41个网页设计效果的代码生成器工具

热门文章

  1. 软件库Library之静态库\动态库和静态加载\动态加载
  2. Python创建类似Matlab中的cell数组
  3. matlab查找集合中某个元素的位置/Struct结构体某个字段值的位置
  4. PageOffice产品简介
  5. pageoffice 破解 php,pageoffice for php
  6. 推荐一款免费实用的报表工具
  7. 地心地固坐标系(ECEF)与站心坐标系(ENU)的转换
  8. 【cartographer】园区场景自动驾驶-利用GPS实现ENU坐标系下的建图与定位
  9. 中大计算机留美教授,悲痛!中大教授逝世,年仅42岁
  10. 怎么搭建xss平台云服务器,最详细搭建xss平台