Last active
August 29, 2015 14:03
-
-
Save justlooks/709a312fdf0ed38935c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# curl -k http://192.168.10.231:8888 -H "X-Auth-Token:7715cc6c49dc652820c25e4c09684c49bfd9ccf9" -d client='local_async' -d tgt='saltslave2' -d fun='state.sls' -d arg='tomcat.newinstance' | |
{"return": [{"jid": "20140327162916805438", "minions": ["saltslave2"]}]} | |
# curl -k http://192.168.10.231:8888 -H "X-Auth-Token:7715cc6c49dc652820c25e4c09684c49bfd9ccf9" -d client='local' -d tgt='saltslave2' -d fun='state.sls' -d arg='tomcat.newinstance' | |
{"return": [{}]} |
whiteinge
commented
Jun 27, 2014
Here's a three-liner that will wait indefinitely for a job to complete. This will not have timeout issues.
# Log in:
% curl -c /tmp/cookies.txt -sSi http://localhost:8000/login -d username='saltdev' -d password='saltdev' -d eauth='auto' | head -1 | grep -q '200 OK'
# Get the JID:
% jid=$(curl -b /tmp/cookies.txt -sS http://localhost:8000 -d client='local_async' -d tgt=jerry -d fun='test.sleep' -d arg='8' | sed -r -n -e 's/.*jid": "([0-9]+).*/\1/p')
# Wait for the JID:
% curl -b /tmp/cookies.txt -NsS http://localhost:8000/events 2>/dev/null | while read -r line; do { printf '%s\n' "$line" | grep -q "^data:.*$jid" && printf "%s\n" "$line" && break; }; done
(This example will require modification in order to listen for more than one JID or more than one minion.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment