Workshop Exercise - Three Tier App

Table of Contents

Objectives

Guide

Three Tier App

This use-case will focus on the in-place upgrade of RHEL to the next major version 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 RHEL nodes. Additionally, the project also provides a means to test/verify functionality of the application components, which we will perform before and after RHEL in-place upgrades.

Role Inventory name
Automation controller ansible-1
Satellite Server satellite
RHEL Host 1 - HAProxy node1
RHEL Host 2 - Tomcat node2
RHEL Host 3 - PostgreSQL node3
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

Step 2 - Update Ansible Inventory

  "group_tag_map": {
    "node1.example.com": "frontends",
    "node2.example.com": "apps",
    "node3.example.com": "appdbs"
  },
  "app_stack_name": "stack01"

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
node1.example.com HAProxy 80
node2.example.com Tomcat 8080
node3.example.com PostgreSQL 5432

node1.example.com proxies incoming requests on port 80 and forwards them to port 8080 on node2.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 node3.example.com, with the table name being constructed from the date and time of the request. For example:

Table "21-06-2024-20-52" 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://node1.example.com

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

curl http://node1.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 node3.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 the next exercise.


Navigation

Previous Exercise - Next Exercise

Home