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. Configure this setup over AWS using instance over there.
Now Let’s start the Task :
1. Launch Three(minimum) instances :
One for Load Balancer
Two for webserver
2. Create Inventory file with any name :
In my case i created a file name with inventory.txt.
command : vim file_name.txt
3. Update the Inventory File :-
In Inventory file write IP of the load balancer and Web Server…
Here instead of giving the password we need to give the private key for that private key must be present in the system and then give the path..
4. Update the Configuration file of ansible :
Command : vi /etc/ansible/ansible.cfg
5. Check the connectivity with the node :
Command : ansible all -m ping
6. Code for configure HAProxy :
7. Code for configure Webserver:
8. Make HAProxy configuration file dynamic :
9. Now run the yml file One by One :
Command : ansible-playbook file_name.yml
10. Check Configuration file of HAProxy in managed node updated dynamically or not :
11. Check Connectivity in the browser :
Check the connectivity using load balancer IP that they successfully done proxy or not..
In mycase load balancer IP- 188.8.131.52(public IP of Instance)
If we are using our Local System then all step and procedure are same just we need to change the inventory file, i.e change the IP address with our local systems IP and username and password (don’t use private key that is only for cloud instances).
Task Completed !!
Thanks for reading !!!