现在我有6台主机,要将他们进行分组,这样管理起来比较方便
比如redhat、centos、各自分组。
1
|
ddcluster1,hddcluster2,hddcluster3,hddcluster4,salt-master,salt-minion01
|
修改master的配置文件中的nodegroups
vim /etc/salt/master
1
2
3
4
5
6
7
8
9
10
11
12
|
#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'
nodegroups:
redhat-group:
'L@hddcluster1,hddcluster2,hddcluster3,hddcluster4'
centos-group:
'L@salt-master,salt-minion01'
redhat-centos-group:
'L@hddcluster1,salt-minion01'
|
不需要重启master
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
[root@salt-master ~]
# salt -N redhat-group test.ping
hddcluster3:
True
hddcluster1:
True
hddcluster4:
True
hddcluster2:
True
[root@salt-master ~]
# salt -N centos-group test.ping
salt-master:
True
salt-minion01:
True
[root@salt-master ~]
#
[root@salt-master ~]
# salt -N centos-group cmd.run 'df -h'
salt-master:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root
50G 5.0G 46G 10% /
devtmpfs 3.9G 0 3.9G 0%
/dev
tmpfs 3.9G 116K 3.9G 1%
/dev/shm
tmpfs 3.9G 41M 3.8G 2%
/run
tmpfs 3.9G 0 3.9G 0%
/sys/fs/cgroup
/dev/sda2
494M 133M 362M 27%
/boot
/dev/sda1
200M 9.5M 191M 5%
/boot/efi
/dev/mapper/centos-home
873G 1.3G 872G 1%
/home
tmpfs 786M 20K 786M 1%
/run/user/42
tmpfs 786M 4.0K 786M 1%
/run/user/0
tmpfs 3.9G 16K 3.9G 1%
/tmp
salt-minion01:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
6.5G 805M 5.4G 13% /
tmpfs 245M 12K 245M 1%
/dev/shm
/dev/vda1
477M 30M 422M 7%
/boot
[root@salt-master ~]
#
[root@salt-master ~]
# salt -N redhat-centos-group test.ping
salt-minion01:
True
hddcluster1:
True
|
本文转自 yanconggod 51CTO博客,原文链接:http://blog.51cto.com/yanconggod/1876599