2. SaltStack Data System

1. SaltStack Data System

Grains (cereals)

Pillar (pillar)

2.Grains

Grains kept the Salt gathered when the start command, do not collect runtime

2.1 Information inquiry

 Collect assets

Card, ip , the CPU ....

(1) the underlying collection system msg

[root@linux-node1 ~]# salt '*' grains.ls
[root@linux-node1 ~]# salt '*' grains.items

 

 (2) a single query

[root@linux-node1 ~]# salt '*' grains.item fqdn
[root@linux-node1 ~]# salt '*' grains.get fqdn
[root@linux-node1 ~]# salt '*' grains.get ip4_interfaces

  

2.2 匹配minion

在所有centos上执行,

所有开机的虚拟机上执行

[root@linux-node1 ~]# salt -G 'os:CentOS' cmd.run 'uptime'
[root@linux-node1 ~]# salt -G 'init:systemd' cmd.run 'uptime'

2.3 top.sls中匹配minion

[root@linux-node1 ~]# vim /srv/salt/base/top.sls

2.4 配合模板来做判断

pillar中使用

 

 2.5 如何配置?

1.Minion配置文件中的grains (不推荐了)

 修改配置文件

vim /etc/minion

 

systemctl restart salt-minion

 

在所有角色是memcache上执行

 

 

 

 

grians配置文件

 

新建 grins

:后面必须有空格

 

重启服务minion

[root@host-192-168-23-39 master]# systemctl restart salt-minion

[root@host-192-168-23-39 master]# systemctl status salt-minion

 

执行命令

 

Guess you like

Origin www.cnblogs.com/venicid/p/11265816.html