{"id":20179111,"url":"https://github.com/pratikshinde55/ansible-loadbalancer-webserver-configuration","last_synced_at":"2026-06-05T18:31:13.144Z","repository":{"id":226607126,"uuid":"769166165","full_name":"Pratikshinde55/Ansible-loadBalancer-webserver-configuration","owner":"Pratikshinde55","description":"Ansible-playbook for Configure HAProxy Load Balancer and register Backend Httpd to Load Balancer where put Webpage and this Webpage access by using Load Balancer IP \u0026 port no.","archived":false,"fork":false,"pushed_at":"2025-02-14T10:42:08.000Z","size":79,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T05:41:51.603Z","etag":null,"topics":["ansible","ansible-playbook","automation","aws-ec2","haproxy-loadbalancer","jinja2-template","round-robin-algorithm"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pratikshinde55.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-08T13:33:28.000Z","updated_at":"2025-02-14T10:42:12.000Z","dependencies_parsed_at":"2024-12-23T13:33:22.937Z","dependency_job_id":"8f16cf73-01b2-47c4-8b01-1d52bd718405","html_url":"https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration","commit_stats":null,"previous_names":["pratikshinde55/ansible-loadbalancer-webserver-configuration"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Pratikshinde55/Ansible-loadBalancer-webserver-configuration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-loadBalancer-webserver-configuration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-loadBalancer-webserver-configuration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-loadBalancer-webserver-configuration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-loadBalancer-webserver-configuration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pratikshinde55","download_url":"https://codeload.github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pratikshinde55%2FAnsible-loadBalancer-webserver-configuration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27282333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-26T02:00:06.075Z","response_time":193,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-playbook","automation","aws-ec2","haproxy-loadbalancer","jinja2-template","round-robin-algorithm"],"created_at":"2024-11-14T02:25:11.374Z","updated_at":"2025-11-27T18:05:01.433Z","avatar_url":"https://github.com/Pratikshinde55.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Configuration of Load balancer \u0026 webserver using Ansible Automation\n![image](https://github.com/user-attachments/assets/f27fa663-6563-470f-bd12-b331e1f2d12a)\n\n- Refer:\n  Manual way or using Ad hoc command Configuration of Load balancer \u0026 webserver using Ansible Automation in given link:\n  [Load-Balancer-manual](https://github.com/Pratikshinde55/Load-Balancer.git) \n\n## Using Ansible Automation (playbook):\n\nFor this Configuration i take four instances, Amazon linux EC2 instances.\n\nOne for  Ansible-Master node :   54.197.11.139\n\nTwo Instances for webserver (Backend): Public IP  backend 1- 54.159.221.239,Backend  2- 44.202.88.227\n\nOne for Load Balancer (Frontend):lb: 18.206.228.124\n\n![Screenshot 2024-03-08 185237](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/3a8443c8-80f3-403d-bc7b-4d5b411f6f56)\n\nIn ansible master node created 2 playbooks **One for Loadbalancer** and **One for Webserver** \u0026 **One jinja template file** and one webpage.\n\n![Screenshot 2024-03-08 191538](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/8762d476-644d-497e-b0e4-5b2c24c2b34f)\n\n### Step-1: [In master node 1st create Webpage(index.php): This webpage index.php is deploy to webserver which can client access from browser]\n     \n     cat \u003e index.php\n\n![Screenshot 2024-03-08 191718](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/7e46d046-7a9b-4ad0-8a46-f329681c06b5)\n\n### Step-2: [Create Inventory, In Inventory made two groups \"Web\" group for webserver nodes \u0026 \"lb\" group for LoadBalancer node]\n     \n     vim /etc/ansible/hosts\n\n![Screenshot 2024-03-08 192439](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/c7222013-3942-48d7-abf2-80024384fa12)\n\nWe can check ansible list of hosts using following Command:\n\n![Screenshot 2024-03-08 192031](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/c4e3522a-b1ff-432d-bf88-e30377fff6a0)\n\n### Step-3: [Now Create Webserver(Backend) playbook and here hosts for webserver playbook is \"web\" group, in web group two instances are kept]\n\nIn this ansible-playbook:\n1. Task install Httpd package,\n2. Task is Install php package which is because my Webpage in the form of '.php',\n3. Task is Deploy Webpage index.php to destination **\"/var/www/html/\"**,\n4. Task for start httpd service.\n     \n       vim webserver.yml\n\n![Screenshot 2024-03-08 191743](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/307945c7-0c30-4c0b-bcee-e35ed336d058)\n\n### Step-4: [Run Webserver.yml playbook - this playbook do Configuration in Web group where Two nodes]\n     \n     ansible-playbook webserver.yml\n\n![Screenshot 2024-03-08 192223](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/40949559-4c32-4cd7-abc9-a4f8e64168d7)\n\n### Step-5: [Load Balancer need Registration of backend nodes]\n\nNow for this, create jinja file \"pratik.cfg.j2\" which pass registration information to LoadBalancer playbook \"lb\":\n      \n      vim pratik.cfg.j2\n\n![Screenshot 2024-03-08 191830](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/ea5a34da-3cc3-470d-95fb-8cc861e69ba1)\n\n- Note:\n\n*here we use **Round Robin** Algorithm that work as Client will connect to Web Server through Load balancer, 1st connect to Web 1 then Web 2 and next Web 3 then \nagain go to 1. here also bind the port number as **8080**.*\n\n### Step-6: [Create Load balancer Playbook]\n\nCreate Load balancer Playbook \"lb.yml\", add lb group where only one instance for lb IP:-18.206.228.124\n\nIn this playbook:-\n1. task for install haproxy package It is loadBalancer that i used,\n2. task for rigistration of backend webservre to Load balncer for this pratik.cfg.j2 jinja template used , In haproxy Load balancer configuration file for load \nbalancer is kept in \"/etc/haproxy/haproxy.cfg\"\n3. task for Start haproxy service\n\n        vim lb.yml\n\n![Screenshot 2024-03-08 191851](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/bd60bfcf-8a66-49ae-aa38-3478aa5398a4)\n\n- Note:\n\n**HAproxy is one of the product of load balancer, HAproxy is a high-performance, open source load balancer \u0026 reverse proxy for HTTP and TCP.**\n\n### Step-7: [Run Load balancer]\n\nRun Load balancer \"lb.yml\" playbook , This do load balncer configuration on lb group:\n\n    ansible-playbook lb.yml\n\n![Screenshot 2024-03-08 192329](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/006b2f23-342c-49b9-a1b2-adc0f95d6685)\n\n\n## Configuration of Load balancer \u0026 WebServer done successfully:\n\nCheck on Google or Browser Publich IP load balancer : port no. that bind:\n\nExample:- http://18.206.228.124:8080\n\n![Screenshot 2024-03-08 193442](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/823b6f21-2453-4580-9369-ef92c9e1ed26)\n\n- Note:\n\nLoad balancer node Inbound rules -\u003e\u003e All trafic , Anywhere ( remove Firewall )\n\n![Screenshot 2024-03-08 185340](https://github.com/Pratikshinde55/Ansible-loadBalancer-webserver-configuration/assets/145910708/16ee3cf8-f783-4ea8-8dd4-f019dce74bb8)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpratikshinde55%2Fansible-loadbalancer-webserver-configuration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpratikshinde55%2Fansible-loadbalancer-webserver-configuration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpratikshinde55%2Fansible-loadbalancer-webserver-configuration/lists"}