Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xuguruogu/go-salt
go salt lib for easy access salt-api
https://github.com/xuguruogu/go-salt
Last synced: about 1 month ago
JSON representation
go salt lib for easy access salt-api
- Host: GitHub
- URL: https://github.com/xuguruogu/go-salt
- Owner: xuguruogu
- License: mpl-2.0
- Created: 2016-10-17T10:17:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-08T02:19:31.000Z (about 8 years ago)
- Last Synced: 2023-07-27T22:49:01.422Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# go-rest
modified version of [go-salt](https://github.com/r3labs/go-salt)
detailed api reference see [rest_cherrypy](https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html)## feature
- retry authenticate after receive 401
- easy access to urls /jobs, /minions and /run
- easy to parse run result## module list
- [cmd readme](cmd/README.md)
- [test readme](test/README.md)## usage
- run test.ping
```
client := NewClient(addr, username, password)
ping := map[string]bool{}
err := client.RunCmd("*", "test.ping", nil, &ping)
fmt.Print(ping)
```# vagrant usage
```
vagrant up
vagrant ssh master
```## command via shell
- accept all keys
```
sudo salt-key -A -y
```
- ping```
sudo salt '*' test.ping
```## api via curl
- login
```
curl -k https://192.168.88.101:8000/login -H "Accept: application/x-yaml" -d username='salt' -d password='salt' -d eauth='pam'
```- test.ping
```
curl -k https://192.168.88.101:8000 -H "Accept: application/x-yaml" -H "X-Auth-Token: b04cb118d4a0db2213b09db2f42c42ab" -d client=local -d tgt='*' -d fun='test.ping'
```- request
```
curl -k https://192.168.88.101:8000/minions/minion -H "Accept: application/x-yaml" -H "X-Auth-Token: b04cb118d4a0db2213b09db2f42c42ab"
```- jobs list
```
curl -k https://192.168.88.101:8000/jobs -H "Accept: application/x-yaml" -H "X-Auth-Token: b04cb118d4a0db2213b09db2f42c42ab"
```- shell via post json
```
curl -k -X POST https://192.168.88.101:8000 -H "Content-Type: application/json" -H "Accept: application/x-yaml" -H "X-Auth-Token: 54a76c07ad71270e0bafd375fb91ad8a2e837e91" --data '{"client":"local","fun":"cmd.run","tgt":"master","arg":["whoami"],"kwarg":{"runas":"ubuntu"}}'
```