ARTH — Task 15 👨🏻‍💻

Mihir Patel
4 min readFeb 15, 2021


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.

Role for Configuring HTTPD

Role: In Ansible, the role is the primary mechanism for breaking a playbook into multiple files. This simplifies writing complex playbooks, and it makes them easier to reuse.

in this article my managed node is :

Creating the role in Controller node and setup Path in Inventory File :

Here i create the my_http_role under the roles folder :

Setup roles Path :

🔹Creating an ansible role my_http_role:

# ansible-galaxy role init my_http_role

🔹For see how many role in your pc :

# ansible-galaxy role list

🔹For configuring server using my_http_role:

🔹Put Task in Main.yml file :

🌟Now run main yml file http_role.yml :

🔹Let’s check our webpage from the browser :

Successfully Run ….

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 ….



Mihir Patel