An open API service indexing awesome lists of open source software.

https://github.com/fredex42/saltapi-test

Docker setup for playing with the Saltstack API
https://github.com/fredex42/saltapi-test

Last synced: 3 months ago
JSON representation

Docker setup for playing with the Saltstack API

Awesome Lists containing this project

README

        

# saltapi-test

This is a simple docker setup for testing/experimenting with the saltstack
master API as found at https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html.

Usage instructions:

1. Build the Docker container: `docker build . -t {yourname}/saltapi-test:latest`
2. Run it: `docker run --rm -p 8000:80 {yourname}/saltapi-test:latest`
salt-master is started up in the background and salt-api in the foreground, you should
see the salt-api log being displayed in your terminal
3. You should now be able to access the salt api via port 8000 on your local machine:
```
$ curl http://localhost:8000 -D-
HTTP/1.1 200 OK
Content-Length: 146
Access-Control-Expose-Headers: GET, POST
Vary: Accept-Encoding
Server: CherryPy/unknown
Allow: GET, HEAD, POST
Access-Control-Allow-Credentials: true
Date: Thu, 28 Jun 2018 09:32:53 GMT
Access-Control-Allow-Origin: *
Content-Type: application/json

{"clients": ["local", "local_async", "local_batch", "local_subset", "runner", "runner_async", "ssh", "wheel", "wheel_async"], "return": "Welcome"}
$
```
4. The container creates a user called `salttest` with the password `test` for default authentication, with permissions currently limited to creating accepted minion keys only. Update the file `master` and rebuild the container for more options; see https://docs.saltstack.com/en/latest/topics/eauth/index.html#acl-eauth and https://github.com/saltstack/salt/issues/19732 for more information on the external auth syntax.

This is simple to customise in the Dockerfile.
5. To shut the container down, use `docker container stop`:
```
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
99b6d10d2ab2 andyg/saltapi-test:latest "/bin/bash -c '/usr/…" About a minute ago Up About a minute 0.0.0.0:8000->80/tcp dazzling_fermi
$ docker container stop dazzling_fermi
$ docker container rm dazzling_fermi
```
(the last command is not necessary if you started the container with `--rm` on the `docker run` commandline)