Ansible AWX - Launching a Job Template
There are 2 options to trigger a Job Template.
- via the UI
- via the RESTful API
Triggering a Job Template from the UI
- Navigate to the Job Template to run, then click on Launch
- Choose the template here
- Click on the launch icon
- Next, the console output will be displayed showing you the progress of the playbook.
Triggering a Job Template from the RESTful API
Ansible AWX provides a RESTful API to programmatically interact with the platform.
This is accessible via: http://<AWX_HOST>/api/v2/
To trigger a specific Job Template.
Navigate to:
<AWX_HOST/api/v2/job_templates/
This will show a list of Job Templates currently available within Ansible AWX.
You will notice each Job Template has a project associated with it, and this will give you an idea on which Job Template to launch.
In this example I have the following project
"project":
{
"id": 10, "name": "DiskChecker", "description": "", "status": "ok", "scm_type": ""
}
Find the specific launch entry in the JSON,
"launch": "/api/v2/job_templates/<ID>/launch/"
When you open the link it will take you to a page to invoke a HTTP POST action.
If the particular Job Template requires extra variables to run, then these can be sent via the {} content.
"extra_vars": {
"key": "val"
}
Once ready, click on the POST button to trigger the Job Template.
You can then track the progress of the triggered Job Template via the UI under Jobs.
You can also track the progress via API using the Job stdout.
<AWX_HOST>/api/v2/jobs/<job_no>/stdout/