Employ Ansible Automation Platform workflows so teams can collaborate more efficiently

The basic idea of a workflow in Ansible Automation Platform is to link multiple Job Templates together. They may or may not share inventory, Playbooks, or even permissions. The links can be conditional, e.g.:

  • If job template A succeeds, job template B is automatically executed afterwards.

  • In case of a failure, job template C will be run.

workflow

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

This enables new ways for teams to collaborate e.g. the application 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 repositories, playbooks, and inventory, but everything is tied together with a workflow.

The Scenario

Assume you have two teams in your organization. Each team is managing their respective content in their own Git repository:

  • The web operations team is creating playbooks to deploy web infrastructures

  • The web applications team is developing JavaScript web applications for NodeJS

When there is a new NodeJS-based website to deploy, two main steps need to happen.

The web operations team has to:

  • Install and configure NodeJS to run as a service.

  • An Apache instance needs to be installed and configured as a proxy to pass requests for the NodeJS content to the NodeJS backend. And a lot of other steps might be needed, too. Like SELinux, firewall…​ you know the drill.

The web developer team has to:

  • Deploy the most recent version of the JavaScript web application.

  • Make sure everything is prepared to run the application like the directory structure and service restarts.

As you ran the Playbook during the Configure Ansible Automation Platform with Ansible chapter some resources you need here were already setup:

  • Two Git repositories were setup as Projects Webdev Git Repo and Webops Git Repo

  • Playbooks were configured as Job Templates Web App Deploy and Web Infra Deploy

If you want to know what the Playbooks look like, check out the Git URL in the Projects.

Access the Automation Execution UI

In your browser open https://aap.MYGUID.sandboxMYSANDBOX.opentlc.com (or click on the tab "AAP" on the right of those instructions) and login as user MYUSER with the password MYPASSWORD.

Configure the Workflow

Now, you set up the Workflow to bring together the work of the two teams. In the Automation Execution section, go to the Templates resource and click the blue Create template button.

  1. Choose Create workflow job template and fill in as follows:

    • Name: Deploy Webapplication

    • Organization: Default

    • Click Create workflow job template at the bottom

    After saving the template the Workflow Visualizer opens to allow you to build a workflow. You can later open the Workflow Visualizer again by using the button labeled Visualizer on the template details page.

  2. Click on the Add step button, a dialog to configure a new workflow node opens.

  3. First, select the node type Job Template

  4. Choose the Web Infra Deploy Template

  5. Click Next then Finish

    You get into the Workflow Visualizer overview showing the first workflow node.

    • The node gets annotated with the name of the job.

    • Click the kebab-style menu right next to the existing node "Web Infra Deploy", you’ll see a number of options appearing: workflow node edit

      • Edit step to edit the current workflow node

      • Add step and link to add new workflow node

      • and a Remove step to delete current workflow node.

  6. We want to add another workflow node, so click the Add step and link sign

  7. Choose Web App Deploy as the next Job Template.

  8. The Status field sets the condition under which the next node is executed, select Run on success

    The Status field allows for more complex workflows. You could lay out different execution paths for successful and for failed Playbook runs.
  9. Click Next then Finish

    Your workflow should look like this:

    Workflow deploying Web Infra and App
  10. Back in the main Workflow Visualizer view, click Save in the upper left to save the Workflow Template.

And Action!

Your Deploy Webapplication workflow is ready to go, launch it.

Click the Launch button directly (potentially hidden behind a kebap-style/3 dots menu item) or go to the the Templates view and launch the Deploy Webapplication workflow by clicking the rocket icon.

job workflow

Note how the workflow run is shown in the job view as a visual representation of the different workflow steps. Same as for a normal job template execution you can go to the Details tab to get more information.

If you want to look at the actual Jobs behind the workflow nodes, click the workflow node. If you want to get back from a details view to the corresponding workflow, just hit your browsers back button or click on Source Workflow Job in the job template details.

After the job has finished, check if everything worked fine. To test the NodeJS application in your terminal, run:

curl http://node1.example.com/nodejs

You should be greeted with a friendly Hello World. Well done!