Image

When you use Ansible Automation Platform (AAP), you create job templates to execute Ansible playbooks. You also define which inventory, credentials, Execution Environments, and other parameters the playbook uses.
[ Get started with IT automation with the Ansible Automation Platform beginner's guide. ]
Workflow job templates allow you to coordinate the execution of job templates. These workflow templates amplify the power of your individual job templates because they allow you to:
Each of those actions becomes a "node" on a workflow template, which you can create using the AAP web interface. This allows you to visualize the flow of actions. You can see which ones occur at the beginning and which ones are executed on the previous node's success or failure.
In this article, I'll show how to create workflow templates with Approval nodes and using Recovery nodes.
For this example, I've created three job templates:
I like using numbers as part of the names of playbooks and job templates because then I can control how they appear when I am browsing.
The nodes in the workflow template look like this:
Key aspects:
[ Want to test your sysadmin skills? Take a skills assessment today. ]
The following is a step-by-step guide to creating a workflow.
1. Click on Templates under Resources, then select Add and Add workflow template.
2. Fill in the basic information about the workflow template and click Save.
3. Click on the Start icon to begin.
4. Add a node for project synchronization, and then select Save.
5. Click on the + icon, and choose the next node.
6. Under Run, choose On Success, then Next.
7. Select the first Job Template and Save.
8. Repeat the procedure to add another node.
9. The Run type is the same as before: On Success. The difference is that the Node type must be set to Approval this time.
In this simple workflow, do not define a timeout for the Approval node. If you add a timeout, the approval is automatically denied without explicit approval from an admin.
10. Continue adding a node:
11. In the end, you have a diagram like the one below. Click on the node 01_Validate to add a different node.
12. This time, the Run type is On Failure.
13. Add the job template 90_Recovery.
Now you have a diagram like this:
[Cheat sheet: Old Linux commands and their modern replacements ]
You can create a workflow that integrates an approval process:
The key ideas for workflow recovery are:
[ Download now: A system administrator's guide to IT automation. ]
Here's one situation where you could apply this idea. Suppose that before creating a virtual machine, you need to reserve resources, like IP addresses or space in your storage area network. Should something go wrong during validation, it could be helpful to release those resources, and you could do that with a Recovery job template.
This is a high-level demonstration of how to create a workflow template in AAP using Approval nodes and Recovery actions. Workflows can be more elaborate and complex than what I've demonstrated in this article, and you need to find the best balance between usefulness and maintainability. In many use cases, though, workflow templates are a great tool for improving automation within your organization.
Roberto Nozaki (RHCSA/RHCE/RHCA) is an Automation Principal Consultant at Red Hat Canada where he specializes in IT automation with Ansible. More about me