Proxy and update it’s configuration
file automatically on each time new Managed node join the inventory on local machine
This blog will explain you how to setup reverse proxy and to configure it automatically every time you attach new managed node.
Below are the machines I have launched according to above picture -
* Namenode -
rhel8_arth — 192.168/29.202 — machine on which ansible script will run.
rhel-exp-2–192.168.29.225 — machine on which haproxy will configure.
rhel-cli — 192.168.29.201 — machine-1 on which web server-1 will run.
rhel-cl-2–192.168.29.24 — machine-2 on which web server-2 will run.
Now go to your namenode(rhel8_arth) machine and configure its inventory file by as -
Make a directory and put your yml file and cfg(configuration file of haproxy)
both file in that directory.
Below is the script …
Do the changes in haproxy.cfg.j2 file as show below.
I have used jinja code so that it can dynamically update it self to configure haproxy.
Bind keyword as shown in below rectangle shows that haproxy runs on 8081 port number.
second rectangle is use to update ip address of the instances where web server runs.
After all above configuration run the script
As the script runs successfully, now go to instance where you run haproxy server and web servers and check their status by the command —
systemctl status haproxy
systemctl status httpd
Now go to browser and check whether haproxy server is running or not