Installation
# yum-y Install Salt-api
Change Configuration
Vim/etc/salt/master
Drop the default comment on our side. The default profile directory is/srv/salt
DEFAULT_INCLUDE:MASTER.D/*. conf
Create a Directory
#cd/etc/salt
# mkdir Master.d/
# CD Master.d/
Create two files and add a configuration
# cat api.conf rest_cherrypy: 0.0. 0.0 8080truetrue # cat eauch.conf External_auth: Pam: saltapi: -. * '@wheel' ' @runner '
Create user
123123 | passwd--stdin Saltapi
Restart 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 ]
Then test whether the installation was successful
# 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
After returning the token value, the token value can be used directly after the call.
Let's try the Cmd.run module.
# 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- on:'Total used free shared buffers cachedMem:980 913 the 0 - 184-/+ Buffers/cache:672 307Swap:1983 - 1963'salt-minion- Geneva:'Total used free shared buffers cachedMem:980 914 $ 0 - 169-/+ Buffers/cache:696 284Swap:1983 - 1913'
Test success can return information
CentOS installation and configuration Salt API