基于salt-syndic和salt-ssh安装部署saltstack

初始salt-syndic

salt-syndic如果大家知道zabbix proxy的话那就可以很容易理解了,syndic的意思为理事,其实如果叫salt-proxy的话那就更好理解了,它就是一层代理,如同zabbix proxy功能一样,隔离master与minion,使其不需要通讯,只需要与syndic都通讯就可以,这样的话就可以在跨机房的时候将架构清晰部署了

salt-syndic的部署

[root@server4 keepalived]# yum  install salt-master -y
[root@server4 keepalived]# vim /etc/salt/master
#允许开启多层master

这里写图片描述

[root@server1 _modules]# yum  install -y salt-syndic
[root@server1 _modules]# vim  /etc/salt/master

这里写图片描述

[root@server1 ~]# /etc/init.d/salt-master stop
Stopping salt-master daemon:                               [  OK  ]
[root@server1 ~]# /etc/init.d/salt-master start
Starting salt-master daemon:                               [  OK  
[root@server1 ~]# /etc/init.d/salt-syndic start
[root@server4 keepalived]# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
server1
Rejected Keys:
[root@server4 keepalived]# salt-key -A

基于salt-syndic和salt-ssh安装部署saltstack_第1张图片

[root@server4 keepalived]# salt '*' test.ping

基于salt-syndic和salt-ssh安装部署saltstack_第2张图片

salt-ssh部署

[root@server1 ~]# yum  install -y salt-ssh
[root@server1 ~]# vim  /etc/salt/roster
server3:
  host: 172.25.7.3
  user: root
  passwd: wests

测试:

[root@server1 _modules]# cat  my_disk.py 
#!/usr/bin/env python

def df():
    return __salt__['cmd.run']('df -h')
[root@server1 salt]# salt-ssh 'server3' test.ping -i
server3:
    True
[root@server1 salt]# salt-ssh 'server3' my_disk.df
server3:
    Filesystem                    Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root   19G  1.1G   17G   7% /
    tmpfs                         246M   80K  246M   1% /dev/shm
    /dev/vda1                     485M   33M  427M   8% /boot

你可能感兴趣的:(运维企业级,Saltstack)