AUTOMATING HAPROXY USING ANSIBLE ON TOP OF AWS

AUTOMATING HAPROXY USING ANSIBLE ON TOP OF AWS

Task Description 📃

Use Ansible playbook to Configure Reverse Proxy i.e. Haproxy and update it's configuration file automatically on each time new Managed node (Configured With Apache Webserver) join the inventory over AWS using instance over there.

WHAT IS LOAD BALANCER?

No alt text provided for this image


A load balancer may be:

  • A physical device, a virtualized instance running on specialized hardware or a software process.
  • Incorporated into application delivery controllers (ADCs) designed to more broadly improve the performance and security of three-tier web and microservices-based applications, regardless of where they’re hosted.
  • Able to leverage many possible load balancing algorithms, including round robin, server response time and the least connection method to distribute traffic in line with current requirements.

WHAT IS HAPROXY?

No alt text provided for this image


HAProxy is a free, amazingly fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for extremely high traffic web sites and powers quite a number of the world’s most visited ones. Over the years it has become the de-facto standard opensource load balancer, is now shipped with most mainstream Linux distributions, and is often deployed by default in cloud platforms. Its mode of operation makes its integration into existing architectures very easy and riskless, while still offering the possibility not to expose fragile web servers to the internet.

Let's Get Started

Step 1: Launch AWS Instances

I have launched 4 instances (3 instances for Backend Server, 1 for LoadBalancer )

No alt text provided for this image

Step 2: Adding IPs of instances in the inventory file (2 Groups: One for Haproxy and other one for backend servers):

vim /root/ip.txt
No alt text provided for this image

Ansible config:

No alt text provided for this image

Step 3: Lets check the connectivity with the instances:

ansible -m ping all

No alt text provided for this image

Step 4: Lets create the Ansible Playbook: (For reverse proxy and web server)

No alt text provided for this image
vim index.php

No alt text provided for this image

Step 5: To update HAProxy Configuration file automatically on each time new managed node join the inventory:

No alt text provided for this image

Step 6: Lets Run the Playbook

ansible-playbook play.yml

No alt text provided for this image
No alt text provided for this image

Lets Test the Web Pages:

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image



No alt text provided for this image


To view or add a comment, sign in

More articles by GAURAV SINGH SHEKHAWAT

Insights from the community

Others also viewed

Explore topics