Workshop Exercise - Three Tier App

Table of Contents

Objectives

Guide

Three Tier App

This use-case will focus on conversion from CentOS (though this could be another RHEL derivative) to RHEL while maintaining a 3 tier application stack (do no harm). We will utilize an additional project in Ansible Automation Platform, “Three Tier App / Prod”, which will allow us to install a three tier application stack, consisting of HAProxy, Tomcat, and PostgreSQL, across the three CentOS nodes. Additionally, the project also provides a means to test/verify functionality of the application components, which we will perform before and after CentOS to RHEL conversions.

Role Inventory name
Automation Automation Platform controller ansible-1
Satellite Server satellite
CentOS/OracleLinux Host 4 - HAProxy node4
CentOS/OracleLinux Host 5 - Tomcat node5
CentOS/OracleLinux Host 6 - PostgreSQL node6
A Note about using Satellite vs. Ansible Automation Platform for this…
Out of the box, Satellite 6 supports RHEL systems roles (a collection of Ansible Roles) for a limited set of administration tasks. Satellite can be used to do OS conversions and upgrades, however an Ansible Automation Platform Subscription is required to execute complicated OS conversions and upgrades that require logic to meet up-time requirements. Using these two solutions together ensures you have the best tool for the job for:
- Content Management (Satellite)
- OS Patching & Standardized Operating Environments (Satellite)
- Provisioning: OS, Infra Services and Applications/Other (Satellite and/or Ansible Automation Platform)
- Configuration of Infra and Apps (Ansible Automation Platform)

Reference: Converting CentOS to RHEL with Red Hat Satellite 6 and Leapp Upgrade with Satellite 6

Step 1 - Set Instance Tags

Note

  • This workshop is utilizing virtual machines/servers running on Amazon Web Services (AWS). AWS nomenclature utilizes the term instance to designate a virtual machine/server.
  • In AWS, a tag is a key-value pair applied to a resource to hold metadata about that resource. Each tag is a label consisting of a key and an optional value. For example, if we wanted to designate a name tag for an instance named node4.example.com within AWS, we could assign –> key: name, value: node4.example.com. Utilizing tags are a suggested practice for grouping resources in logical manners (not just in AWS, but in other hyperscaler clouds, as well as even in Vsphere, etc). We will see that when utilized properly, tags are a powerful means for constructing dynamic infrastructure inventories that can be utilized within Ansible Automation Platform to target the correct components in a hybrid cloud infrastructure.

Step 2 - Update Ansible Inventory

  "group_tag_map": {
    "node4.example.com": "frontends",
    "node5.example.com": "apps",
    "node6.example.com": "appdbs"
  },
  "app_stack_name": "stack02"

Step 3 - Install Three Tier Application

3tier-install-stack

This will take ~2 minutes to complete.

3tier-install

Step 4 - Smoke Test Three Tier Application

Now that our three tier application is installed, let’s cover the application stack layout.

Host Component Port
node4.example.com HAProxy 80
node5.example.com Tomcat 8080
node6.example.com PostgreSQL 5432

node4.example.com proxies incoming requests on port 80 and forwards them to port 8080 on node5.example.com, where Tomcat is running a simple java application that, upon an incoming request to the servlet, creates a table in the PostgreSQL database on node6.example.com, with the table name being constructed from the date and time of the request. For example:

Table "06-06-2024-18-00" has been created!

If you’d like to manually test the application stack, you can run the following commands by switching your browser to Visual Studio Code terminal, then from ansible-1 prompt:

curl http://node4.example.com

Remember, node4.example.com is a proxy, so the above command displays the default page on node5.example.com

curl http://node4.example.com/3ta/connectordbbservlet?

The above will make a request to the Tomcat servlet, where the database table described earlier will be created on the PostgreSQL database on node6.example.com. Without writing out a complete PostgreSQL command cheat sheet, if desired, you can follow the following example command line trail (commands outlined in red rectangles) and check out the PostgreSQL system yourself:

3tier-db-check

This should take ~15 seconds to complete.

3tier-smoke-test-output

Conclusion

In this exercise, we learned about how to set instance tags to assist with identifying instances. We then turned to looking into how Ansible Automation Platform dynamic inventory sources can be utilized to generate various host groups with a given inventory. We followed that with performing an automated installation of an example three tier application stack. Finally, we verified the three tier application stack functionality via an automated application smoke test.

Use the link below to move on the next exercise.


Navigation

Previous Exercise - Next Exercise

Home