安装saltstack 基本是很简单的了。一直yum安装就好了,但是这次遇到了一些坑,记录一下,以后避免。 环境: centos 7.4 x86 python2.7.5 主控端 yum -y install salt-master 一直安装就好了。如果提示没有包,下载一个saltstack源就好了。 在主控端安装salt-api. 如果一直yum安装, yum -y install salt-api 因为salt-api是基于CherryPy框架开发的。它会安装一个python-cherrypy依赖包。 安装完成之后启动/usr/bin/salt-api start 会一直提示一个错误: Process Process-16: ........................................more info............................. self.namespaces(config) File "/usr/lib64/python2.7/site-packages/cherrypy/lib/reprconf.py", line 112, in call handler(k, v) File "/usr/lib64/python2.7/site-packages/cherrypy/_cpconfig.py", line 272, in _engine_namespace_handler plugin = getattr(engine, plugin) AttributeError: 'Bus' object has no attribute 'timeout_monitor'

这个错误查了一些资料,百度是找不到任何信息的,折腾了我2天时间,用biying吧。第一条就有解决方法, https://github.com/hubbcaps/gazee/issues/51 。 使用pip install CherryPy==11.0.0 安装cherrypy的低级版本。yum安装默认是15.0.0,这个版本是python3以上的。 其他的安装yum -y install gcc make pythond-evel libffi-devel yum -y install pyOpenSSL 这些没什么还说的。 主控端没有安装salt-minion ,在salt-call tls.create_self_signed_cert 提示命令没有找到。再安装一次yum -y install salt-minion . 安装完全之后,你执行salt-call tls.create_self_signed_cert ,会提示salt 主机没有,再在/etc/salt/minion配置好master: salt ,在/etc/hosts 写入"IP地址" salt,解析一下。你再执行salt-call tls.create_self_signed_cert,会提示主机没有通过认证,在主控端salt-key -A,再执行一次salt-call tls.create_self_signed_cert,这时候你就可以在/etc/pki/tls/certs/目录下看到localhost.crt localhost.key2个文件了。 把api.conf eauth.conf也放一下。 api.conf: rest_cherrypy: port: 8888 debug: True #disable_ssl: True ssl_crt: /etc/pki/tls/certs/localhost.crt ssl_key: /etc/pki/tls/certs/localhost.key

eauth.conf: external_auth: pam: saltapi: - .* - '@wheel' - '@runner'

创建一个用户: useradd -M -s /nologin saltapi echo "passwd" |passwd saltapi --stdin 记得要重启下master:systemctl restart salt-master 启动salt-api :/usr/bin/salt-api start 测试下: curl -k https://10.253.169.187:8888/login -H "Accept: application/x-yaml" -d username='saltapi' -d password='xxxxxxxxx' -d eauth='pam' return:

  • eauth: pam expire: 1527619421.05083 perms:
    • .*
    • '@wheel'
    • '@runner' start: 1527576221.050828 token: 892e08a901d4ac3b628fb7cb0e09b8de6499624c user: saltapi

客户端的坑: 客户端操作系统是uname -r 2.6.32-220.23.2.al.ali1.1.alios6.x86_64 这个鬼玩意你直接yum -y install salt-minion 会提示python-request 是需要的。PyXMl你是没有的。 把yum.repos.d换成一个163的。wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

下载完成之后,记得vi CentOS-Base.repo 把里面的$release 都换成6. 清空缓存 yum clean all 生成换成yum makecache. 再直接yum -y install salt-minion 。当然,提示没有源的时候下载一个salt源。

文章中涉及到的配置文件中的“点点点” 都是'-'符号。什么鬼。或者去其他地方找下配置文件。