Lab Guide: Deploying Applications on Azure VMs

A guide to deploying applications to virtual machines in Microsoft Azure using the Ansible Automation Platform.

Estimated time to complete: 15 minutes


Lab Overview

In this final challenge, you will create and run a job template to deploy an application to a Red Hat Enterprise Linux (RHEL) virtual machine on Azure. You will then verify the installation using an ad-hoc command.


1. Task 1: Create the "Deploy Application" Job Template

First, you will create a job template with a survey that allows a user to select which application to install and where.

  1. Navigate to the Ansible Automation Platform UI.

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

  2. Log in with the provided credentials.

    Parameter

    Value

    Username

    admin

    Password

    ansible123!

  3. Navigate to the Templates page.

    Expand the Automation Execution menu on the left. Automation ExecutionTemplates.

  4. Initiate the creation of a new job template.

    Click the + Create Template then scroll down and click Create job template

  5. Enter the job template details.

    Fill out the form with the following information:

    Parameter

    Value

    Name

    Deploy Application

    Job Type

    Run

    Inventory

    Azure Inventory

    Project

    Product Demos Project

    Playbook

    linux/deploy_application.yml

    Execution Environment

    Default execution environment

    Credentials

    RHEL on Azure

  6. Save the job template.

    Scroll to the bottom, click Create job template.

  7. Add the first survey question.

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

    Parameter

    Value

    Question

    Enter the Linux Host you want to deploy the application to

    Answer variable name

    _hosts

    Answer type

    Text

    Default answer

    RHEL-ansible

    Click Create survey question.

  8. Add the second survey question.

    On the survey page, click the blue Create survey question button. Configure the second question as follows:

    Parameter

    Value

    Question

    Which application do you want to install?

    Answer variable name

    application

    Answer type

    Multiple Choice (single select)

    Multiple Choice Options

    nginx, gdb, httpd, nano

    After entering the options, select the radio button next to nginx to make it the Default option.Click Create survey question.
  9. 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 Disabled to SURVEY enabled.

2. Task 2: Run the Job Template

Now you will launch the template and use the survey to deploy an application.

  1. Navigate to the Templates page.

    Expand the Automation Execution menu on the left. Automation ExecutionTemplates.

  2. Launch the "Deploy Application" job template.

    Find the Deploy Application template and click 🚀 Launch template icon.

  3. Complete the survey and run the job.

    You will be prompted with the survey. The default values are correct (RHEL-ansible for the host, and nginx for the application). Accept the default answers by clicking Next, then click Finish to run the job.

  4. Monitor the job progress. and observe the output.

    The job will take a few moments to complete. The output will confirm that nginx was installed on the RHEL-ansible host.

3. Task 3: Verify Installation with an Ad-Hoc Command

Finally, you will run an ad-hoc command to confirm that the nginx service was installed and is running.

  1. Navigate to the Azure Inventories

    Expand the Automation Execution menu on the left. Automation ExecutionInfrastructureInventories.

  2. Select the Azure Inventory.

    Click on the inventory named Azure Inventory. Then select the Hosts tab.

  3. Select the host and initiate the command.

    Select the checkbox next to RHEL-ansible, then click the Run Command button.

  4. Configure the ad-hoc command.

    A wizard will appear. Fill it out as follows:

    1. Details View: From the Module dropdown, select service. In the Arguments field, enter name=nginx. Click Next.

    2. Execution Environment View: Select Default execution environment from the dropdown. Click Next.

    3. Credential View: Select RHEL on Azure from the dropdown. Click Next.

  5. Launch the ad-hoc command.

    On the Review screen, click Click Finish to launch the ad-hoc command.

  6. Observe the output.

    The job will complete in a few moments. The output will show details about the nginx service on the host, confirming its status.

4. Conclusion

Thank you for taking the time to learn about automating cloud operations tasks in Azure using the Red Hat Ansible Automation Platform!

In this lab, you have seen how automation can be used to deploy applications and how ad-hoc commands can perform quick checks on target hosts. These same principles can be easily applied to other cloud environments.

5. Troubleshooting

If you have encountered an issue or have noticed something not quite right, please open an issue with the lab maintainers.