To Configure Reverse Proxy i.e. Haproxy and update it’s configuration file automatically on each time new Managed node join the inventory .
To configure Reverse Proxy and it’s configuration file
We first need to update the configuration file ,ie haproxy.cfg with Jinja .
Here I used ‘for loop’ in Jinja language for printing Groups (webserver) Value(Ip’s present in that group)
I created the architecture in the type like in future it would automatically update it’s configuration file on each time new Managed node join the inventory.
Before copying the haproxy.cfg file to the managed node
After copying the haproxy.cfg file to the managed node
Inventory File
After Working on the configuration file in the side of controller node ,I created a playbook which would automatically launch a webserver with a Load Balancer or Reverse proxy configured and also start the services .
In haproxy.yml playbook
First Creating a play for webserver groups
STEP 1
Creating a host ,ie webserver groups.
STEP 2
Installing Httpd package with the help of package module .
STEP 3
Creating a simple html file in document root of managed node using the module copy.
STEP 4
Starting the Httpd Web Services using the module service.
STEP 5
Creating a Firewall rule for port no 80 with the protocol tcp using the module firewall.
Secondly creating a play for haproxy groups.
STEP 1
Creating a host ,ie haproxy groups.
STEP 2
Installing haproxy package with the help of package module .
STEP 3
Copying the configuration file that we updated onto the controller node using the module template .
STEP 4
Starting the Haproxy service using the module service.
STEP 5
Creating a Firewall rule for port no 8080 with the protocol tcp using the module firewall.
Now running haproxy.yml playbook
ansible-playbook haproxy.yml