Ansible PlayBook to Configure HTTPD and HAProxy Using Ansible Roles

In this article we will:

  1. We will create an ansible role httpd to configure Httpd WebServer.

2. We will create another ansible role haproxy to configure HAProxy LoadBalancer.

3. We will combine both of these roles controlling web server versions and solving challenges for host IP’s addition dynamically over each Managed Node in HAProxy.cfg file.

Role for Configuring HTTPD

  • Create a Role
  • Task File
  • Var File
  • Handler File
  • Index.j2 file

Role for Configuring HAProxy

  • Create a Role
  • Task File
  • Var File
  • Handler File
  • HAProxy Configuration file

PlayBook For HTTP and HAProxy

Inventory File

Ansible Configuration File

Finally, Our WebServer and LoadBalancer have been configured.

We can see that IPs are dynamically added in the HAProxy Configuration File.

We can verify our setup is working:




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

Recommended from Medium

Lighting Round: Raven x Bolt Global

[Golang] How I learned Go!!

Building a Maven Plugin to explore your code-base

Why story points should never be used as a measure for success

Recognizing Handwritten Digits

How to access Spotify without 3rd Party VPNs

Build docker image using spring boot buildImage + gradle

Agile Fundamental / Scrum Knowledge

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
Karan Agrawal

Karan Agrawal

More from Medium

Setup Gitlab Backup into S3 Bucket

GitLab Container/Docker Registry

How to ssh into GCP using Windows Terminal

Create a group on Windows-like systems — Ansible module win_group