salt分组配置
我是以ip地址作为minion的id,这样在master上管理的时候,一目了然的知道是哪台minion。要是有dns的支持就更好了,直接规范主机名。
一、依靠nodegroups
编辑master的配置文件:
加入一行:default_include: include/group.conf
编辑default_include: include/group.conf:
nodegroups:
lvs: ‘[email protected],192.168.122.103‘
dns: ‘[email protected]‘
之后在命令行可以这样执行:
salt -N lvs test.ping
salt -N lvs test.ping
salt-cp -N lvs /var/www/html/soft/lvs/install_lvs.sh /tmp/install_lvs.sh
salt的nodegroup结合sls文件做按组操作。
vim /etc/salt/master
interface: 0.0.0.0
publish_port: 4505
user: root
worker_threads: 5
ret_port: 4506
root_dir: /
pki_dir: /etc/salt/pki/master
keep_jobs: 24
timeout: 5
state_top: top.sls
file_roots:
base:
– /srv/salt
pillar_roots:
base:
– /srv/pillar
log_file: /var/log/salt/master
log_level: warning
default_include: include/group.conf
vim /etc/salt/include/group.conf
nodegroups:
lvs: ‘[email protected],192.168.122.103‘
dnsmasq: ‘[email protected],192.168.122.101,192.168.122.102,192.168.122.103‘
————
[[email protected] salt]# ls /srv/salt/
dnsmasq mypkgs myscript top.sls
vim /srv/salt/top.sls
base:
‘dnsmasq‘:
– match: nodegroup
– dnsmasq
‘lvs‘:
– match: nodegroup
– myscript.lvs
—