现在我有6台主机,要将他们进行分组,这样管理起来比较方便
比如redhat、centos、各自分组。
ddcluster1,hddcluster2,hddcluster3,hddcluster4,salt-master,salt-minion01
修改master的配置文件中的nodegroups
vim /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‘ nodegroups: redhat-group: ‘L@hddcluster1,hddcluster2,hddcluster3,hddcluster4‘ centos-group: ‘L@salt-master,salt-minion01‘ redhat-centos-group: ‘L@hddcluster1,salt-minion01‘
不需要重启master
[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
原文:https://www.cnblogs.com/fat-girl-spring/p/14814071.html