Deploying Apache webservers, configuring & updating HAProxy dynamically using Ansible

👉 HAProxy, which stands for High Availability Proxy, is a popular open-source software TCP/HTTP Load Balancer and proxying solution which can be run on Linux, Solaris, and FreeBSD.

Git-HuB-link of this practical

👉 LoadBalancer

A load balancer is a device that acts as a reverse proxy and distributes network or application traffic across a number of servers. Load balancers are used to increase capacity (concurrent users) and reliability of applications. So load balancer is work as proxy so we can protect our server by Proxy .

In load balancer we use proxy ip and our request come from backend server ips so we can access web page from server without knowing actual ip.

In this blog you will you how to make load balancer .

Here i use three Machine one loadbalancer (127.0.0.1) two webserver

(192.168.0.118)& .119

👉Now We Start make LoadBalancer by Ansible👈

👉 Create Inventory

In this practical Our control node will Loadbalncer so i use 127.0.0.1

Now make jinja code in haproxy.cfg file copy from /etc/haproxy/

Now Create the Ansible File for LoadBalncer and Webserver

Now run the playbook using the below command

ansible-playbook <<playbookname.yml>>

Output:

Now See haproxy.cfg Config or not

So you can see in the above screenshot, the haproxy.cfg file is updated

Now Put ip of LoadBalncer (192.168.0.113) in chrome So you can access web page from server

So you can See our web page from .118 server ip .

Thank you

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store