设为首页 收藏本站
查看: 950|回复: 0

[经验分享] centos7 安装salt-api

[复制链接]

尚未签到

发表于 2018-4-23 12:27:58 | 显示全部楼层 |阅读模式
  环境说明
  操作系统:centos 7.0
  Salt-api安装
  salt-api 使用pip安装
12[root@centos7 ~]# pip install CherryPy  [root@centos7 ~]# pip install salt-api
  [root@centos7 ~]# pip install  PyOpenssl
  我在安装过程中发现使用pip install salt-api   安装API会报错:
  Could not find any downloads that satisfy the requirement salt-api
  所以我采用的是使用yum安装的salt-api
[root@centos7 ~]#  yum -y install salt-api

  Salt-api配置
123456789101112131415161718192021222324252627[root@centos7 ~]# cd /etc/pki/tls/certs/  # 生成自签名证书,用于ssl[root@centos7 certs]# make testcert     umask 77 ; \/usr/bin/openssl genrsa -aes128 2048 > /etc/pki/tls/private/localhost.keyGenerating RSA private key, 2048 bit long modulus...................................................................+++..+++e is 65537 (0x10001)Enter pass phrase:       # 输入加密密语,4到8191个字符Verifying - Enter pass phrase:   # 确认加密密语umask 77 ; \/usr/bin/openssl req -utf8 -new -key /etc/pki/tls/private/localhost.key -x509 -days 365 -out /etc/pki/tls/certs/localhost.crt -set_serial 0Enter pass phrase for /etc/pki/tls/private/localhost.key:     # 再次输入密语You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [XX]:CN                             # 选填State or Province Name (full name) []:ShanghaiLocality Name (eg, city) [Default City]:ShanghaiOrganization Name (eg, company) [Default Company Ltd]:Organizational Unit Name (eg, section) []:Common Name (eg, your name or your server's hostname) []:Email Address []:yao.xiabing@99cloud.net123456[root@centos7 certs]# cd ../private/[root@centos7 private]# openssl rsa -in localhost.key -out localhost_nopass.keyEnter pass phrase for localhost.key:writing RSA key[root@centos7 private]# lslocalhost.key  localhost_nopass.key  注:
  1、 如果make testcert出现错误,删除/etc/pki/tls/private/localhost.key文件,然后再make testcert。
  2、 装salt-api的时候,使用curl命令遇到curl: (56) SSL received a record that exceeded the maximum permissible length.可能是CherryPy包的问题。
123# 创建用户[root@centos7 private]# useradd -M -s /sbin/nologin saltapi[root@centos7 private]# echo "yao" | passwd saltapi --stdin123456789101112131415161718192021222324# 添加配置文件[root@centos7 ~]# mkdir -p /etc/salt/master.d/      [root@centos7 ~]# vim /etc/salt/master.d/eauth.conf   # 处于安全因素,一般只给特定模块的使用权限,这里给saltapi用户所有模块的使用权限       external_auth:  pam:    saltapi:      - .*      - '@wheel'      - '@runner'       [root@centos7 ~]# vim /etc/salt/master.d/api.conf rest_cherrypy:  port: 8888                          #  salt-api 监听端口  ssl_crt: /etc/pki/tls/certs/localhost.crt          # ssl认证的证书  ssl_key: /etc/pki/tls/private/localhost_nopass.key   # 如果不使用ssl,用下面配置rest_cherrypy:  port: 8888  host: 172.16.20.20  disable_ssl: True   [root@centos7 ~]# systemctl restart salt-master.service[root@centos7 ~]# systemctl restart salt-api.service  Salt-api使用
  1、curl使用
  获取token
1234567891011[root@centos7 ~]# curl -k https://172.16.199.249:8888/login -H "Accept: application/x-yaml" -d username='saltapi' -d password='yao' -d eauth='pam'return:- eauth: pam  expire: 1427373796.305001  perms:  - .*  - '@wheel'  - '@runner'  start: 1427330596.305  token: ec8d60e3b492e9947e557eefd4112802053432c7  user: saltapi  查询minion的信息
12345678910[root@centos7 ~]# curl -k https://172.16.199.249:8888/minions/compute-1 -H "Accept: application/x-yaml"      -H "X-Auth-Token: 9845eab9848c5b5ba72fbad9102532bddab2df7f"   # token是上面获取到的,如果后面跟的请求不包含特定minion id如compute-1,则请求的是所有的minion的信息。return:- compute-1:    SSDs: []    biosreleasedate: 01/01/2011    biosversion: 0.5.1    cpu_flags:    - fpu    - vme。。。。。。  查询缓存的job信息
12345678910111213141516[root@centos7 ~]# curl -k https://172.16.199.249:8888/jobs/20150326085224919460 -H "Accept: application/x-yaml"      -H "X-Auth-Token: 9845eab9848c5b5ba72fbad9102532bddab2df7f"    # 如果后面跟的请求不包含特定job id如20150326085224919460,则请求的是所有job的信息。info:- Arguments: []  Function: test.ping  Minions:  - compute-1  Result:    compute-1:      return: true  StartTime: 2015, Mar 26 08:52:24.919460  Target: '*'  Target-type: glob  User: root  jid: '20150326085224919460'return:- compute-1: true  远程执行module
123[root@centos7 ~]# curl -k https://172.16.199.249:8888 -H "Accept: application/x-yaml" -H "X-Auth-Token: 9845eab9848c5b5ba72fbad9102532bddab2df7f" -d client='local' -d tgt='*' -d fun='test.ping'return:- compute-1: true  远程执行runner
12345[root@centos7 ~]# curl -k https://172.16.199.249:8888 -H "Accept: application/x-yaml" -H "X-Auth-Token: 9845eab9848c5b5ba72fbad9102532bddab2df7f" -d client='runner'  -d fun='manage.status'return:- down: []  up:  - compute-1  远程运行wheel
123456789101112131415161718[root@centos7 ~]# curl -k https://172.16.199.249:8888 -H "Accept: application/x-yaml" -H "X-Auth-Token: 0110cb3fd4bc4521d5c2de7126eadfd786dc8b36" -d client='wheel'  -d fun='key.list_all'return:- data:    _stamp: '2015-03-26T13:42:16.569194'    fun: wheel.key.list_all    jid: '20150326134216540701'    return:      local:      - master.pem      - master.pub      minions:      - compute-1      minions_pre: []      minions_rejected: []    success: true    tag: salt/wheel/20150326134216540701    user: saltapi  tag: salt/wheel/20150326134216540701

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-450913-1-1.html 上篇帖子: centos6——初始化脚本 下篇帖子: centos 7.0 网卡配置及重命名教程
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表