Ansible playbook to Configure Reverse Proxy i.e. Haproxy and update it's configuration file automatically👨💻
Task Description 📃
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 (Configured With Apache Webserver) join the inventory.
WHAT IS HAProxy?
HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications.
Advantages of using HAProxy
Over the years it has become the de-facto standard opensource load balancer, is now shipped with most mainstream Linux distributions, and is often deployed by default in cloud platforms.
What is Ansible?
Ansible is an open source community project sponsored by Red Hat, it's the simplest way to automate IT.
Advantages of Ansible
ANSIBLE PLAYBOOK
Configuration file for ansible
Inventory file
How Ansible works?
LET'S Start the task
2. System for Webserver 1
3. System for Webserver 2
4. After knowing the ip addresses of the systems whom we have to configure as load balancer and web servers add these ip's in the inventory file.
5. Before running the ansible playbook in the System Load Balancer.
6. Before running the ansible playbook in "Webserver 1" and "Webserver 2".
7. Ansible playbook in the controller node.
8. Configuration file for the haproxy server.
With the last 3 lines of code it will automatically update the configuration file each time new Managed node (Configured With Apache Webserver) join the inventory.
9. After running the ansible playbook, httpd services are running in both the webservers.
10. After running the ansible playbook ,HAProxy is installed and services are running in the "Load Balancer".
11. Output of the ansible playbook.
12. We will check the configuration file of the HAProxy in the system configured as Load Balancer.
We can see that the ip address of the webservers have been added.
13. Let's connect to the ip of the load balancer and it will redirect us to the webservers.
Thank you .