HAPROXY USING ANSIBLE PLAYBOOK

darshil shah
2 min readApr 28, 2021

TASK 12.1:

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.

Ansible :-

Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows.

Haproxy:-

HAProxy is free, open source software that provides a high availability load balancer and proxy server for TCP and HTTP-based applications that spreads requests across multiple servers. It is written in C and has a reputation for being fast and efficient

I have created an playbook to configure the haproxy server and update the ip dynamically in configuration file of haproxy on the run time so each time we update the webserver file it automatically detects while running haproxy playbook and update it’s configuration file dynamically !

Github-URL :-

https://github.com/sdarshil/ANSIBLE_HAPROXY

firstly we will install the package haproxy and then we will use template to copy the haproxy.cfg configuration file so that we can run some ansible facts and fetch the ip of webservers while we run the playbook dynamically !

then at last we will start the haproxy service and boom !

we got haproxy server ready with dynamically updated config file !

as shown we have used ansible inventory file to dynamically update the webserver details from webserver ips and with port number 80 configured !

--

--

darshil shah

Integration is key , and thats what i love to do !