LOADBALANCER-HAPROXY USING ANSIBLE!!!!!

Venkateshsandupatla
3 min readDec 24, 2020

Task Details:

  • Use Ansible Playbook to configure reverse proxy and update its configuration file automatically each time a new managed node joins the inventory.

Ansible

Ansible is an agent-less software platform that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs. It can configure both Unix-like systems as well as Microsoft Windows.

Ansible portrays a wide range of features that can enhance current processes, migrate applications for better optimization, and provide a single language for DevOps practices across the organization.

haproxy

HAProxy, which stands for High Availability Proxy, is a popular open source software TCP/HTTP Load Balancer and proxying solution which can be run on Linux, Solaris, and FreeBSD. Its most common use is to improve the performance and reliability of a server environment by distributing the workload across multiple servers (e.g. web, application, database). It is used in many high-profile environments, including GitHub, Imgur, Instagram, and Twitter.

PRE-REQUISITES

  • Ansible controller node
  • Two vms for webservers

Let's jump into the practical!!!!!

  • Inventory file
  • Now we have to write the playbook for setting up the webserver!
  • Let's run this playbook and make them as webservers.
ansible-playbook playbook.yml
  • Webpage — Index.html
  • Now let's make our controller node as load balancer for this we are using local host in the playbook and we have to configure haproxy .
  • Let's see the playbook.
  • For retrieving the webserver IPs automatically, we have to use for loop (jinja format) in haproxy.cfg file and we have to copy it to the /etc/haproxy
  • Now, let's run the playbook.
  • Now we have to check whether our load balancer is configured properly to not.
  • We have to give load balancer IP in google to connect to our webservers.
  • We have to refresh multiple times the page so that we can see different IPs with this we can conclude that we reach two web servers with the help of load balancer.
http://loadbalancerip:8080/webpageaname(index.html)

GitHub Repo:

Thanks for reading the blog!

--

--