Create an email notification template, configure a job template to use the notification template, and launch a job to confirm that the notification works.
Outcomes
Create a notification template.
Use the notification template with a job template to generate email notifications of job results.
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 job-notification
Procedure 5.3. Instructions
Navigate to https://controller.lab.example.com and log in as the admin user with redhat as the password.
Create a new notification template.
Navigate to → and then click .
Create the new notification template using the following information. When finished, click .
| Field | Value |
|---|---|
Email AAP Admins
| |
Sends an email to notify the status of the Job
| |
localhost
| |
aap-admins@lab.example.com
| |
system@controller.lab.example.com
| |
25
| |
30
|
Validate the new notification template.
Navigate to → .
Click the icon for the Email AAP Admins job template to test the notification process.
After several seconds, the column displays the message.
Configure the DEV webservers setup job template to use the new Email AAP Admins notification template. Trigger the notification when jobs using the DEV webservers setup job template either succeed or fail.
Navigate to → and then click the link.
Click the tab and then set the and switches to on for the Email AAP Admins notification.
Verify that the DEV webservers setup job template triggers a notification email after job completion.
Open a terminal and connect to the utility server.
[student@workstation ~]$ ssh student@utilityUse the tail command to read incoming messages to the local mailbox file of the student user. You should see the email that was sent by the test notification launched from a previous step. Your message looks similar to the following:
[student@utility ~]$ tail -f /var/mail/student
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Notification Test 1 https://controller.lab.example.com
From: system@controller.lab.example.com
To: aap-admins@lab.example.com
Date: Fri, 22 Apr 2022 19:39:31 -0000
Message-ID: <165065637197.1384.7900890983573152025@controller.lab.example.com>
Test Notification 1 https://controller.lab.example.comIf you prefer, then use the mailx or mutt commands to display mail messages on the utility server.
From the automation controller web UI, navigate to → and then click the icon for the job template.
In the survey window, enter v1.2 for the deployment version, click , and then click .
Go to the terminal window running the tail command and wait. After about one minute, you should see a notification email arrive that looks similar to the following example. When finished, press Ctrl+C to exit the tail command.
From system@controller.lab.example.com Fri Apr 22 15:44:03 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 EDB3418BB563
for <aap-admins@lab.example.com>; Fri, 22 Apr 2022 15:44:03 -0400 (EDT)
Received: from controller.lab.example.com (localhost [IPv6:::1])
by controller.lab.example.com (Postfix) with ESMTP id CF64D195822E
for <aap-admins@lab.example.com>; Fri, 22 Apr 2022 15:44:03 -0400 (EDT)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Job #10 'DEV webservers setup' successful:
https://controller.lab.example.com/#/jobs/playbook/10
From: system@controller.lab.example.com
To: aap-admins@lab.example.com
Date: Fri, 22 Apr 2022 19:44:03 -0000
Message-ID:
<165065664382.1385.10783097240459901012@controller.lab.example.com>
Job #10 had status successful, view details at https://controller.lab.example.com/#/jobs/playbook/10
{
"id": 10,
"name": "DEV webservers setup",
"url": "https://controller.lab.example.com/#/jobs/playbook/10",
"created_by": "admin",
"started": "2022-04-22T19:43:40.383371+00:00",
"finished": "2022-04-22T19:44:02.979429+00:00",
"status": "successful",
"traceback": "",
"inventory": "Dev",
"project": "My Webservers DEV",
"playbook": "apache-setup.yml",
"credential": "Developers",
"limit": "",
"extra_vars": "{\"deployment_version\": \"v1.2\"}",
"hosts": {
"serverb.lab.example.com": {
"failed": false,
"changed": 6,
"dark": 0,
"failures": 0,
"ok": 7,
"processed": 1,
"skipped": 0,
"rescued": 0,
"ignored": 0
},
"servera.lab.example.com": {
"failed": false,
"changed": 6,
"dark": 0,
"failures": 0,
"ok": 7,
"processed": 1,
"skipped": 0,
"rescued": 0,
"ignored": 0
}
}
}
^CExit the terminal session on the utility system.
[student@utility ~]$ exitVerify that the web servers have been updated successfully on servera.lab.example.com and serverb.lab.example.com.
Open a web browser and navigate to http://servera.lab.example.com and http://serverb.lab.example.com in separate tabs. You should see this line at the bottom of each page:
Deployment Version: v1.2
Based on the DEV webservers setup job template, schedule a new job at three minutes from the current time.
From a terminal window, display the current date, time, and time zone used by the controller server. Your environment might display a different date and time than this example. Use the identified time zone when you create your new schedule.
[student@workstation ~]$ ssh controller timedatectl
Local time: Fri 2022-04-22 16:14:45 EDT
Universal time: Fri 2022-04-22 20:14:45 UTC
RTC time: Fri 2022-04-22 20:14:44
Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
NTP service: active
RTC in local TZ: noNavigate to → and then click the link.
Click the tab and then click .
Schedule the job using the following information. The date defaults to the current date. If necessary, adjust the time zone to match the one used by the controller server. When finished, click to create the new schedule.
| Field | Value |
|---|---|
Automatic job run
| |
| (Set the execution of the job to +3 minutes from the current time.) | |
| (The time zone that you just determined for the automation controller, America/New_York in the preceding example.) | |
Navigate to → and wait for the scheduled job to be executed. The scheduled job succeeds.