安装saltstackhtml
环境:
Master:192.168.117.145 (centos七、python2.7)
Minion1:192.168.117.215 (centos7)
Minion2:192.168.117.231 (2008R2)python
安装masterlinux
关闭selinuxgit
getenforce ##查看selinux的状态 setenforce 0 ##关闭selinux
关闭防火墙github
Systemctl stop firewalld ##关闭防火墙
安装epel源web
安装master和minion都须要配置epel,官方地址:https://fedoraproject.org/wiki/EPELubuntu
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
安装并启动masterwindows
可使用包管理器(centos:yum,ubuntu:apt-get),也可使用pip安装,具体能够参考此处使用yum进行安装,其它能够参考官网说明https://docs.saltstack.com/en/latest/topics/installation/index.htmlcentos
yum install -y salt-master systemctl enable salt-master.service ##开机自启 systemctl start salt-master
配置/etc/hosts文件api
192.168.117.145 Master 192.168.117.215 Node-1 192.168.117.167 R2
ping Node-1以验证配置结果。
安装minion
1.安装
其它安装方式参考官网说明,windows agent连接安装包下载地址:
https://repo.saltstack.com/#windows
yum install -y salt-minion
2.指定master地址
修改文件/etc/salt/minion
master: 192.168.46.163 Id:Node-1 ##这里定义后,master认证证书那里就以这个名称为主,默认这里是注释状态。
启动minion
systemctl enable salt-minion.service systemctl start salt-minion
master节点Salt-KEY认证
minion启动完成后,master节点使用salt-key能够看到
[root@localhost ~]# salt-key Accepted Keys: Denied Keys: Unaccepted Keys: ##不合格KEY Node-1 Rejected Keys:
配置认证
在服务端上操做
salt-key -a Node-1
[root@localhost ~]# salt-key Accepted Keys: ##接受的KEY Node-1 Denied Keys: Unaccepted Keys: Rejected Keys:
说明:-a :accept ,-A:accept-all,-d:delete,-D:delete-all。可使用 salt-key 命令查看到已经签名的客户端。此时咱们在客户端的 /etc/salt/pki/minion 目录下面会多出一个minion_master.pub 文件。
测试验证
示例1: salt '*' test.ping //检测通信是否正常,也能够指定其中一个 'Node-1'
示例2: salt '*' cmd.run 'df -h' //远程执行命令
说明: 这里的 * 必须是在 master 上已经被接受过的客户端,能够经过 salt-key 查到,一般是咱们已经设定的 id 值。
关于这部份内容,它支持通配、列表以及正则。 好比两台客户端 web十、web11, 那咱们能够写成 salt 'web*' salt 'web1[02]' salt -L 'web10,web11' salt -E 'web(10|11)' 等形式,使用列表,即多个机器用逗号分隔,并且须要加-L,使用正则必需要带-E选项。
master装web界面
下载halite 地址:https://github.com/saltstack/halite
[root@localhost ~]# cd /var/www
生成index.html文件,解压并进入halite目录下
[root@localhost www]# cd halite/halite/ [root@localhost www]# ./genindex.py -C
安装salt-api
yum install salt-api
建立用户salt-api的用户(非root)
useradd -M -s /sbin/nologin slsapi echo 'slsapi' | passwd slsapi --stdin
配置master
修改文件/etc/salt/master
rest_cherrypy: host: 0.0.0.0 port: 8080 debug: true static: /root/halite/halite app: /root/halite/halite/index.html external_auth: pam: admin: - .* - '@runner' - '@wheel'
重启master
systemctl restart salt-master
配置salt-api启动项,设置api开机自启
systemctl enable salt-api.service
修改服务文件
vi /usr/lib/systemd/system/salt-api.service
修改ExecStart项
ExecStart=/usr/bin/python /var/www/halite/halite/server_bottle.py -d -C -l debug -s cherrypy
启动salt-api
systemctl daemon-reload systemctl start salt-api
登陆测试:http://127.0.0.1:8080/app/console
经过salt/salt登录便可