Sign in
Log inSign up
Configuring Load Balancer using Ansible

Configuring Load Balancer using Ansible

Govind Singh's photo
Govind Singh
·Jul 6, 2021·

2 min read

ARTH - Task 12 👨‍💻

Task Description 📃

Use Ansible playbook to Configure Reverse Proxy i.e. Haproxy and update its configuration file automatically each time a new Managed node (Configured With Apache Webserver) joins the inventory.

Ansible

Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs. Here I will be using Ansible as a configuration manager.

Load Balancer

Load balancing is defined as the methodical and efficient distribution of network or application traffic across multiple servers in a server farm. Each load balancer sits between client devices and backend servers, receiving and then distributing incoming requests to any available server capable of fulfilling them.

What is HAProxy?

HAProxy is free, open-source software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spreads requests across multiple servers. It is written in C and has a reputation for being fast and efficient.

What is a Reverse Proxy?

A reverse proxy server is a type of proxy server that typically sits behind the firewall in a private network and directs client requests to the appropriate backend server. A reverse proxy provides an additional level of abstraction and control to ensure the smooth flow of network traffic between clients and servers.

Inventory file:

image.png

Configuration file

image.png

Check the connectivity:

image.png

Now, firstly we have to make some changes in the configuration file of the haproxy such that every time one or more IP connects to our load balancer it will dynamically update in the inventory file without manually doing by us

![image.png] (cdn.hashnode.com/res/hashnode/image/upload…)

Ansible Playbook to configure Webserver and Loadbalancer:

haproxylb.png

Running the playbook, we got the following result:

image.png

image.png

haproxy has been installed and running successfully in the load balancer node

image.png

As we can see, the above output comes when we go to the load balancer's IP.

The task is Successfully completed!

Thanks for reading.