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.

Ashish Mangal
3 min readMar 27, 2021

In this article I would like to show the demo how should we configure a web server along with load balancer inside the managed node using ansible playbook.

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.

To perform the above practical we need minimum two systems one is webserver that contain the actual website and one is load balancer which balance the heavy traffic coming on the website. We achieve it using ansible playbook.

Procedure for performing this practical is-:

  1. Check that ansible is properly installed and write the IP’s of managed nodes inside the inventory file along with other credentials.

2. Create a workspace and write a website code either in html or in php or in some other frontend languages.

3. Create a jinja template of HAProxy.cfg file which automatically do the necessary changes like its port number and other information.

4. Now create a ansible playbook to configure webserver and load balancer-:

5. RUN the playbook using the command-:

ansible-playbook {filename}.yml

In this way we configure the load balancer and webserver and check the result in the browser by writing the IP/{name}.

Thank you 😊😊

--

--

Ashish Mangal
0 Followers

My name is Ashish Mangal. Currently I am pursuing B.tech in Electronics and Communication. A Technology Enthusiast!!!