Lab Guide: Automating OS Patching on Azure VMs
A guide to creating a Job Template to perform and report on OS patching for virtual machines in Microsoft Azure.
Estimated time to complete: 15 minutes
Lab Overview
In this challenge, you will create a Job Template to automate the patching of a Red Hat Enterprise Linux (RHEL) server running on Azure. You will also configure the job to generate an HTML report that can be viewed from a web browser.
1. Task 1: Create and Run the Patching Job Template
You will start by creating a job template, adding a survey to make it interactive, and then running it to patch the Linux host.
-
Navigate to the Ansible Automation Platform UI.
Click on the Ansible Automation Platform tab at the top of your lab window.
-
Log in with the provided credentials.
Parameter
Value
Username
adminPassword
ansible123! -
Navigate to the Templates page.
Expand the
Automation Executionmenu on the left.Automation Execution→Templates. -
Initiate the creation of a new job template.
Click the
+ Create Templatethen scroll down and clickCreate job template -
Enter the job template details.
Fill out the form with the following information:
Parameter
Value
Name
Linux PatchingJob Type
RUNInventory
Azure InventoryProject
Product Demos ProjectPlaybook
linux/patching.ymlExecution Environment
Default execution environmentCredentials
RHEL on AzureTo select the credential, click in the text field or on the drop down icon, then select the RHEL on Azurecredential. -
Save the job template.
Scroll to the bottom, click
Create job template. -
Add the first survey question.
Navigate to the
Surveytab and click the blueCreate survey questionbutton. Configure the first question as follows:Parameter
Value
Question
Enter the Linux Host you want to patchAnswer variable name
_hostsAnswer type
TextDefault answer
RHEL-ansibleClick
Create survey question. -
Add the second survey question.
On the survey page, click the blue
Create survey questionbutton. Configure the second question as follows:Parameter
Value
Question
Where should the RHEL Patching report be generated?Answer variable name
report_serverAnswer type
TextDefault answer
reportserverClick
Create survey question. -
Enable the survey.
You must enable the survey by clicking the toggle switch at the top of the survey page. The text will change from
SURVEY DisabledtoSURVEY enabled. -
Launch the template.
Navigate back to the Templates page. Find the
Linux Patchingtemplate and click🚀 Launch templateicon. -
Complete the survey and run the job.
You will be prompted with the survey questions. Accept the default answers by clicking
Next, then clickFinishto run the job. -
Observe the output.
The job will run and apply any available patches to the
RHEL-ansiblehost. The output will contain URLs for the reports, which you will view in the next task.
2. Task 2: View the Patching Report
The automation job generates HTML reports detailing the available patches and what actions were taken.
-
Locate the report URLs in the job output.
The output from the
Linux Patchingjob will contain URLs for the generated reports. They will look similar to this: -
View the reports.
Copy and paste each URL into a new browser tab to view them. The
linuxpatch.htmlreport provides a detailed list of all package updates that were installed or removed. -
Re-run the job and observe the changes.
Launch the
Linux Patchingjob a second time. Once it completes, refresh the report URLs in your browser. You will see that the report has been updated with the latest information, confirming that no new patches were needed.
| While this challenge focuses on Linux, Ansible Automation Platform can be used to perform Windows patching with similar workflows. |