:> 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.
⚜️I am writing this article to 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.
🔹We have three different RHEL8 Virtual Machines on the top of Oracle Virtual Box. These three VMs will work as the backend servers for the Load Balancer.
I will be configuring these backend servers as web-servers. And I am going to configure my localhost (Controller Node of Ansible) as an Haproxy server.
So, let’s begin
I have Configured Master Node as Controller node of Ansible, created ansible configuration file in the ansible workspace and specified my inventory path
🔹Inventory: A database containing the list of worker nodes or system upon which configuration has to be performed
🔹Check the connectivity to all the nodes using command
ansible all -m ping → this command goes to all the node and perform ping operation
let’s begin with configuring the target nodes as web servers:
Here, I have created a single playbook where I have created two different plays. One play is for configuring the target nodes as webservers and the second play is for configuring the localhost as the Haproxy server.
🔹playbook for configuring the target nodes as webservers:
🔹This playbook will :
- attach mount my RHEL8 dvd containing different software with the node
- 2.create BaseOS & AppStream Yum Repo
- Installs httpd package from the yum repo that we created
- copy the content inside root directory of apache-webserver (/var/www/html/)
- Start httpd services
🔹This playbook will :
- Installs the HAproxy package, used for load balancing purpose
- I have a pre-created configuration template in which I have used some of the Jinja2 programs in order to dynamically identify the IP of the backend servers, so this step will copy this template to the destination folder.
🔹Given is the image of the configuration file that i have copied to slave nodes using template module.
🔹Let’s run the playbook
🔹The load balancer has been configured successfully:
Thanks for Reading…..
Keep Growing…Keep Sharing..!!!!