What is a Job Template?
A Job Template is a reusable definition for running an Ansible playbook against an inventory with specific credentials and settings. Job templates are the primary way to launch automation jobs in AWX, providing a consistent interface for executing playbooks with parameterization and access control.Job templates act as a “play button” for your automation - they define what to run, where to run it, and how to run it.
Core Concepts
Required Components
From the JobTemplate model (awx/main/models/jobs.py:194-558):
A job template requires:
- Project: The source of playbooks
- Playbook: Specific playbook file from the project
- Inventory (or prompt on launch): Target hosts
- Credentials: Authentication for target systems
Key Fields
| Field | Type | Description |
|---|---|---|
name | String | Template name (unique within organization) |
description | String | Optional description |
job_type | Choice | run (execute playbook) or check (dry run) |
inventory | ForeignKey | Target inventory |
project | ForeignKey | Source project containing playbook |
playbook | String | Playbook filename (must exist in project) |
scm_branch | String | Override project branch (if allowed) |
forks | Integer | Ansible parallelism (0 = unlimited) |
limit | String | Limit job to specific hosts or groups |
verbosity | Integer | Ansible output verbosity (0-4) |
extra_vars | TextField | Additional variables (JSON or YAML) |
job_tags | String | Only run plays/tasks tagged with these |
skip_tags | String | Skip plays/tasks with these tags |
start_at_task | String | Start playbook at specific task |
timeout | Integer | Job timeout in seconds (0 = no timeout) |
diff_mode | Boolean | Show textual changes to templated files |
become_enabled | Boolean | Enable privilege escalation |
allow_simultaneous | Boolean | Allow multiple jobs from this template to run concurrently |
use_fact_cache | Boolean | Enable Ansible fact caching |
job_slice_count | Integer | Number of job slices for parallel execution |
Prompting on Launch
Job templates can be configured to prompt for values at launch time usingask_*_on_launch fields:
Credentials
Job templates support multiple credential types simultaneously:- One SSH credential (machine credential)
- Multiple network credentials
- Multiple cloud credentials
- Multiple vault credentials
Extra Variables
Extra variables follow a specific precedence order:- Job launch extra vars (highest)
- Survey answers
- Job template extra vars
- Inventory variables
- Host/group variables (lowest)
Surveys
Job templates can have surveys that prompt users for input:Job Slicing
Job slicing enables parallel execution across multiple job instances:job_slice_count > 1, AWX:
- Creates a workflow job instead of a regular job
- Creates one job node per slice
- Distributes inventory hosts across slices
- Runs slices in parallel
Jobs
When a job template is launched, it creates a Job (awx/main/models/jobs.py:560-868):
Job Lifecycle
Job Fields
Jobs inherit all fields from the job template plus:| Field | Type | Description |
|---|---|---|
job_template | ForeignKey | Source template |
status | String | Current job status |
started | DateTime | When job execution started |
finished | DateTime | When job completed |
elapsed | Float | Execution time in seconds |
artifacts | JSON | Artifacts from set_stats module |
scm_revision | String | Git commit used from project |
project_update | ForeignKey | Related project update job |
job_slice_number | Integer | Slice number (if sliced) |
job_slice_count | Integer | Total slices (if sliced) |
Dependencies
Jobs may wait for dependencies before running:- Project updates (if
scm_update_on_launch) - Inventory updates (if inventory sources have
update_on_launch)
Execution Environments
Job templates can specify an execution environment:- Job template’s
execution_environment - Project’s
default_environment - Organization’s
default_environment - Global default execution environment
Instance Groups
Job templates can specify which instance groups run the job:API Endpoints
List Job Templates
Create Job Template
Launch Job
Cancel Job
Relaunch Job
Permissions
Job templates have these roles (jobs.py:264-275):
- Admin Role: Full control over the template
- Execute Role: Can launch jobs
- Read Role: Can view template details
Notifications
Job templates can trigger notifications on job events:- When job starts (
started) - When job succeeds (
success) - When job fails (
error)
Best Practices
Use Surveys for User Input
Use Surveys for User Input
Instead of prompting for raw extra_vars, create surveys with typed inputs (integers, choices, etc.) for better UX and validation.
Enable Fact Caching
Enable Fact Caching
Set
use_fact_cache: true to cache Ansible facts. This speeds up subsequent runs and enables fact-based smart inventories.Set Appropriate Timeouts
Set Appropriate Timeouts
Always set a timeout to prevent runaway jobs. Consider the longest expected runtime plus buffer.
Use Limit for Targeted Runs
Use Limit for Targeted Runs
Use the
limit field or prompt for it to run playbooks against subsets of inventory without creating duplicate templates.Leverage Job Slicing
Leverage Job Slicing
For large inventories with independent hosts, use job slicing to parallelize execution and reduce total runtime.
Control Simultaneous Execution
Control Simultaneous Execution
Only enable
allow_simultaneous if your playbooks are idempotent and safe to run concurrently.Related Resources
- Projects - Source of playbooks
- Inventories - Target hosts
- Credentials - Authentication
- Workflows - Chain multiple job templates
- Execution Environments - Container images for execution