Create a workflow job template in automation controller that launches a branching chain of jobs based on the success or failure of each job in the workflow sequence.
Job templates run single Ansible Playbooks as jobs. As the use of Red Hat Ansible grows in an organization, so does the number of Ansible Playbooks it has. Each playbook typically performs a set of tasks associated with a certain function.
Instead of writing one large playbook to automate a complex operation, you might want to run several playbooks in sequence. For example, your goal might be to configure NTP on your network devices. This process might first require testing connectivity to your network devices. You might then use a separate playbook to back up the current configurations. Finally, you might use another playbook to configure NTP. In other words, there might be a particular workflow that you need to follow for the process to succeed.
You could manage this in automation controller by manually launching multiple jobs in sequence. But, you have to execute the jobs in the correct order, as defined by your workflow, for everything to work correctly. For example, you might have the following workflow:
Run the connectivity jobs first.
Run the backup jobs only if the connectivity jobs completed successfully.
Run the configuration change jobs only if the connectivity and backup jobs completed successfully.
Finally, if one of these playbooks fails, you might need to run other playbooks to recover from the failure. For example, you might need to restore your network devices using the backup that was created if the playbook used to configure NTP fails.
Automation controller supports workflow job templates to make it easier to automate complex operations. A workflow job template connects multiple job templates into a single workflow. When launched, a workflow job template launches a job using the first job template. Depending on whether that job succeeds or fails, the workflow job template determines which job template to launch next. This allows you to launch a sequence of jobs, and to automatically take recovery steps if a job fails.
You can start workflow job templates in many ways:
Manually, from the automation controller web UI
As a scheduled job
By an external program using the automation controller API
Workflow job templates do not only run job templates serially. Using the graphical workflow editor, workflow job templates can chain together multiple job templates and run different job templates depending on whether the previous one succeeded or failed.
You need to create a workflow job template before associating a workflow with it.
You create a workflow job template much the same way you create a job template:
Navigate to → and then click → .
At a minimum, enter a name for the workflow template and then save the template.
After creating a workflow job template, you can define an associated workflow by using the workflow visualizer.
After you have created a workflow job template, the workflow visualizer becomes active on the tab of the workflow job template. The workflow visualizer is a graphical interface for defining the node types to incorporate in a workflow, as well as the decision tree structure that chains the job templates together.
The workflow visualizer contains a single button that represents the starting point for the workflow. Click to start editing the workflow. The workflow visualizer displays a list of node types that you can use for the first step of the workflow. These node types are described in the following table. When added to the workflow, each node is identified by a symbol in the lower left of the node.
| Node type | Purpose | Symbol |
|---|---|---|
| Request manual approval before workflow continues. | ||
| Synchronize inventory from a specified source. | ||
| Run a job template. | ||
| Synchronize a specified project. | ||
| Run one of the management jobs. | ||
| Run another workflow job template. |
Being able to add job templates and other resources ensures that, for example, project and inventory resources are synchronized before the workflow job uses job templates that depend on those resources.
You can select the desired node type, the specific resource, and then save it to add it as the first node in the workflow.
![]() |
After you add a workflow node, you can hover over it to open a column of icons. You can use these icons to add another node, view node details, edit the node, link to an available node, or delete the node.
When you add subsequent nodes, the page opens, prompting for the conditions under which the node should execute. You can choose one of three relationships between the new node and the preceding node:
| Run condition | Node relationship |
|---|---|
| The node resource is executed upon successful completion of the actions associated with the previous node. | |
| The node resource is executed upon failure of the actions associated with the previous node. | |
| The node resource is executed regardless of the outcome of the actions associated with the previous node. |
Select the desired condition and then click to select the new node type and the specific resource. Click to add the new node.
![]() |
A node can have more than one child node. For example, you can add a child node to a parent node using an association type. You can add a second child node to the same parent using an association type. This creates a branch in the workflow structure such that one course of action is taken upon the success of an action, and a different course is taken upon failure.
![]() |
As you add nodes to a workflow, differently colored lines connecting the nodes in the workflow editor indicate the relationships between parent and child nodes:
A green line indicates an relationship.
A red line indicates an relationship.
A blue line indicates an relationship.
In addition, if you hover your mouse pointer over a line, then the web UI displays the relationship type as text in the upper left corner of the visualizer.
You can change the type of relationship between two nodes in the visualizer by hovering over the line connecting the two nodes, and then clicking the pencil icon to edit the relationship. You can also hover over the line connecting two nodes and click the plus icon to add a new node between the two nodes.
After you create the entire decision tree structure of the workflow in the workflow editor, click to save the workflow.
The new workflow job template displays on the same page as the job templates but with a different type () and with an icon that directs you to the workflow visualizer.
![]() |
You can have a node that has the same relationship with several subsequent nodes. For example, one node can be configured with relationships to several nodes.
In the following example, automation controller always runs the two job template nodes after running the project synchronization job for the Demo Project node.
Because the Check Cisco Devices and Check Juniper Devices nodes are separate job templates, automation controller runs the jobs in parallel.
![]() |
Nodes can have multiple parent nodes. For example, you can have a node that runs if any parent node succeeds, or only if all parent nodes succeed.
If you have a configuration that uses a multiple node relationship (as described in the previous section), then you can configure convergent nodes with the following steps:
Hover over any of the parent nodes and add a new node.
Hover over one of the other parent nodes and click the chain icon.
Connect the dashed gray arrow that follows your mouse pointer to the node you just added and specify when the node should run (always, on success, or on failure). That node now has two parent nodes, and is a convergent node.
If you edit the convergent node, on its page there is a field labeled . This controls the conditions that cause the node to run.
Any is the default setting.
After all parent nodes complete, if any parent node triggers the convergent node, then automation controller runs the job for the convergent node.
All requires that all parent nodes trigger the convergent node, based on their relationship, for the convergent node to run.
In the following example from the visualizer, the convergent node Apply configuration only runs if both of its parent nodes report success.
![]() |
Workflow job templates have access to many of the features that have been discussed for job templates. Like job templates, you can add surveys to workflow job templates so that users can interactively set extra variables.
When you add a survey to a workflow job template, the resulting extra variables are accessible by every job executed by the workflow.
The procedure to launch a workflow job template is similar to how you launch a job template:
Log in to automation controller.
Navigate to → to list the available templates.
Click the icon for the desired workflow job template.
After you launch a workflow job template, the automation controller web UI redirects you to the tab for this workflow job template, and displays the progress and result in the workflow visualizer.
The workflow job page consists of two tabs. The tab displays details of the parameters for the workflow job template. The tab displays the progress of the job through the steps in the workflow.
As each step in the workflow job completes, the web UI indicates whether the step succeeded or failed. If the step succeeds, then the web UI outlines the node in green and adds a box to the node in which the upper half of the box is colored green. If the step fails, then the web UI outlines the node in red and adds a box to the node in which the lower half of the box is colored red. Within each successful or failed node, the web UI displays the amount of time it took to complete the step. Nodes that are not run are outlined in gray.
Progress from one node to another is represented in the same way as it is in the visualizer; by colored lines indicating the decision responsible for the progression:
Green indicates that the next node runs if the previous node succeeds.
Red indicates that the next node runs if the previous node fails.
Blue indicates that the next node always runs.
![]() |
You can examine the live output of the running workflow job or review the output after the job completes. In a workflow diagram that represents a currently running job or completed job, you can click each node to display the results and standard output for the job run.