安装Salt
1、
wget -O - https://repo.saltstack.com/apt/ubuntu/14.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -
2、
sudo gedit/etc/apt/sources.list.d/saltstack.list
debhttp://repo.saltstack.com/apt/ubuntu/14.04/amd64/latesttrustymain
4、更新源
sudoapt-getupdate
5、安装
sudoapt-getinstallsalt-master sudoapt-getinstallsalt-minion sudoapt-getinstallsalt-api
6、配置Salt-Minion (Salt-Minion配置文件详解)把minion的master指定一下就好
#master: salt #默认值 : salt ; master服务器的ID
master: 192.168.28.141
7、配置Salt-Master与Salt-API(Salt master配置文件)
file_roots: base: -/srv/salt/
rest_cherrypy: port:8001 debug:True ssl_crt:/etc/pki/tls/certs/localhost.crt ssl_key:/etc/pki/tls/certs/localhost.key disable_ssl:True external_auth: pam: jeff:#jeff是[你的用户名] -.* -'@wheel' -'@runner'
8、重启master、minion、api服务,验证一下是否配置成功
sudo/etc/init.d/salt-minionrestart sudo/etc/init.d/salt-masterrestart sudo/etc/init.d/salt-apirestart
9、
curl-khttp://127.0.0.1:8001/login-H"Accept:application/x-yaml"-dusername='jeff'-dpassword='1qazxsw2'-deauth='pam' #用上面那条命令拿到的token来执行下面这条命令 curl-khttp://127.0.0.1:8001-H"Accept:application/x-yaml"-H"X-Auth-Token:b69c3cb8882bbacb19ab7b09a964dd7e2a17e6a5"-dclient='local'-dtgt='*'-dfun='test.ping'
10、curl没装的话
sudoapt-getinstallcurl
11、下载saltops源码
cd /mnt
sudo git clonehttps://git.oschina.net/wuwenhao/saltops.git
12、安装SaltOps依赖(SaltOps采用Python3,不兼容Python2)
cd/mnt/saltops/ 1. sudopipinstall-r./requiement.txt-ihttp://pypi.douban.com/simple--trusted-hostpypi.douban.com #python2和python3同时存在的话(pip3): sudopip3install-r./requiement.txt-ihttp://pypi.douban.com/simple--trusted-hostpypi.douban.com #默认用的sqlite3,可以换成自己喜欢的DB,然后 2. sudopythonmanage.pymakemigrations&&sudopythonmanage.pymigrate 或 sudopython3manage.pymakemigrations&&sudopython3manage.pymigrate
集中部署
1、启动Celery
pythonmanage.pyceleryworker--loglevel=info pythonmanage.pycelerybeat
2、启动Django
pythonmanage.pyrunserver0.0.0.0:8000
3、访问页面
使用SaltSSH
1、当没办法或者不想安装SaltMinion的时候,我们可以使用SaltSSH,首先需要在master节点上安装Salt-SSH
sudoapt-getinstallsalt-ssh
2、Salt-SSH在第一次接收客户端的时候,会问我们要不要把密钥加入到信任列表中,所以我们可以编辑 /etc/ssh/ssh_config,加入如下配置
Host192.168.80.* StrictHostKeyCheckingno UserKnownHostsFile=/dev/null
3、配置完成后,在主机列表中新增一条记录,填写密码等必要信息并勾选启用SaltSSH,SaltOps会在自动扫描并完善该主机的信息
更多saltops的文档请查看http://saltops.mydoc.io/?t=174145