Lab Guide: Deploying Applications with Ansible

A guide to deploying applications to Linux hosts using a job template and verifying the installation with ad-hoc commands.


Lab Briefing

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

Challenge Summary

In this challenge, you’ll deploy applications to your Linux hosts using a pre-created Job Template named Deploy Application.

After launching the template, you will monitor its progress. Finally, you will use Ansible Automation Platform’s ad-hoc command capability to verify that the application was installed correctly. This built-in functionality allows operations teams to get value right away without needing to write a full Ansible Playbook.

Infrastructure Use Cases

Ansible can automate many hybrid cloud tasks, as well as your on-premises Linux and Windows infrastructure. Red Hat refers to this as infrastructure automation.

Diagram showing infrastructure automation use cases

The use case you are focusing on in this lab is application deployment.

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 deploy applications using the Ansible Automation Platform.

Task 1: Deploy Applications with a Job Template

In this task, you will launch a pre-configured job template and use a survey to specify which applications to deploy and on which hosts.

  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. Launch the "Deploy Application" job template.

    Find the Deploy Application template in the list and click the Launch icon (🚀).

  5. Complete the survey.

    You will be prompted with a survey. Configure it as follows:

    1. In the first field, the default application is httpd. Add nginx to the list of applications to install.

    2. In the second field for hosts, the default is rhel1. Add rhel2 to also install the applications on the second host.

    3. Click Next.

  6. Review and finish the job.

    On the Review screen, observe the job details and the extra variables generated by the survey. Click Finish to launch the job.

  7. Monitor the job progress.

    The job will take a few moments to complete. The output will confirm which applications were installed on each host.

Task 2: Verify Installation with an Ad-Hoc Command

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

  1. Navigate to your inventory hosts.

    In the left navigation menu, go to Automation ExecutionInfrastructureInventories, click on AWS Inventory, and then select the Hosts tab.

  2. Select hosts and run a command.

    Select the checkbox next to both rhel1 and rhel2, then click the Run command button.

  3. 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. Click Next.

    3. Credential View: Select RHEL on AWS - SSH KEY. Click Next.

  4. Launch the ad-hoc command.

    On the Review screen, click Finish.

  5. Observe the output.

    The job will complete in a few moments. The output will list both hosts and provide details about the nginx service, confirming its status.


Conclusion

Thank you for taking the time to learn about automating cloud operations tasks in AWS 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.

Troubleshooting

If you have encountered an issue or have noticed something not quite right, please open an issue on GitHub.