AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

AAP 2.6 Job Templates and Inventories: Complete Configuration Guide

By Luca Berton · Published 2024-01-01 · Category: troubleshooting

Configure job templates and inventories in AAP 2.6: static and dynamic inventories, smart inventories, job template surveys, scheduling, notification templates, and launch configuration. Practical examples for enterprise automation.

Job Templates Overview

Job Templates in AAP 2.6 are the fundamental unit of automation execution. They combine: • A playbook (from a Project) • An inventory (target hosts) • Credentials (authentication) • An Execution Environment (runtime container) • Optional surveys (runtime input) • Optional schedules (recurring execution) • Optional notifications (alerts on success/failure)

Creating Job Templates

Via the ansible.platform Collection

Key Job Template Settings

| Setting | Description | Default | |---------|-------------|---------| | job_type | run (execute) or check (dry run) | run | | verbosity | 0 (normal) to 5 (connection debug) | 0 | | forks | Parallel host execution | 5 | | limit | Restrict to subset of inventory | (all hosts) | | timeout | Job timeout in seconds | 0 (no timeout) | | diff_mode | Show file changes | false | | become_enabled | Enable privilege escalation | false |

Ask-on-Launch Options

Enable users to override settings at launch time:

Inventory Types

Static Inventory

Define hosts and groups manually:

Dynamic Inventory (Cloud Sources)

Auto-discover hosts from cloud providers:

Smart Inventories

Smart inventories dynamically group hosts from other inventories using filters:

Smart inventory use cases:

| Filter | Use Case | |--------|----------| | groups__name=webservers | All hosts in webservers group (any inventory) | | ansible_facts__os_family=Debian | All Debian-family hosts | | name__startswith=prod- | Hosts with names starting with "prod-" | | ansible_facts__ansible_kernel__contains=el9 | RHEL 9 hosts |

Constructed Inventories

Combine and transform multiple inventory sources:

Surveys

Surveys create forms that collect input at job launch:

Survey question types:

| Type | Widget | Notes | |------|--------|-------| | text | Text input | min/max character length | | textarea | Multi-line text | min/max character length | | password | Password input | Encrypted, not shown in output | | integer | Number input | min/max value | | float | Decimal input | min/max value | | multiplechoice | Dropdown select | Single selection | | multiselect | Checkbox list | Multiple selections |

Scheduling Jobs

Recurring Schedules

Notification Templates

Get alerted when jobs succeed, fail, or start:

Launching Jobs

Via API

Via Playbook

FAQ

What is the difference between a job template and a workflow template?

A job template runs a single playbook against an inventory. A workflow template chains multiple job templates (and other actions) into a pipeline with branching logic, approval gates, and convergence. Use job templates for individual tasks; use workflows for multi-step processes.

Can I limit dynamic inventory to specific hosts?

Yes. Use the limit field on the job template or at launch time. You can also use host_filter in smart inventories to create permanent subsets. Dynamic inventory source_vars support filters to restrict which hosts are discovered.

How do I handle different variables per environment?

Use inventory-level variables. Create separate inventories for each environment (staging, production) with different variable values. The same job template can run against different inventories using ask_inventory_on_launch.

Can I revert a failed job?

AAP does not have built-in rollback. Design your playbooks to be idempotent so re-running is safe. For complex rollback needs, use workflow templates with failure paths that trigger rollback job templates.

What happens when a scheduled job overlaps with a running instance?

By default, AAP will queue the new job. You can configure instance groups and capacity to control concurrent execution. There is no built-in "skip if already running" — implement this logic in your playbook or use workflow convergence.

Conclusion

Job templates and inventories are the workhorses of AAP 2.6. Mastering dynamic inventories, surveys, scheduling, and notifications turns AAP from a manual job runner into a self-service automation platform where teams can safely execute approved automation with proper guardrails.

Related ArticlesAAP 2.6 Workflow Templates: Advanced Multi-Step Automation GuideAAP 2.6 Credential Management: Vaults, External Secrets, and Machine CredentialsAAP 2.6 Architecture and Components: Complete GuideAAP 2.6 RBAC and Gateway APIAAP 2.6 Configuration as Code with ansible.platform

Category: troubleshooting

Browse all Ansible tutorials · AnsiblePilot Home