Configure HAProxy With Dynamic Inventory using Ansible on AWS

mayank agrawal
3 min readAug 28, 2020

--

This is my new task where i have to configure haproxy load balancer on top of amazon cloud. For this we have to register our backend and our backend is nothing its just an our website. Scenario is like we have to do this with ansible and as soon as our load increase we launch another webserver but dynamically so we have to use dynamic inventory here.

So let’s get started .

This is my workspace

Here is my conf file

  1. First I create 3 instances one for load balancer and two where are website is running.

After launching of instances we configure load balancer on lb_os and web server on web instance.

This is my haproxy tasks file

Now i have to configure the web server.

This is my setup file that runs my role

Now from above figure you can see we balance the load successfully.

Thank you

#keepcoding #keepshaing #makinindiafutureready #devops #ansible #aws

-

--

--

mayank agrawal

I am devops enthusiast always trying to learn new technologies and try to implement in real world to solve real use cases. Creative integrator