How To launch a job with the Rest APIs in synchronous mode

Hello,

I’m using the AWX APIs to launch a job from another php application. The problem is that the API launch without waiting for the completion of the task.

Is there a way to launch a job synchronously?

thanks in advance

Manu

I solve this by putting logic in my calling code to check the status of the wax job

Thank you for your reply.
Indeed, I can call the API to check the status of the job until it is finished. I had already thought of this solution.

But, it would be much simpler and safer if the API could wait for the end of the job.
There is no way to do that?

Hey Manu,

As Scott suggested, the way to do this is to periodically poll the API for job status - other open source tools (like the Python-based tower-cli) take the same approach:

https://github.com/ansible/tower-cli/blob/828234df230efc94f2b7abbceb3ae2309ccaf235/tower_cli/models/base.py#L871

We’re not likely to add functionality to have the HTTP POST hang open as the job runs in the background because it could prevent the pool of HTTP worker processes from processing other inbound HTTP requests (resulting in HTTP 504 errors).

Hey Ryan,

Thank you for your answer, I will add a loop to control the status of the job until the end.