Lab Guide: Automating OS Patching on AWS

A guide to creating a job template with a survey to perform OS patching on EC2 instances.


Lab Briefing

This section provides an overview of the lab challenge and instructions for getting started.

Challenge Summary

In this challenge, you’ll perform OS patching on a Red Hat Enterprise Linux virtual machine running in AWS.

You will also use a Survey. Surveys set extra variables for a playbook in a user-friendly, question-and-answer format, making your automation more interactive and flexible.

Example of a survey prompt in automation controller

Getting Started

That is the end of your challenge briefing! Please click the green Start button in the bottom right corner of this window if the lab has not already started.

Start Button


Lab Guide: Hands-On Tasks

Estimated time to complete: 15 minutes

Your assignment is to create a Job Template to perform OS patching on EC2 instances. In this example, you will patch a Red Hat Enterprise Linux server and generate a viewable report.

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 check for available patches on the Linux host.

  1. Navigate to the Automation Controller UI.

    Click on the Automation Controller tab at the top of your lab window.

  2. Log in with the provided credentials.

    Username

    admin

    Password

    ansible123!

  3. Navigate to the Templates page.

    In the left navigation menu, go to Automation ExecutionTemplates.

  4. Initiate the creation of a new job template.

    Click the Create template button, then select Create job template.

    Create a new job template

  5. Enter the job template details.

    Fill out the form with the following information:

    Parameter

    Value

    Name

    Linux Patching

    Job Type

    Check

    Inventory

    AWS Inventory

    Project

    AWS Demo Project

    Execution Environment

    Default execution environment

    Playbook

    playbooks/lab2-patching.yml

    Credentials

    RHEL on AWS - SSH KEY

    To select the credential, you may need to first filter the Credential Type to Machine.
  6. Save the job template.

    Scroll to the bottom and click the blue Save button.

  7. Add a survey question.

    Navigate to the Survey tab and click the Create survey question button. Configure the question as follows:

    Parameter

    Value

    Question

    Enter the Linux Host you want to patch

    Answer variable name

    HOSTS

    Answer type

    Multiple Choice (single select)

    Required

    Check the box ☑️

    Multiple Choice Options

    rhel1

    Click the radio button next to rhel1 to make it the default option, then click Create survey question.

  8. 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 OFF to SURVEY ON.

    Enable Survey Toggle

  9. Launch the template.

    Click the Launch button in the top right.

  10. Complete the survey and run the job.

    You will be prompted with the survey question. Since rhel1 is already the default, click Next, review the details, and then click Finish to run the job.

We set the Job Type to Check. This runs the playbook in "dry run" mode, showing what changes would be made without actually applying them. The job output will point to the patch reports, which you will examine in the next task.

Task 2: View the Patching Report

The automation job generates HTML reports detailing the available patches.

  1. Locate the report URLs in the job output.

    The output from the Linux Patching job will contain URLs for the generated reports. They will look similar to this:

  2. View the reports.

    Copy and paste each URL into a new browser tab to view them. The linuxpatch.html report provides a detailed list of all package updates that would be installed or removed if the job were run in normal mode.

While this challenge focuses on Linux, Ansible Automation Platform can be used to perform Windows patching with similar workflows.

Next Steps

You have successfully completed this lab. Press the Next button in your lab environment to proceed to the next challenge.