Workshop Exercise - Workflows

Read this in other languages:
uk English, japan日本語, brazil Portugues do Brasil, france Française, Español Español.

Table of Contents

Objective

The purpose of a workflow is to link multiple job templates together. These templates may or may not share inventory, playbooks, or permissions. The links can be conditional:

Workflows can include not only job templates but also project or inventory updates.

This flexibility allows different teams to collaborate efficiently. For example, a networking team can manage its own repositories and inventories, while an operations team handles other aspects. In this lab, you’ll learn how to set up a workflow.

Guide

Lab scenario

You have two departments in your organization:

When a new Node.js server is needed, the following tasks must be performed:

Web operations team tasks

Web developers team tasks

The web operations team sets up the server, and the developers deploy the application.

Note:
For this example, both teams use branches of the same Git repository. In a real scenario, your source control structure may vary.


Set up projects

First, set up the Git repositories as projects.

Warning:
If logged in as wweb, log out and log in as admin.

Within Automation Execution -> Projects, click Create Project to set up the web operations team’s project:

Parameter Value
Name Webops Git Repo
Organization Default
Execution Environment Default execution environment
Source control type Git
Source control URL https://github.com/ansible/workshop-examples.git
Source control branch/tag/commit webops
Options
  • ✓ Clean
  • ✓ Delete
  • ✓ Update Revision on Launch

Click Create project.

create_project

Repeat the process to set up the Webdev Git Repo, using the branch webdev.

Parameter Value
Name Webdev Git Repo
Organization Default
Execution Environment Default execution environment
Source control type Git
Source control URL https://github.com/ansible/workshop-examples.git
Source control branch/tag/commit webdev
Options
  • ✓ Clean
  • ✓ Delete
  • ✓ Update Revision on Launch

Set up job templates

Within Automation Execution -> Templates -> Create template -> Create job template, fill out the form with the following values:

Parameter Value
Name Web App Deploy
Inventory Workshop Inventory
Project Webops Git Repo
Playbook rhel/webops/web_infrastructure.yml
Execution Environment Default execution environment

create_template_webops

Click Create job template, and then repeat the process for the Node.js Deploy template, changing the project to Webdev Git Repo and the playbook to rhel/webdev/install_node_app.yml.


Set up the workflow

Within Automation Execution -> Templates -> Create template -> Create workflow job template, fill in the details:

Parameter Value
Name Deploy Webapp Server

Click Create workflow job template to open the Workflow Visualizer.

add_step

Click the Add Step button and assign the Web App Deploy job template to the first node. Add a second node by clicking the 3 dot sign, selecting the “Add step and link” and assign the Node.js Deploy template with the Run on success status type. Select Next and Finish to complete the workflow.

app_deploy

add_link

add_nodejs

Click Save to finalize the workflow.

overview


Launch workflow

Within the Deploy Webapp Server template, click Launch template.

launch_template

Once the workflow completes, verify the results by checking the job details. Run the following command on the control host to confirm the deployment:

curl http://nodeX/nodejs
Hello World

NOTE: X should be replaced with the appropriate number of the node you are checking.


Navigation
Previous Exercise - Next Exercise

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