Ansible Automation Platform Workflows

Overview

AWX Workflows let you chain tasks together and act on the outcome. This article provides instructions in how to create an AWX Workflow.

Templates

An AWX Workflow is a series of playbooks that are created in Templates to run a task. In this case, I have a pair of HAProxy servers configured as load balancers for my Kubernetes cluster. The servers use keepalived to ensure the VIP is always available.

keepalived monitors the live server and if it goes off line, it configures the idle server to take over the VIP until the live server comes back on line.

In addition I install monit, a tool that monitors the configured service and restarts it should it fail. It has a notification process and a web server so we’ll know if the service was restarted and can investigate.

This gives us the ideal chain of Templates to try out AWX Workflows.

Workflows

The expectation before you create the AWX Workflow is that you’ve run each task individually and they all run successfully.

Under Templates, click the Add drop down but select Add workflow template.

Fill out the information in the form.

  • Name – I added HAProxy Workflow
  • Description – Installs and configures HAProxy, keepalived, and monit
  • Organization – Since this is Development, I selected my Dev organization
  • Inventory – I only have the Development Inventory.

The remainder I left for another time. I clicked Save and it brought me into the Workflow Details page. I clicked Launch and the workflow started with the Visualizer.

Visualizer

In the Visualizer, you begin with a Start block. Click it to begin creating your workflow

You are now presented with an Add Node dialog box with all of your Templates.

The Node Type lets you do pre-run actions such as synchronizing your Project or Inventory before the run, identifying someone that needs to Approve the next task before proceeding, and even merging in another Workflow. In this case, we’ll simply use the default Job Template and build a simple Workflow.

For this example, select the HAProxy Install Template and click Save.

Now we’re presented with the Virtualizer that shows the Start box plus the first Node we created, the HAProxy Install node. When hovering over the node, multiple options become available.

  • Plus – Add a new node
  • i – See details about this node
  • Pencil – Edit this node
  • Link – Link in a node
  • Trashcan – Delete this node

Click the Plus and you’ll be presented with a Add Node dialog box. This one first lets you select how to proceed. On Success, On Failure, Always. In this case we want to simply continue so select On Success.

Click Next and the second task is available. Like the first time, you can select Approve, sync Project or Inventory, link in a Workflow, or simply add a new Job Template. Select the HAProxy Config Job Template and click Save.

Continue until you have a Workflow that consists of HAProxy, keepalived, and Monit. There doesn’t seem to be a way to move the Workflow tasks so it’s a straight line. You can move the Workflow to see the rightmost task and continue to add Nodes.

When done, click the Save button at the top right and you’re ready to rock!

Run Workflow

When you’re ready to run the new Workflow, simply go to the Templates task and click the Launch icon next to the Workflow.

Sibling Nodes

In the example, we created a long chain of events. Basically running each task after the prior task completed. But do these really need to be run in such a way? AWX Workflows lets you create Sibling Nodes. These Nodes are in the same column so are run simultaneously. For our example, we create Sibling Nodes for the three binary installations and then Child Nodes to configure the software.

Errors

Of course errors can occur. When they do, the Node will indicate an error status and if you selected On Success, the next Node will not start.

In case of error, simply click on the Node tile and it’ll take you to the job so you can troubleshoot.

My issue in this case the error is that the image couldn’t be pulled from quay.io. This is a problem where I live in that I’m on High Speed WiFi which isn’t always sufficient to pull the necessary image in time before it times out. I do want these containers (awx-ee:latest) to be local so the image is pulled locally vs pulled from quay.io every time I run a job. But I’ve been unable to identify where this is defined in the AWX manifest files.

Kubernetes

Just for some background, the AWX process creates multiple containers in the AWX namespace in Kubernetes. When you execute a Template, be it a Job Template or Workflow Template, an automation-job-[job id]-[unique id] container is created. This lets the orchestration environment start containers where they have sufficient resources to run.

References

In the Visualizer Editor, there’s a link to the Visualizer documentation that provides more detail on the process of creating and running AWX Workflows. I’ve added the link here as well.

This entry was posted in ansible, Computers and tagged , , , . Bookmark the permalink.

One Response to Ansible Automation Platform Workflows

  1. Pingback: Kubernetes Index | Motorcycle Touring

Leave a Reply

Your email address will not be published. Required fields are marked *