Configuring Loadbalancer HaProxy On AWS EC2 Instance Using Ansible

Problem Statement

What is Ansible?

What is HaProxy LoadBalancer?

What is EC2 in AWS?


  • Ansible installed
  • python3 with boto, botocore and boto3 libraries installed(To do anything related to AWS one must install the above-mentioned libraries)
yum install python3 
python3 -V
pip3 install ansible

1. Provisioning EC2 instance

ansible-playbook key_gen.yml
load balancer
for webserver

2. Dynamic Inventory In Ansible

3.Creating roles

ansible-galaxy init <rolename>


HaProxy.cfg file

Every time you refresh you will get different IP and the load on a web server is distributed with Load Balancer

Thanks for reading...



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