Implementing HaProxy LoadBalancer on Local System

  • “ansible.cfg” — Configuration File which ansible will use, when we run the playbook. According to precedence of ansible.cfg files, current location of the ansible.cfg file will be taken. We can verify by the following command:
  • “haproxy.cfg” — Configuration file in which we have to configure our Haproxy Server. In this file, I have made 2 changes, one change is in the port number of our Load Balancer which is called “Frontend main Port”, so the Complete IP will be:
    http://<IP_of_Load_Balancer>:<Port_number_specified>
    The other change is that, We have to add the servers i.e IP/hostnames of the HTTPD servers, so to add them, there are 2 ways: One is that we can add the required fields manually, but we will choose the other way which is the automated way of adding these. In ansible, jinja format, and we will add a for loop to add the Server’s IP/Hostnames. which is as follows:
  • “inventory.txt” — This file consists of groups of Hostnames/IP’s, which is as follows:
  • “playbook.yml” — This file is our main file, which consists of our script/code written in YAML Language. In this file, I have used 2 plays, and each play has almost 3 tasks within it, which are:

--

--

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