Skip to content

Instantly share code, notes, and snippets.

@hemebond
Last active March 3, 2017 01:21
Show Gist options
  • Save hemebond/dab36b44436f45df41492b051f59397f to your computer and use it in GitHub Desktop.
Save hemebond/dab36b44436f45df41492b051f59397f to your computer and use it in GitHub Desktop.
Saltstack API (netapi) Examples

rest_cherrypy

First authenticate against the API:

curl -si $HOST:$CHERRY_PORT/login' -H 'Accept: application/json' -H 'Content-type: application/json' -d "{"username": "$USER", "password": "$PASS", "eauth": "pam"}"

Request data from Salt Mine using the token given by the login:

curl -sS -i -H "Accept: application/json" -H "Content-type: application/json" -H "X-Auth-Token: $TOKEN" -d "[{"username": "$USER", "password": "$PASS", "eauth": "pam", "client": "runner", "fun": "mine.get", "tgt": "*", "kwargs": {"tgt": "db9svc*", "fun": "grains.items"}}]" $HOST:$CHERRY_PORT

rest_wsgi

Credentials and command are all passed in the same request:

curl -sS -i -H "Accept: application/json" -H "Content-type: application/json" -H "X-Auth-Token: $TOKEN" -d "[{"username": "$USER", "password": "$PASS", "eauth": "pam", "client": "runner", "fun": "mine.get", "tgt": "*", "kwargs": {"tgt": "db9svc*", "fun": "grains.items"}}]" $HOST:$WSGI_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment