0

Could someone please help on "How to download Ansible Tower execution result to a log file on a particular remote server?".

I couldn't find much results on "How to automatically download the result of execution?".

U880D
  • 8,601
  • 6
  • 24
  • 40

1 Answers1

1

I understand your question similar to Ansible Tower REST API: Is there any way to get the logs/output of a job?

According the Tower API Reference Guide: Jobs, the following call might work from or on your remote server.

curl --silent -u ${TOWER_USER}:${TOWER_PASSWORD} -JL https://${TOWER_URL}/api/v2/jobs/${JobID}/stdout?format=txt_download -o job_${JobID}.log

resulting into the output of a file called job_${JobID}.log.

You may transfer this in to an Ansible task, ideally by not using the shell module.

U880D
  • 8,601
  • 6
  • 24
  • 40
  • 1
    If you need more than the `stdout` alone and want the FULL output (as if you were to click on each task result and look at the JSON individually), it may also be useful to see `https://${TOWER_URL}/api/v2/jobs/${JobID}/job_events >> outfile` but note that these are paginated results so you would need to iterate through and fetch page by page (`/?page=###` -- unless there's a trick I'm missing to get it all!) – Christopher Rice Nov 04 '22 at 12:11