Ansible to configure haproxy(loadbalancer)

task description:

“🔅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.”

Roles:

Roles let you automatically load related vars_files, tasks, handlers, and other Ansible artifacts based on a known file structure. Once you group your content in roles, you can easily reuse them and share them with other users.

firstly you need to set the ips of loadbalaner and my web to work this job

check if you are connected to the loadbalacer and web

ansible all -m ping

we need to create the roles to function myloadbalancer and myapache

In this we need to create the seperate roles of myloadbalancer and my apache

ansible-galaxy role init myapache
ansible-galaxy role init myloadbalancer

here, we can see the role functions .

this tells the roles that are present in our system

ansible-galaxy role list

To configure loadbalancer using loadbalancer role

we should use this command and configure the file…

vim /roles/myloadbalancer/tasks/main.yml

To configure webserver using apache role

we need to use this command and configure this file…

vim /roles/myapache/tasks/main.yml

This is the haproxy.cfg file we need to configure in loadbalancer using jinja

This is the index.php file you need to configure in myapache

This is the yml file we need to combine the both myloadbalaner and myapache roles and configure the file

use this command and configure the file..

vim /ws/setup.yml

Run the file using playbook

ansible-playbook setup.yml

To test if the setup is work or not we use (mylb)ip:8081/index.php

At last we created the roles and combined the role and controlling the weberver version…

--

--

--

In a phase of learning;)

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

Recommended from Medium

Don’t learn a syntax, learn to change the way you think

How to Use Fancy Interface for Python Shell Interpretation

Configuring Auth0 with WSO2 API Manager for SSO

Open Source Summit 2017 — a week in Pragues

Common Practices I learned with 3 years of coding in JAVA

Call Stacks and Recursions

How to Get Your App Published to the Zoom App Marketplace on Your First Review!

Why and how to learn to read or write code as a Salesforce Admin?

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
Himavarsha Madala

Himavarsha Madala

In a phase of learning;)