top of page
Search

Configure Haproxy using ansible ....


Welcome back to my new blog🤗


In this blog, I am going to show you how to Configure Reverse Proxy i.e. Haproxy and update it's configuration file automatically each time a new Managed node (Configured With Apache Webserver) is added to the inventory, with the help of ansible playbook.


What is haproxy?

ree

HAProxy is free, open source software that provides a high availability load balancer and proxy server for TCP and HTTP -based applications that spread requests across multiple servers.




ree

Haproxy accepts a request from a client, forwards it to a server that can fulfill it, and returns the server's response to the client. A load balancer distributes incoming client requests among a group of servers, in each case returning the response from the selected server to the appropriate client




So now let's jump to the practical part:-


Here is my inventory file which contains two IP's one for the webserver(backend user) and another one for the load balancer(front-end user).

ree

Now I am going to ping the system to check the connectivity.

command :- ansible all -m ping  
ree

Here ping pong msg shows that we are successfully connected ...


Playbook:-

ree

Haproxy.cfg.j2 file, with the help of this file haproxy.cfg file will dynamically update when the new webserver is added.


ree

Implementation:-

ree

Let's see Target nodes configured or not

  1. webserver:-

ree

Here you can see that my files are copied successfully and also check that this system IP is (192.168.43.251).


2. Loadbalancer:-

ree

Here our haproxy file is configured successfully.

ree

IP of load balancer (192.168.43.53) and also in HTML dir, I don't have any web file.

Now I am going to check that the service is running or not properly

ree

Here you can see that the IP which I am using is load balancer IP and data is from the webserver system. and as you can see our load balancer IP is fetching data from the webserver IP this shows that our configuration is successfully done.


Thank you so much for visiting my article 🙌🏻🙌🏻



 
 
 

Comments


Post: Blog2_Post
  • Facebook
  • LinkedIn

©2020 by My Site. Proudly created with Wix.com

bottom of page