標籤:
安裝
# 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 restartStopping salt-api daemon: [FAILED]Starting salt-api daemon: [ OK ]
# /etc/init.d/salt-master restartStopping 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‘
測試成功 可以返回資訊
CentOS 安裝及配置Salt api