This article is one step ahead of my previous article. Here we will learn how to configure a load balancer on AWS using Ansible.

First, let’s understand what is a load balancer?

load balancer does the work of routing client requests across all servers capable of fulfilling those requests in a manner that maximizes speed and capacity utilization and ensures that no one server is overworked, which could degrade performance.

A load balancer performs the following functions:

  • Distributes client requests or network load efficiently across multiple servers
  • Ensures high availability and reliability by sending requests only to servers that are online
  • Provides the flexibility to add or subtract servers as demand dictates

To begin with the setup we launch four instances on AWS named ‘_ansibleweb’ which serves as the webservers on the backend, and one instance named ‘load-balancer’ _which is configured as the front end load balancer. We have launched these instances using the Ansible playbook ‘instancelaunch.yml’.

This playbook is available for download on the given link

ishajain140/configuring-loadbalancer-on-AWS-using-Ansible

github.com

For a detailed explanation of launching instances on AWS using Ansible kindly refer to my article on Deploying Web Server on AWS through ANSIBLE.

The playbook ‘instancelaunch.yml’ is run through the command :

ansible-playbook --ask-vault-pass instancelaunch.yml 

Image for post

playbook: instancelaunch.yml

The vault holds the value of variables myaccess and _mysecret _which are used in the _tasks/main.yml _file of role instance. Once the playbook runs successfully 5 instances are launched on AWS as shown.

Image for post

main.yml file of the role instance

#ec2 #ansible #haproxy #load-balancing #aws

Configuring Loadbalancer on AWS using Ansible
1.35 GEEK