Create a new workflow job template that uses a survey to set variables, and fact caching to speed up the workflow.
Outcomes
Create a workflow job template.
Create an associated survey and notification template.
Launch the workflow job template from the automation controller web UI.
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-review
Procedure 6.3. Instructions
Create a workflow job template that deploys your web servers to the test environment, and after approval, to production. As part of this process, rename the existing TEST webservers setup job template to Webservers setup and configure the job template to prompt for an inventory. This allows you to use a single job template for both the test and production environments. The Webservers setup job template needs to use facts cached from earlier in the workflow. The workflow job template also needs to prompt the user with a survey to set some variable values when the workflow job template is launched.
Navigate to https://controller.lab.example.com and log in as the admin user with redhat as the password.
Make sure that the per-host Ansible fact cache time-out for automation controller is set for exactly one day (86400 seconds). This ensures that facts are cached for hosts but also expire if those facts have not been refreshed recently.
Update the TEST webservers setup job template with the following information, leaving the other fields untouched. Make sure to clear the existing inventory entry for the job template.
| Field | Value |
|---|---|
Webservers setup
| |
Setup apache webservers
| |
Navigate to → and click the icon for the job template.
Rename to Webservers setup and change the description to Setup apache webservers.
Clear the inventory selection and select for the inventory.
Scroll to the bottom of the page, select in the section, and then click . Do not change any of the other fields.
Create a workflow job template called with the following information. In the following steps, you create nodes for the workflow job template.
Table 6.1. Workflow Template
| Field | Value |
|---|---|
From Test to Prod
| |
Deploy to Test and on success deploy to Prod
| |
Start the workflow for the workflow job template by synchronizing the project. Create the first node using the following information:
Using the workflow visualizer for the workflow job template, click . Create the first node using information from the Workflow Node #1 table and then click .
The symbol under the node in the workflow visualizer indicates it is a project sync node.
The blue line connecting and the node indicates that this step is always performed.
If the node succeeds, then launch the job template. Create the second node using the following information:
Using the workflow visualizer for the workflow job template, hover over the node and then click .
Select and click .
Create the second node using information from the Workflow Node #2 table and then click .
Select the inventory and click . Click .
The symbol under the node in the workflow visualizer indicates it is a job template node.
The green line connecting the node and the node indicates that this step is performed only on success.
If the node succeeds, then launch the job template. Create the third node using the following information:
If the node succeeds, then create an approval node using the following information:
Using the workflow visualizer for the workflow job template, hover over the node and then click .
Select and click .
Create the fourth node using information from the Workflow Node #4 table and then click .
The pause symbol () under the node in the workflow visualizer indicates it is an approval node.
After a successful launch of job templates in the test environment, the workflow indicates requesting an approval to launch them in production.
If the node succeeds, then launch the job template. Create the fifth node using the following information:
If the node succeeds, then launch the job template. Create the sixth node using the following information. This is the final node in the workflow job template.
Using the workflow visualizer for the workflow job template, hover over the node and then click .
Select and click .
Create the sixth node using information from the Workflow Node #6 table and then click .
Select the inventory and click . Click .
Click to save the workflow and exit the workflow visualizer.
Add a survey to the workflow job template containing the following information. Make sure you enable the survey.
Table 6.8. Workflow Job Template Survey
| Field | Value |
|---|---|
What version are you deploying?
| |
This version number is displayed at the bottom of the index page.
| |
deployment_version
| |
| (selected) | |
1
| |
40
| |
v1.0
|
Navigate to → and click the link.
Click the tab and then click .
Add a single question to the survey, using the information in the Workflow Job Template Survey table. When finished, click .
Enable the survey by setting the switch to on.
The survey is disabled by default. Make sure that you enable it.
Activate the , , and notifications for the workflow job template using the existing notification template.
Launch the workflow job template. When prompted by the survey, enter v1.3 for the deployment version.
Navigate to → and then click the icon for the workflow job template.
Enter v1.3 in the text field for the survey that you just created, and then click .
Click to launch the workflow. Observe the running jobs of the workflow.
The workflow stops on the approval node. Notice the notification icon at the top of the page, indicating one pending workflow approval.
Approve the execution of the remaining workflow job template nodes and verify that the workflow triggers an email notification for the approval, when approved, and after completion.
The Email AAP Admins notification template sends emails to the aap-admins@lab.example.com email alias. The student user can access these emails on the utility server.
Open a terminal and connect to the utility server.
[student@workstation ~]$ ssh student@utilityUse the tail command to view incoming messages 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:
[student@utility ~]$ tail -f /var/mail/student
"id": 10,
"name": "Prod Approval",
"url": "https://controller.lab.example.com/#/jobs/workflow/6",
"created_by": "admin",
"started": "2022-05-13T21:53:29.886316+00:00",
"finished": null,
"status": "pending",
"traceback": ""
}Click the notification icon in the automation controller web UI, select the checkbox for the workflow approval, and then click .
Go to the terminal window running the tail command and wait a few seconds. You should see an approval notification email arrive that looks similar to the following example:
From system@controller.lab.example.com Fri May 13 17:57:15 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 E81EA938CEC
for <aap-admins@lab.example.com>; Fri, 13 May 2022 17:57:13 -0400 (EDT)
Received: from controller.lab.example.com (localhost [IPv6:::1])
by controller.lab.example.com (Postfix) with ESMTP id CF7DC25D127
for <aap-admins@lab.example.com>; Fri, 13 May 2022 17:57:13 -0400 (EDT)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: The approval node "Prod Approval" was approved.
https://controller.lab.example.com/#/jobs/workflow/6
From: system@controller.lab.example.com
To: aap-admins@lab.example.com
Date: Fri, 13 May 2022 21:57:13 -0000
Message-ID:
<165247903382.5344.15434941766628918585@controller.lab.example.com>
The approval node "Prod Approval" was approved. https://controller.lab.example.com/#/jobs/workflow/6
{
"id": 10,
"name": "Prod Approval",
"url": "https://controller.lab.example.com/#/jobs/workflow/6",
"created_by": "admin",
"started": "2022-05-13T21:53:29.886316+00:00",
"finished": "2022-05-13T21:57:13.356070+00:00",
"status": "successful",
"traceback": ""
}Navigate to → in the automation controller web UI and wait for the workflow job to finish.
Go to the terminal window running the tail command. You should see a new notification email indicating the successful execution of the workflow. The notification looks similar to the following example:
From system@controller.lab.example.com Fri May 13 17:57:47 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 53C0C938CEC
for <aap-admins@lab.example.com>; Fri, 13 May 2022 17:57:47 -0400 (EDT)
Received: from controller.lab.example.com (localhost [IPv6:::1])
by controller.lab.example.com (Postfix) with ESMTP id 4D82325D127
for <aap-admins@lab.example.com>; Fri, 13 May 2022 17:57:47 -0400 (EDT)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Workflow Job #6 'From Test to Prod' successful:
https://controller.lab.example.com/#/jobs/workflow/6
From: system@controller.lab.example.com
To: aap-admins@lab.example.com
Date: Fri, 13 May 2022 21:57:47 -0000
Message-ID:
<165247906731.5344.18226747658229373298@controller.lab.example.com>
Workflow Job #6 had status successful, view details at https://controller.lab.example.com/#/jobs/workflow/6
{
"id": 6,
"name": "From Test to Prod",
"url": "https://controller.lab.example.com/#/jobs/workflow/6",
"created_by": "admin",
"started": "2022-05-13T21:52:53.307159+00:00",
"finished": "2022-05-13T21:57:46.714992+00:00",
"status": "successful",
"traceback": "",
"body": "Workflow job summary:\n\n- node #1 spawns job #7, \"My Webservers\", which finished with status successful.\n- node #2 spawns job #8, \"Refresh Fact Cache\", which finished with status successful.\n- node #3 spawns job #9, \"Webservers setup\", which finished with status successful.\n- node #6 spawns job #10, \"Prod Approval\", which finished with status successful.\n- node #5 spawns job #11, \"Refresh Fact Cache\", which finished with status successful.\n- node #4 spawns job #12, \"Webservers setup\", which finished with status successful."
}When finished, press Ctrl+C to exit the tail command.
If you prefer, you can use the mailx or mutt commands to display mail messages on the utility server. The subject of the emails received includes the following text:
The approval node "Prod Approval" needs review.
The approval node "Prod Approval" was approved.
Workflow Job #6 'From Test to Prod' successful.
Exit the terminal session on the utility system.
[student@utility ~]$ exitVerify that the web servers in the Test and Prod inventories (serverc.lab.example.com, serverd.lab.example.com, servere.lab.example.com, and serverf.lab.example.com) display the Deployment Version: v1.3 line.
Open a web browser and navigate to http://serverc.lab.example.com, http://serverd.lab.example.com, http://servere.lab.example.com, and http://serverf.lab.example.com in separate tabs. You should see this line at the bottom of each page:
Deployment Version: v1.3
When ready, log out from the automation controller web UI.