ansibleansible-awxansible-tower

Ansible Tower REST API: Is there any way to get the logs/output of a job?


I have a Ansible job started by another Process. Now I need to check the status of the current running job in Ansible Tower.

I am able to track the status whether it is running/success/failed/canceled with /jobs/{id} using REST API.

But I would also need the information of the console logs/ouputs of the task for processing as well. Is there any direct API call for the same?


Solution

  • You can access the job log via a link similar to:

    https://tower.yourcompany.com/api/v1/jobs/12345/stdout?format=txt_download

    Your curl command would be similar to: curl -O -k -J -L -u ${username):${password} https://tower.company.com/api/v1/jobs/${jobnumber}/stdout?format=txt_download

    obviously replacing ${username}, ${password}, and ${jobnumber} with your own values

    The curl flags used: