Provisioning HAProxy LoadBalancer and Webservers On AWS Using Ansible

Prajwal Patil
Oct 29, 2020

Statement: Deploy a Load Balancer and multiple Web Servers on AWS instances through ANSIBLE!

đź”…Provision EC2 instances through ansible.
đź”… Retrieve the IP Address of instances using the dynamic inventory concept.
đź”…Configure the web servers through the ansible role.
đź”…Configure the load balancer through the ansible role.
đź”…The target nodes of the load balancer should auto-update as per the status of web servers.

Note: For Better Understanding Do read my previous post on Ansible

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. It is written in and has a reputation for being fast and efficient (in terms of processor and memory usage). HAProxy is used by a number of high-profile websites including GoDaddy, GitHub, Bitbucket, Stack Overflow, Reddit, Slack, Speedtest.net, Tumblr, Twitter and Tuenti and is used in the OpsWorks product from Amazon Web Services.

Step1: Create Ansible Playbook for webservers and load balancer.

LB
WS

Step2: On Local system,edit HAProxy config file.

/etc/haproxy/haproxy.cfg

Step3: Save the Playbook and Execute it.

Command to execute Playbook:# ansible-playbook <YML-File>
  1. Playbook for Webserver:
webserver playbook

2. Playbook for Proxy server

HAProxy Node
Check the IP Address

So our playbook successfully run

Lets take a look at EC2 Dashboard of AWS

ec2 dashboard

Thanks You For Reading :)

--

--