Create a workflow job template that requires approval to run.
Outcomes
Modify a workflow job template by adding an approval node to the workflow.
Configure an email notification when the workflow requires an approval.
Launch and approve the workflow job.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that automation controller is installed and configured with any necessary resources created in previous exercises.
[student@workstation ~]$ lab start workflow-approval
Procedure 6.2. Instructions
Review the automation controller resources created by the lab command for this exercise.
The lab command configured a workflow job template named DEV - Deploy HTTPS and Populate Webservers. You can add an approval node to that workflow job template that uses an existing notification template to alert your operations team by email. If you add that approval node at the beginning of the workflow job template, then your operations team must approve jobs launched using the workflow job template before the next on success node in the job runs.
Navigate to https://controller.lab.example.com and log in as the admin user with redhat as the password.
Navigate to → . The lab command created the workflow job template and the job templates used in this exercise. The workflow job template runs the job template and then runs either the job template if the previous job succeeds, or the job template if the previous job fails.
Navigate to → . You can see the notification listed as a notification template of type . Click the icon for the notification template and wait for the column to display the message. This ensures that the notification is working as expected.
Navigate to → . You can see the and teams listed as part of the organization.
Insert a workflow approval node as the first step for the workflow job template and modify the workflow so that it only executes when approved.
Navigate to → and click the icon for the workflow job template.
In the workflow visualizer, hover over the line connecting the button and the node, and then click the + icon (notice the description at the upper-left corner of the workflow editor).
Create the new node using the following information. Do not modify any of the other fields. Click when finished.
| Field | Value |
|---|---|
Dev approval
| |
Require approval before even starting the workflow
| |
60
| |
Approval
|
Hover over the line connecting the new approval node and the node and click the icon.
In the list, choose and click . Notice how the line that connects the two nodes changes from blue () to green ().
Click in the upper-right corner to save the changes you made to the workflow job template.
On the workflow job template, assign the role to the team. Give the team the role.
Navigate to → and click the link.
Click the tab and then click .
Click and then click .
Select the team and then click .
Select the role and then click to assign the role. Because they are part of the team, the and users now have the role.
Click again, select , and then click .
Select the team and then click .
Select the role and then click to assign the role. Because they are part of the team, the and users now have the role.
Configure the workflow job template to use the notification template. When a workflow job launched by the template requests an approval, it should trigger the notification.
Navigate to → and click the link.
Click the tab and set to on for the notification.
Run the workflow job template as user ophelia, who is a member of the Operations team.
Navigate to → to log out of the admin account. Log in again, using the ophelia user, with redhat123 as the password.
Because you were on the tab when you logged out as the admin user, when you log in with the ophelia user, the web UI attempts to return to the same tab.
The ophelia user only has the Execute role on the workflow job template. Consequently, the ophelia user does not have permission to see the notifications associated with the workflow job template, and the web UI displays a Not Found message.
Navigate to → . Because the Operations team has the Execute role, and the ophelia user is a member of that team, the ophelia user can launch the workflow job template.
Click the icon for the workflow job template. A workflow job launches, but its workflow stops at the approval node.
Notice that the icon at the top of the page indicates one pending workflow approval. Click the icon and then select the checkbox for the workflow approval. Even though the ophelia user can see the workflow approval, that user does not have sufficient permissions to approve it.
Click the notification icon in the top of the page, then select the checkbox for the workflow approval. Even though the ophelia user can see the workflow approval, that user does not have sufficient permissions to approve it.
Verify that the workflow job triggered a notification email. In a real situation, this mail would reach the people with permissions to approve the workflow. In this exercise, those people are the members of the Developers team.
Open a terminal and connect to the utility server.
[student@workstation ~]$ ssh student@utilityUse the tail command to read incoming email messages delivered to the local mailbox file of the student user. You should see the email that was sent for the approval. Your message looks similar to the following example:
[student@utility ~]$ tail -f /var/mail/student
"id": 4,
"name": "Dev approval",
"url": "https://controller.lab.example.com/#/jobs/workflow/3",
"created_by": "ophelia",
"started": "2022-05-05T18:00:11.884846+00:00",
"finished": null,
"status": "pending",
"traceback": ""
}As user david, who is a member of the Developers team, approve the workflow job.
Navigate to → to log out as user ophelia. Log in again as the david user, with redhat123 as the password.
Click the notification icon, and then select the checkbox for the workflow approval. The david user has the permissions needed to approve or deny the approval request.
Click to approve the request.
Go to the terminal window that is running the tail command and wait. After a few seconds, you should see a notification email arrive that looks similar to the following example:
From system@controller.lab.example.com Thu May 5 14:18:35 2022
Return-Path: <system@controller.lab.example.com>
X-Original-To: aap-admins@lab.example.com
Delivered-To: aap-admins@lab.example.com
Received: from controller.lab.example.com (controller.lab.example.com [172.25.250.7])
by utility.lab.example.com (Postfix) with ESMTPS id B5ABD938DAC
for <aap-admins@lab.example.com>; Thu, 5 May 2022 14:18:35 -0400 (EDT)
Received: from controller.lab.example.com (localhost [IPv6:::1])
by controller.lab.example.com (Postfix) with ESMTP id 9DF3A30404AA
for <aap-admins@lab.example.com>; Thu, 5 May 2022 14:18:35 -0400 (EDT)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: The approval node "Dev approval" was approved.
https://controller.lab.example.com/#/jobs/workflow/3
From: system@controller.lab.example.com
To: aap-admins@lab.example.com
Date: Thu, 05 May 2022 18:18:35 -0000
Message-ID:
<165177471562.4668.18225658775475317495@controller.lab.example.com>
The approval node "Dev approval" was approved. https://controller.lab.example.com/#/jobs/workflow/3
{
"id": 4,
"name": "Dev approval",
"url": "https://controller.lab.example.com/#/jobs/workflow/3",
"created_by": "ophelia",
"started": "2022-05-05T18:00:11.884846+00:00",
"finished": "2022-05-05T18:18:35.040965+00:00",
"status": "successful",
"traceback": ""
}When finished, press Ctrl+C to exit the tail command.
Exit the terminal session on the utility system.
[student@utility ~]$ exitVerify that the workflow job completed successfully.
Navigate to → and wait for the workflow job to finish.
After the job succeeds, click the link for the job name, such as the link, to see the workflow results for the completed job. The number in the job name might be different from the one listed here.
(Optional) Repeat the exercise starting at step 5. This time, have the david user deny the approval request for the workflow job.
Log out from the automation controller web UI.