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.

Rishabh
3 min readJan 13, 2021

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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Rishabh
Rishabh

Written by Rishabh

Student from B.tech 2nd Year, A proud ARTH learner, love new technologies, Curious about many thing, likes to explore places, love eating pizza and much more.

No responses yet

Write a response