Read this in other languages:
English, 日本語, Portugues do Brasil, Française, Español.
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.
You have two departments in your organization:
webops
.webdev
.When a new Node.js server is needed, the following tasks must be performed:
httpd
, firewalld
, and node.js
.SELinux
settings, open the firewall, and start httpd
and node.js
.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.
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 |
|
Click 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 |
|
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 |
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
.
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.
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.
Click Save to finalize the workflow.
Within the Deploy Webapp Server template, click 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