AWX Workflow Template
An Ansible AWX Workflow Template allows you to chain multiple Job Templates (and even other Workflow Templates) together in a defined sequence or conditional structure. It is essentially a “workflow” or orchestration of multiple jobs, letting you create complex automation flows.
Key Features of Workflow Templates:
- Multiple Job Templates: You can chain several Job Templates together, allowing for more complex automation.
- Conditional Execution: Workflows can be set to conditionally run specific jobs based on the success/failure of prior jobs (using “Success/Failure” logic).
- Parallel Execution: You can have multiple jobs run in parallel (asynchronously).
- Logical Flow: Workflows provide a way to control the flow of execution between multiple jobs. For example, you can set up a series of jobs that depend on each other’s outcome (e.g., Job A must succeed before Job B runs).
- Visual Design: The workflow is usually displayed as a flowchart in the AWX UI, which helps visualize the execution path.
- Triggering Jobs: A Workflow Template can be triggered manually or automatically (via an API, CLI, or other workflows).
When to use Workflow Template:
Automating Larger Processes: If your automation pipeline involves many interconnected jobs that need to run sequentially or in parallel.
Complex Tasks: If you have multiple independent or dependent tasks that should be executed in a specific order.
Task Orchestration: When you need to coordinate multiple steps across different machines, roles, or playbooks.
AWX Job Template
A Job Template in AWX is a single playbook run configuration. It’s the simplest form of automation in AWX and defines a specific playbook to be executed on a set of hosts, with parameters (like extra_vars
), inventory, and other settings like credentials.
Key Features of Job Templates:
- Single Playbook Execution: Executes one playbook on a set of hosts.
- Target Hosts: Defined in the Inventory.
- Variables: Can define variables in extra_vars or prompt the user for input at launch.
- Credentials: Credentials are used to authenticate against the managed nodes (e.g., SSH or API credentials).
- Execution Environment: Defines the Ansible environment, including the playbook’s Python version, libraries, etc.
- Launchable by API/CLI: Can be launched manually through the AWX UI, CLI, or API.
When to use Job Template:
- Simple tasks: For when you need to run a single playbook on one or more hosts with a specific set of variables.
- One-time configurations: Suitable for automating individual tasks, such as configuring devices, updating software, or deploying apps.
Example Scenario
- Job Template Example:
- A Job Template could run a playbook to configure a Cisco router with specific settings, such as IP addresses, BGP configurations, etc.
- Workflow Template Example:
- A Workflow Template could combine the router configuration playbook (Job A) with another playbook that installs monitoring software on the router (Job B), then a third job that sends an alert (Job C) if either of the first two jobs fails.
- It could run Jobs A and B in parallel, but only run Job C if Job A or Job B fails.
When to use each?
- Use Job Templates when you have a single task or playbook that you want to run.
- Use Workflow Templates when your task requires multiple jobs that may need to be executed in a specific order or parallel, with conditions for success/failure.
Feature | Job Template | Workflow Template |
---|
Execution | Runs a single playbook on target hosts | Chains multiple job templates together |
Flow Control | No flow control; runs as a standalone job | Supports conditions, parallel execution, and sequence |
Job Dependency | No dependency between jobs | Can define dependencies between jobs (Success/Failure logic) |
Usage | For simple, standalone tasks | For complex automation involving multiple steps |
UI Representation | Single job execution | Visual flowchart of job executions |
Launch Mechanism | Manually or through API | Manually or through API, triggered by other workflows |
Leave a Reply