To Configure Reverse Proxy i.e. Haproxy and update it’s configuration file automatically on each time new Managed node join the inventory .

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

haproxy.cfg file in controller node

After copying the haproxy.cfg file to the managed node

haproxy.cfg file in managed node

Inventory File

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

haproxy.yml playbook

First Creating a play for webserver groups

Play for webserver

STEP 1

Creating a host ,ie webserver groups.

Host

STEP 2

Installing Httpd package with the help of package module .

Installing httpd package

STEP 3

Creating a simple html file in document root of managed node using the module copy.

Copying the webpage

STEP 4

Starting the Httpd Web Services using the module service.

Starting httpd services

STEP 5

Creating a Firewall rule for port no 80 with the protocol tcp using the module firewall.

Creating a Firewall Rule

Secondly creating a play for haproxy groups.

Play for haproxy

STEP 1

Creating a host ,ie haproxy groups.

Host

STEP 2

Installing haproxy package with the help of package module .

Installing haproxy

STEP 3

Copying the configuration file that we updated onto the controller node using the module template .

Copying the file

STEP 4

Starting the Haproxy service using the module service.

Starting haproxy service

STEP 5

Creating a Firewall rule for port no 8080 with the protocol tcp using the module firewall.

Creating a Firewall Rule

Now running haproxy.yml playbook

ansible-playbook haproxy.yml

Running Playbook

Here my website is running with the Reverse proxy configured .

ThankYou .

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Rust on Windows 10 from scratch

OceanDAO Round 18 is Live

RackN And Digital Rebar Philosophy Of Provisioning

Is It Worth To Be A Software Engineer/Developer in 2020?

From Splunk 5.x to 7.0: Just what have you been missing out on?

CMDER PROBLEM WITH THE LEADING LAMBDA

The Assumptions Programmers Make

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Himanshi Kabra

Himanshi Kabra

More from Medium

Network Whitepaper | Part 1 Abstract & Introduction

Tangany Recap 2021

StoneFly Improves Storehouse Operation for Hosting Service Provider.

MeanFi. Future is here and now