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?
A 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:
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
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
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.
main.yml file of the role instance
#ec2 #ansible #haproxy #load-balancing #aws