semaphoreui/semaphore

REST Api feature

cdloh opened this issue · 8 comments

I've been playing with semaphore for a while now. Good alternative if Ansible Tower isn't an option.

One feature that I'd like to see is a REST API so that it would be possible to fire off playbooks via an API. Would this be possible / been looked at?

Cheers.

There is a JSON api already written which the frontend code uses.

The authentication mechanism would need to change to allow scripts easier access. For the short-term, you could use the Cookie header as authentication.

Better API access will definitely be looked at (0-2 weeks?).

Endpoint that starts a job: /lib/routes/task/tasks.js#L60

Try this with curl:

curl -X POST \
 -vvv \
 -H "Content-Type: application/json" \
 -H "Cookie: (steal it from your browser)" \
 {semaphore-domain}/playbook/your-playbook-id/job/your-job-id/run

+1

Is there a way that basic token authentication can be implemented?

Yeah instead of using cookies it could accept an Authorization header or similar. Its not extremely complicated, neither would it take a long time to do so i'll add that for the next release.

What will take some time is API documentation :). I suppose we'll start a wiki for that.

Is there anything I can do to help? I haven't created a nodejs app before but I can write documentation :)

You already did. Nudge me to do this :P

I'll let you know once it works and we can collaborate on the documentation. Thanks for offering

This would be very nice, an additional function that would be great if it worked is:
To get back the id of the run we trigger with the API so we could check for:

  • ability to request status while a play runs.
  • get status code when its completed (to know if it failed or ended ok)

V2 documentation here: https://ansible-semaphore.github.io/semaphore

V2-alpha can be downloaded from the releases page.