saltstack 分组

1、为什么要分组

使用saltstack可以在很大程度上简化我们的工作,特别是在机器特别多的场景,并且业务较复杂的情况下,因此分组就显得非常重要了。

2、定义分组

[email protected] salt]# vim /etc/salt/master
nodegroups:
  group01: ‘[email protected],node02.saltstack.com‘
  group02: ‘[email protected]/24‘
  group03: ‘[email protected][1-2].saltstack.com‘

3、根据自己定义的分组进行测试

[[email protected] salt]# /etc/init.d/salt-master restart
Stopping salt-master daemon:                               [确定]
Starting salt-master daemon:                               [确定]
[[email protected] salt]# salt -N group01 test.ping
node02.saltstack.com:
    True
node01.saltstack.com:
    True
[[email protected] salt]# salt -N group02 test.ping
node01.saltstack.com:
    True
node02.saltstack.com:
    True
[[email protected] salt]# salt -N group03 test.ping
node01.saltstack.com:
    True
node02.saltstack.com:
    True
[[email protected] salt]# salt -N group01 cmd.run ‘uptime‘
node02.saltstack.com:
     22:34:22 up  4:25,  0 users,  load average: 0.00, 0.00, 0.00
node01.saltstack.com:
     22:34:22 up  4:25,  1 user,  load average: 0.00, 0.00, 0.00

4、关于saltstack分组的补充信息

参数 含义 举例
G Grains glob匹配 G:os:ubuntu
E PCRE Minion id匹配  [email protected]\d+\. (dev|qa|prod)\.loc
P Grains PCRE匹配 [email protected]:(RedHat|Fedora|CentOS)
L minions列表 [email protected],node02.saltstack.com or openstack*.saltstack.com
I Pillar glob匹配 [email protected]:foobar
S 子网/IP地址匹配 [email protected]/24 or [email protected]
R Range cluster匹配 [email protected]
D Minion Data匹配 [email protected]:value
时间: 2024-08-25 11:21:21

saltstack 分组的相关文章

Saltstack系列:Saltstack分组

关于Saltstack分组的混合匹配:(Compound matchers) 1.修改配置文件,添加组. [[email protected] ~]# vim /etc/salt/master nodegroups:   group1: '[email protected],node3'   group2: '[email protected]'   group3: '[email protected]/24'   group4: '[email protected][2-3]' [[email

SaltStack学习笔记

一.安装部署 实验环境: Server : 192.168.0.41 Client-1: 192.168.0.42 Client-2: 192.168.0.43 1.安装epel源. rpm -Uvh http://mirrors.sohu.com/fedora-epel/6Server/x86_64/epel-release-6-8.noarch.rpm 2. 服务端安装salt-master,客户端安装salt-minion 3. 修改客户端配置文件/etc/salt/minion 修改两个

1.salt install

salt install(2013-12-09) salt master  ip1   hostname salt minion  ip2 1.vim /etc/hosts cat >> /etc/hosts <<EOF ip1 nginx ip2 cm1 EOF 2.master端需要4505,4506. minion端需要开放sport为4505端口 yum -y install  salt-master yum -y install  salt-minion cat /etc

【saltstack学习笔记之六】salt的分组

分组的类型    -G    Grains glob匹配    //比如:[email protected]:Ubuntu    -E    PCRE Minion id匹配    //比如:[email protected]\d+\.(dev|qa|prod)\.loc    -P    Grains PCRE匹配    //比如:[email protected]:(RedHat|Fedora|CentOS)    -L    minions列表    //比如:[email protect

saltstack将minion客户端分组批量处理

现在我有6台主机,要将他们进行分组,这样管理起来比较方便 比如redhat.centos.各自分组. ddcluster1,hddcluster2,hddcluster3,hddcluster4,salt-master,salt-minion01 修改master的配置文件中的nodegroups vim /etc/salt/master #nodegroups: #  group1: '[email protected],bar.domain.com,baz.domain.com or bl*

saltstack的探索-salt指定目标和分组

一.探讨一下,如何针对指定的minion id来执行 先了解官网文档的targeting这一节的内容: Targeting Salt allows for minions to be targeted based on a wide range of criteria. The default targeting system uses globular expressions to match minions, hence if there are minions named larry1, 

SaltStack 入门到精通 - 第一篇: 安装SaltStack

实际环境的设定: 系统环境: centos6 或centos5 实验机器: 192.168.1.100 软件需求: salt 套件,及其需求环境 实验目的: 成功安装salt,并实现salt主从间通讯 特殊设置: 其它目的: 安装SaltStack(下面简称为salt) epel安装:salt安装需要epel源支持,所以在安装salt前需要先安装epel包 # centos5 下载下面rpm  wget -O    epel.rpm https://dl.fedoraproject.org/pu

SaltStack 入门到精通 - 第七篇: Targeting

什么是Targeting? Targeting minions 是指那些minion会作为运行命令或是执行状态的目标.这些目标可以是一个主机名,系统信息,定义的分组,甚至是自定义的绑定的对象. 例如命令  salt web1 apache.signal restart 可以重启ID 为web1的minion的apache.当然也可以在top文件中使用web1来作为目标匹配的内容: base:   'web1':     - webserver Targing 有哪些匹配方式? Minion Id

Saltstack Automatic grouping

一.要点: 知道key验证存放的目录 key在验证是手动还自动 对不在线的主机的处理 minion_id的命名规范 二.使用的技术栈 saltstack 相关的库:salt.config,salt.client,salt.runner 使用redis 存放两个数据库,第一个为存为字典,用于存放minion_id与物理IP的对应,另一个存为集合,用于项目_业务命名的方式包含相应的主机 使用watchdog对目录变更监控,事件触发机制 三.完整代码 # coding:utf8 # Created b