12.1 Use Ansible playbook to Configure Reverse Proxy i.e. Haproxy and update it’s configuration file automatically on each time new Managed node join the inventory.

What is Load Balancer?
According to Google: A load balancer is a device that acts as a reverse proxy and distributes network or application traffic across a number of servers. Load balancers are used to increase capacity (concurrent users) and reliability of applications.
Pre-requirements:
>> haproxy.cfg file in the system
>> Index.php file in the system
>> Ansible controller node with Ansible installed
>>sshpass insatalled
>>Updated Inventory
Lets Get Right into the task
STEP 1: Adding Haproxy.cfg file as to be used further in Template Module.
>> Vim haproxy.cfg
>> we using the port 8080 for our laodbalancer

>>Writing loop in jinja to gather all the IP’s Automatically from the inventory

STEP 2: Adding and writing an Ansible playbook
>> Vim task12_manual.yml
>>Here loadbal is for the node we going to configure as Haproxy
>> Installing package
>> Using haprpoxy.cfg file as a template
>> Starting haproxy service
>> Stopping firewall for our load balancer

>>Here websw is the name pf node we going to configure as webserver
>> Changing Selinux permissions
>>Installing httpd in webserver
>>Installing php
>>Using index.php as a template(has to be present)

>>Starting httpd service

STEP 4:Running Ansible-playbook
>> ansible-playbook task12_manual.yml



STEP 5: Testing our Loadbalancer
>> As we have created two webservers as a backend and in front end we have a Load balancer having ip 192.168.0.187 working on Port 8080
>> As you can see we have got Different Ip each time after resfresh This means all our setup is working fine.

