Use Ansible playbook to Configure Reverse Proxy i.e. Haproxy and update it’s configuration file

What is Ansible?

Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs.

Every business is a digital business today. Technology is the innovation engine, and delivering your applications faster helps win. Historically, that required a lot of manual effort and complicated coordination. But today, there is Ansible — the simple, yet powerful IT automation engine that thousands of companies are using to drive complexity out of their environments and accelerate DevOps initiatives.

What is LoadBalancer?

Load balancing refers to efficiently distributing incoming network traffic across a group of backend servers, also known as a server farm or server pool.

A load balancer acts as the “traffic cop” sitting in front of your servers and 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. If a single server goes down, the load balancer redirects traffic to the remaining online servers. When a new server is added to the server group, the load balancer automatically starts to send requests to it.

In this manner, 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

What is 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. HAProxy acts as a Proxy server, as well as a LoadBalancer.

Now we have to install Ansible software in control node.

For this please visit below blog

After installation create inventory file as

Now run command #ansible all — list-host It will show list of IPs of all target node

Now to check connectivity with target node use command #ansible all -m ping

Connectivity to all the Managed Node looks good.

Now we have to create configuration file for haproxy as haproxy.cfg.j2. In that file we have to made some changes so that if we add extra ip of server in inventory file then load balancer can get this ip automatically.

Final Playbook :

For playbook visit this link

Output :

Our Playbook is running successfully.

Any Suggestion Is Valuable Fell Free To Ask.😊

Thanks for reading, I’ll meet you in the next one! 🎯




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

‍SQL Data To Excel Automatically Updated: Your Step-By-Step Tutorial

The Only Guide You Need To Get Started In iOS Development (2017)

How to Crop an Image to a Face (Square or Circle Shape) with Java

Identifying a minimum collection of baskets that covers the universe of products using PySpark

Deploy A Flask REST API to Azure App Service using Docker

Generate a UPC-E Barcode as a PNG File using Java

100 Days of No Code

The Adapter Pattern

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mangesh Prakash Jadhav

Mangesh Prakash Jadhav

More from Medium

All about Static Libraries in C

CS373 Spring 2022: Antoney Ejimadu

CS373 Spring 2022: Sahran Hashim

Analyzing a .Net Sample: ziraat_limpi.exe