Skip to content

Latest commit

 

History

History

2.6-workflows

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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:

  • If Job Template A succeeds, Job Template B is executed next.
  • If it fails, Job Template C runs instead.

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:

  • Web operations team: developing playbooks in their Git branch webops.
  • Web developers team: working in their branch webdev.

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

Web operations team tasks

  • Install httpd, firewalld, and node.js.
  • Configure SELinux settings, open the firewall, and start httpd and node.js.

Web developers team tasks

  • Deploy the latest version of the web application and restart node.js.

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
Credentials Workshop Credentials
Options tasks need to run as root so check **Privilege Escalation**

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 result.

Go to Automation Execution → Infrastructure → Inventories → Workshop Inventory

In the **Automation Execution → Infrastructure → Inventories → Workshop Inventory, select the Hosts tab and select node1 and click Run Command

Within the Details window, select Module command, in Arguments type curl http://node1/nodejs and click Next.

Within the Execution Environment window, select Default execution environment and click Next.

Within the Credential window, select Workshop Credentials and click Next.

Review your inputs and click Finish.

Verify that the output result shows Hello World


Navigation
Previous Exercise - Next Exercise

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