workshops

Training Course for Ansible Automation Platform

This project is maintained by ericzji

Exercise 2.6 - Workflows

Read this in other languages: uk English, japan 日本語.

Ansible Tower Workflows

Workflows were introduced as a major new feature in Ansible Tower 3.1. The basic idea of a workflow is to link multiple Job Templates together. They may or may not share inventory, Playbooks or even permissions. The links can be conditional:

And the workflows are not even limited to Job Templates, but can also include project or inventory updates.

This enables new applications for Tower: different Job Templates can build upon each other. E.g. the networking team creates playbooks with their own content, in their own Git repository and even targeting their own inventory, while the operations team also has their own repos, playbooks and inventory.

In this lab you’ll learn how to setup a workflow.

Lab Scenario

You have two departements in your organization:

When there is a new Tomcat server to deploy, two things need to happen:

To make things somewhat easier for you, everything needed already exists in a Github repository: Playbooks, JSP-files etc. You just need to glue it together.

Note

In this example we use two different branches of the same repository for the content of the separate teams. In reality the structure of your SCM repositories depends on a lot of factors and could be different.

Set up Projects

First you have to set up the Git repo as Projects like you normally would. You have done this before, try to do this on your own. Detailed instructions can be found below.

Warning

If you are still logged in as user **wweb, log out of and log in as user admin again.**

Warning

Solution Below

Set up Job Templates

Now you have to create Job Templates like you would for “normal” Jobs.

Tip

If you want to know what the Playbooks look like, check out the Github URL and switch to the appropriate branches.

Set up the Workflow

And now you finally set up the workflow. Workflows are configured in the Templates view, you might have noticed you can choose between Job Template and Workflow Template when adding a template so this is finally making sense.

Tip

Using the red “x” allows you to remove the node, the green plus lets you add the next node and the chain-symbol links to another node .

Tip

The type allows for more complex workflows. You could lay out different execution paths for successful and for failed Playbook runs.

Tip

The Workflow Visualizer has options for setting up more advanced workflows, please refer to the documentation.

And Action

Your workflow is ready to go, launch it.

jobs view of workflow

Note how the workflow run is shown in the job view. In contrast to a normal job template job execution this time there is no playbook output on the right, but a visual representation of the different workflow steps. If you want to look at the actual playbooks behind that, click DETAILS in each step. If you want to get back from a details view to the corresponding workflow, click the w-button in the JOB TEMPLATE line in the DETAILS part on the left side of the job overview.

After the job was finished, check if everything worked fine: log into node1, node2 or node3 from your control host and run:

$ curl http://localhost:8080/coolapp/

Tip

You might have to wait a couple of minutes until Tomcat answers requests.


Click here to return to the Ansible for Red Hat Enterprise Linux Workshop