Create an Ansible Roles for Webserver and Haproxy…

🔅Create an ansible role myapache to configure Httpd WebServer.

🔅Create another ansible role myloadbalancer to configure HAProxy LB.

🔅We need to combine both of these roles controlling webserver versions and solving challenge for host ip’s addition dynamically over each Managed Node in HAProxy.cfg file.

♦Inventory File :

[webserver]
192.168.1.108 ansible_user=root ansible_ssh_pass=password ansible_connection=ssh
192.168.1.106 ansible_user=root ansible_ssh_pass=password ansible_connection=ssh
[loadbalancer]
192.168.1.107 ansible_user=root ansible_ssh_pass=password ansible_connection=ssh

♦️ Ansible Configuration File :

🔅 Create an ansible role “httpd” to configure httpd WebServer.

ansible-galaxy role init httpd

Create another ansible role “haproxy” to configure HAProxy LB.

ansible-galaxy role init haproxy

♦️ Here, we can see two roles created using command :

ansible-galaxy role list --roles-path /root/roles

Now start writing roles :

♦️ In httpd role,

  1. In tasks ;

2. In vars ;

3. In handlers ;

4. In files ;

♦️ In haproxy role,

  1. In tasks ;

2. In vars ;

3. In handlers ;

4. In templates ;

♦️ Now run the playbook ,

♦️ In Haproxy Configuration File we can see that ip’s are added dynamically over managed nodes ;

♦️ Now we have to check on browser :

If we can see while we relod our web page then ip get automatically changed then our task is successful. Let’s check

Here we go our ip changed dynamically …….

--

--

--

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

Recommended from Medium

Building a digital version of my Cypriot recipe book (part 2)

https://m.ascendex.com/en-us/register?inviteCode=UMI1TSBR9

Scrolla — jQuery Plugin for Reveal Animations

Scrolla — jQuery Plugin for Reveal Animations

The case for declaring (seemingly) pointless variables

const a = b && c;

Advanced TypeScript: How to Use Interface Inheritance With Discriminated Unions

10 — Things You Need To Know About React.

Material Design Icons: Font vs SVG. And How to Use SVG Sprites in Angular?

Null and Undefined in Javascript

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
Arya Dhorajiya

Arya Dhorajiya

More from Medium

Streamline with Pipelines: A Tutorial

Configure HTTPS SSL certificate on your AWS instance for Free

Configuring the Webserver and Setting up Python environment on the Docker

Create a Pink Aesthetic Filter In Spark AR | Best Steps