Configuration of Apache webservers along with dynamic configuration of HAProxy using Ansible

Vinay Jadhav
3 min readDec 28, 2020

--

Hello Readers,

This article is to explain how to 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.

Before starting, make sure that HAproxy is installed in controller node. This is required because we need to replace the HAproxy configuration file from target nodes with our custom HAproxy configuration file which would be in jinja2 language.

Step1: Copy the HAproxy file of controller node to other directory

Here, I have made a directory called task12_1 where I have copied the HAproxy configuration file

Step 2: Make the necessary changes in the configuration file and save it with .j2 extension

Step 3: Create a inventory file

Step 4: Create html or php file to deploy

Step 5: Create ansible playbook

Get entire code at my GitHub repository:

https://github.com/Vinayjd99/arth-tasks/tree/main/Arth_task12.1

Step 6: Run the ansible playbook

Step 7: Check whether you can access the webpage or not through browser

Step 8: update the inventory file

Step 9: Again, run the same ansible playbook

Step 10: Now, again check whether you can access the webpage or not through browser

The HAproxy server will sent the requests to its webserver according to the roundrobin algorithm

Thank you for reading..

--

--

No responses yet