安装
1
| yum -y install salt-api
|
配置
cat /etc/salt/master.d/api.conf #配置证书和端口
1
2
3
4
5
| rest_cherrypy:
port: 8888
debug: True
ssl_crt: /etc/pki/tls/certs/localhost.crt
ssl_key: /etc/pki/tls/private/localhost_nopass.key
|
cat /etc/salt/master.d/eauth.conf #设置权限
1
2
3
4
5
6
| external_auth:
pam:
saltapi:
- .*
- '@wheel'
- '@runner'
|
添加账号
1
2
| useradd -M -s /sbin/nologin saltapi
echo "saltapi_xxxxxx" | passwd saltapi --stdin
|
启动服务
1
2
| systemctl enable salt-api
systemctl start salt-api
|
测试
curl测试并获取token信息:
1
2
3
4
| curl -k https://manage-op.test.cn:8888/login -H "Accept: application/x-yaml" \
-d username='saltapi' \
-d password='saltapi_xxxxxxxx' \
-d eauth='pam'
|
如果使用python或者golang可以自己封装client