标签:
安装
# yum -y install salt-api
更改配置
vim /etc/salt/master
把默认的注释掉 我们这边默认配置文件目录是/srv/salt
default_include: master.d/*.conf
创建目录
#cd /etc/salt
# mkdir master.d/
# cd master.d/
创建两个文件和添加配置
# cat api.conf rest_cherrypy: host: 0.0.0.0 port: 8080 debug: true disable_ssl: true # cat eauch.conf external_auth: pam: saltapi: - .* - ‘@wheel‘ - ‘@runner‘
创建用户
# useradd saltapi # echo 123123 | passwd --stdin saltapi
重启salt-api
# /etc/init.d/salt-api restart Stopping salt-api daemon: [FAILED] Starting salt-api daemon: [ OK ]
# /etc/init.d/salt-master restart Stopping salt-master daemon: [FAILED] Starting salt-master daemon: [ OK ]
然后进行测试 是否安装成功
# curl -k http://10.20.0.100:8080/login -H "Accept: application/x-yaml" -d username=‘saltapi‘ -d password=‘123123‘ -d eauth=‘pam‘ return: - eauth: pam expire: 1474258659.0838921 perms: - .* - ‘@wheel‘ - ‘@runner‘ start: 1474215459.0838921 token: 69bb58e4b6bb2026369a40fc40184a88e7472054 user: saltapi
返回了token值 以后需要调用就可以直接用token值
我们试试 cmd.run模块
# curl -k http://10.20.0.100:8080 -H "Accept: application/x-yaml" -H "X-Auth-Token: 69bb58e4b6bb2026369a40fc40184a88e7472054" -d client=‘local‘ -d tgt=‘*‘ -d fun=‘cmd.run‘ -d arg=‘free -m‘ return: - salt-minion-01: ‘ total used free shared buffers cached Mem: 980 913 67 0 55 184 -/+ buffers/cache: 672 307 Swap: 1983 20 1963‘ salt-minion-02: ‘ total used free shared buffers cached Mem: 980 914 65 0 48 169 -/+ buffers/cache: 696 284 Swap: 1983 70 1913‘
测试成功 可以返回信息
标签:
原文地址:http://www.cnblogs.com/yexiaochong/p/5901385.html