AWX/Tower and git integration - Post a comment with AWX/Tower job information

Hi guys,

At work we are testing Tower and AWX and in particular we use it to produce configurations templates that we then push to git.
The whole process works fine and we are trying to automate it using as follows:
- a web frontend calling AWX/Tower API
- APIs call will start a job/playbook in tower that will create/apply the new configuration
- the last task of the playbook will commit and push the configuration to git.
What I would like to do is to include in the git commit comment, the reference to AWX/Tower job that was spun but I can't find
that information anywhere in the ansible_facts that the playbook is running with.
Do you know if it is possible to get it somewhere? Or even a way to pass it as an extra-var at the time the job is started?

Thanks

Valerio

Yep, we have a few extra vars that we pass to playbook execution:

tower_job_id
awx_job_id (same as before)
tower_job_launch_type
awx_job_launch_type
tower_job_template_id
awx_job_template_id
tower_user_id
awx_user_id
tower_user_name
awx_user_name

We also pass some more details in the job environment.

You can check out everything we do by visiting the api endpoint for the job (it’s viewable in your browser!) towerhost/api/v2/jobs/n/

Hey Valerio,

Job Templates launched in awx inject a few additional extra_vars that should give you what you need:

https://github.com/ansible/awx/blob/90f63774f4e83a80dc2612c3277879c1cfe57a7f/awx/main/tasks.py#L1123

Some that you might find useful are:

awx_job_id
awx_job_launch_type - see https://github.com/ansible/awx/blob/90f63774f4e83a80dc2612c3277879c1cfe57a7f/awx/main/models/unified_jobs.py#L427 for options
awx_job_template_id
awx_job_template_name

These two represent the awx user that launched the job:
awx_user_id
awx_user_name

If you wanted to build direct link to a job, it would be something like:

https://your-tower-host.example.org/api/v2/jobs/{{ awx_job_id }}”

Oh no, it looks like Matt Jones beat me to it :D!

Thank you both guys!