Lab Guide: Automating Day-2 Cloud Operations with AWS

A guide to using Ansible Automation Platform for Day-2 cloud operations, including dynamic inventories, job templates, and workflows.


Lab Briefing

This section provides an overview of the lab environment and key concepts in Ansible Automation Platform.

Lab Instructions

Please click the green Start button on the bottom right corner to create the lab environment if it has not already started. To navigate through this briefing, click the white > arrow on the right.

Start Button

Automation controller

The control plane for Ansible Automation Platform is the automation controller. It helps standardize how automation is deployed, initiated, delegated, and audited. You can manage inventory, launch and schedule workflows, track changes, and integrate reporting, all from a centralized user interface and RESTful API.

Automation controller dashboard

Inventories

An inventory is a collection of hosts against which automation jobs can be launched, similar to an Ansible inventory file. Inventories are divided into groups, and these groups contain the actual hosts. Groups can be sourced manually or dynamically from a supported cloud provider using Inventory Plugins.

Some of the available inventory plugins include:

  • Amazon Web Services EC2

  • Google Compute Engine

  • Microsoft Azure Resource Manager

  • VMware vSphere and vCenter

Lab Diagram

The lab topology consists of one Ansible Automation Platform controller node and two Red Hat Enterprise Linux nodes running in Amazon Web Services (AWS) as Elastic Compute Cloud (EC2) instances.

Lab topology diagram

Workflows

Workflows allow you to configure a sequence of disparate job templates that can be chained together. They can share inventory and permissions or use different ones, enabling you to build complex, multi-step automation processes.

Example of a workflow diagram

This concludes your lab briefing.


Lab Guide: Hands-On Tasks

Estimated time to complete: 15 minutes

Welcome to the Ansible Hybrid Cloud Automation - Cloud Operations lab. In this first challenge, you will learn about the pre-configured Dynamic Inventory for this lab and how it uses tags to identify resources.

Task 1: Understanding Credentials

First, you will log in and examine the pre-configured credentials for this lab.

  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. Examine the pre-configured credentials.

    In this lab, we use two different credentials:

    • RHEL on AWS - SSH KEY: An SSH key for connecting to the RHEL hosts.

    • AWS_Credential: An AWS credential for performing actions on the cloud.

      To view them, navigate to Automation ExecutionInfrastructureCredentials in the left navigation menu.

Credential keys are encrypted. Once entered into the automation controller, no one, including administrators, can view the sensitive values.

Task 2: Synchronize the AWS Inventory

Next, you will synchronize the dynamic inventory to ensure the automation controller has the latest host information from AWS.

  1. Navigate to the Inventories menu.

    In the left navigation menu, go to Automation ExecutionInfrastructureInventories.

  2. Select the AWS Inventory.

    Click on the inventory named AWS Inventory.

  3. Synchronize the inventory source.

    Select the Sources tab and click the Sync button (the icon with two circling arrows). This will update the host list from AWS.

  4. View the updated hosts.

    Wait for the synchronization job status to show Success, then click on the Hosts tab to view the discovered EC2 instances.

Task 3: Create a Job Template to Retrieve EC2 Information

Now, you will create a job template to run a playbook that gathers and displays information about your EC2 instances.

  1. Navigate to the Templates page.

    In the left navigation menu, go to Automation ExecutionTemplates.

  2. Initiate the creation of a new job template.

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

    Create a new job template

  3. Enter the job template details.

    Fill out the form with the following information:

    Parameter

    Value

    Name

    Retrieve EC2 information

    Inventory

    AWS Inventory

    Project

    AWS Demo Project

    Playbook

    playbooks/lab2-ec2-info.yml

    Credentials

    AWS_Credential

    To select the AWS_Credential, you may need to first filter the Credential Type to Amazon Web Services.
  4. Save and launch the job template.

    Scroll to the bottom, click Save, and then Launch the template. Observe the output of the job run.

In a highly dynamic environment, the AWS inventory can change often. It’s important to trigger an inventory synchronization before running jobs that rely on that inventory. We will address this in the next task.

Task 4: Build a Workflow to Sync and Retrieve Information

To ensure you are always working with the latest inventory, you will create a workflow that first syncs the AWS inventory and then runs the job template to retrieve EC2 information.

  1. Navigate to the Templates page and initiate workflow creation.

    Go to Automation ExecutionTemplates, click the Create template button, and select Create workflow job template.

    Create a new workflow job template

  2. Enter the workflow details.

    Parameter

    Value

    Name

    WORKFLOW - Retrieve EC2 information

    Inventory

    AWS Inventory

    Click Create workflow job template. The Workflow Visualizer will open.

  3. Add the first node (Inventory Sync).

    Click the Start button. In the Add Node dialog, configure the first step:

    1. Node Type: Select Inventory Source Sync.

    2. Inventory Source: Select AWS Source.

    3. Click Next, then Save.

  4. Add the second node (Job Template).

    Hover over the AWS Source node you just created, click the + icon, and select Add node. Configure it as follows:

    1. Run type: Ensure On Success is selected.

    2. Node Type: This should default to Job Template.

    3. Job Template: Select Retrieve EC2 information.

    4. Click Next, then Save.

  5. Save and launch the workflow.

    In the top right corner of the Visualizer, click Save. Then, navigate back to the Templates page and launch the WORKFLOW - Retrieve EC2 information template.

This workflow ensures your inventory is always up-to-date before you attempt to gather information from it.


Next Steps

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