Ansible PlayBook to Configure HTTPD and HAProxy Using Ansible Roles

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

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:

--

--

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