1. 程式人生 > >centos 7.4 x86 安裝saltstack

centos 7.4 x86 安裝saltstack

saltstack salt-api

安裝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源。

文章中涉及到的配置文件中的“點點點” 都是‘-‘符號。什麽鬼。或者去其他地方找下配置文件。

centos 7.4 x86 安裝saltstack