CentOS 安裝及配置Salt api

來源:互聯網
上載者:User

標籤:

 

 

安裝

# 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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.