一)、安装配置api
[[email protected]_master ~]# pip install pyopenssl #安装依赖包 [[email protected]_master ~]# yum install salt-api #安装api服务 [[email protected]_master ~]# useradd username && echo password | passwd --stdin $username #添加用户 [[email protected]_master ~]# salt-call --local tls.create_self_signed_cert #生成key,默认目录/etc/pki/tls/certs [[email protected]_master ~]# vi /etc/salt/master rest_cherrypy: port: 8000 #api端口 debug: True ssl_crt: /etc/pki/tls/certs/localhost.crt ssl_key: /etc/pki/tls/certs/localhost.key external_auth: pam: #采用linux自带的加密方式 saltapi: #之前添加的用户名 - .* #主机组 - ‘@wheel‘ #所需要调用的模块(如,cmd.*,file.*),这里表示所有权限 - ‘@runner‘ [[email protected]_master ~]# service salt-api start
[[email protected]_master ~]# service salt-master restart
日志查看/var/log/salt/master 或者 salt-master -l debug
测试
[[email protected]_master ~]# netstat -ntlp|grep 8080 [[email protected]_master ~]# curl -k https://192.168.132.148:8000/login -H "Accept: application/x-yaml" -d username=‘saltapi‘ -d password=‘saltapi‘ -d eauth=pam return: - eauth: pam expire: 1509451924.783881 perms: - .* - ‘@wheel‘ - ‘@runner‘ start: 1509408724.78388 token: 1887a5cdc7b675687915fa9363a54ec8224d4282 user: saltapi