安装saltstack
环境:
master:192.168.46.163(centos7、python2.7)
minion1:192.168.46.220(ubuntu18)
minion2:192.168.46.142(win10)
安装master
- 关闭selinux
getenforce ##查看selinux的状态
setenforce 0 ##关闭selinux
- 安装epel源
安装master和minion都需要配置epel,官方地址: https://fedoraproject.org/wiki/EPEL
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- 安装并启动master
可以使用包管理器(centos:yum,ubuntu:apt-get),也可以使用pip安装,具体可以参考此处使用yum进行安装,其它可以参考官网说明https://docs.saltstack.com/en/latest/topics/installation/index.html
yum install -y salt-master
systemctl enable salt-master.service ##开机自启
systemctl start salt-master
- 配置
/etc/hosts
文件
192.168.46.163 centos
192.168.46.220 bogon
192.168.46.142 R2
ping bogon
以验证配置结果。
安装minion
- 安装
其它安装方式参考官网说明。
注:windows需要以管理员身份运行salt-minion.bat
yum install -y salt-minion
- 指定master地址
修改文件/etc/salt/minion
master: 192.168.46.163
- 启动minion
systemctl enable salt-minion.service
systemctl start salt-minion
master节点Salt秘钥认证
minion启动完成后,master节点使用salt-key
可以看到
[root@centos ~]# salt-key
Accepted Keys:
bogon
centos
Denied Keys:
Unaccepted Keys:
R2
Rejected Keys:
可以使用salt-key -A
接受所有key,也可以salt-key -a 'R2'
接受指定minion的key。
可以指定个命令测试下结果:
[root@centos ~]# salt '*' test.ping
bogon:
True
centos:
True
R2:
True
master装web界面
- 执行
pip install -U halite
安装halite - 配置master
修改文件/etc/salt/master
halite:
level: 'debug'
server: 'cherrypy'
host: '0.0.0.0'
port: '8080'
cors: False
tls: True
certpath: '/etc/pki/tls/certs/localhost.crt'
keypath: '/etc/pki/tls/certs/localhost.key'
pempath: '/etc/pki/tls/certs/localhost.pem'
external_auth:
pam:
slsapi: #手动创建该用户,使用该用户访问web界面
- .*
- '@runner'
- '@wheel
- 创建用户salt-api的用户(非root)
useradd -M -s /sbin/nologin slsapi
echo 'slsapi' | passwd slsapi --stdin
-
重启master
效果图
补充:
如果minion中途变更master,则需要清除原来的密钥,否则会报错,systemctl status salt-minion
可以看到报错信息
The master public key can be found at:
/var/lib/salt/pki/minion/minion_master.pub
[ERROR ] Error while bringing up minion for multi-master. Is master at 192.168.46.137 responding?
[ERROR ] The master key has changed, the salt master could have been subverted, verify salt master's public key
[CRITICAL] The Salt Master server's public key did not authenticate!
The master may need to be updated if it is a version of Salt lower than 2017.7.4, or
If you are confident that you are connecting to a valid Salt Master, then remove the master public key and restart the Salt Minion.
也可以通过查日志/var/log/salt/minion
,然后定位minion服务器上master密钥位置。
网友评论