Create another ansible role myloadbalancer to configure HAProxy LB.


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

In this article we create two Role for Haproxy and Webserver configure .

🌟Controller Node🌟 in this controller node we will config our Loadbalancer.

🌟Managed Node🌟 this managed node is our backed webserver .

👉 Creating an ansible role haproxy_role and webserver_role:

# ansible-galaxy role init haproxy_role
# ansible-galaxy role init

👉For see how many role in your machine :

# ansible-galaxy role list

Configure Role path in Inventory :

My Roles in Role folder so role_path=/root/roles

👉For configuring Load Balancer using haproxy_role role:

update the man.yml file in haproxy_role .

In haproxy.cfg use jinja code like below .

👉For configuring webserver using webserver_role role:

upadte the main.yml file in webserver_role .

👉create the main haproxy_role.yml File :

# ansible-playbook haproxy_role.yml

Now run this haproxy_role.yml file :

👉Now see the Backedwebserver Status ( :

systemctl status httpd

Now go to the Chrome and see webpage :

👉Here LB ip was ( :

Thank for reading ….



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