Task 15

Mdkneema
3 min readMar 28, 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.

Setting up the roles path in ansible.cfg file and creating role by name ‘myapache’.

The configuration file for ansible will look like —

Create an ansible role myapache to configure Httpd WebServer.

Now, Converting webserver playbook webserver.yml playbook into the role. The main.yml file in myapache role will consist —

The variables will be present in myroles/myapache/vars/main.yml will have —

The configuration file is present in the myroles/myapache/templates folder by the name web.conf —

Create another ansible role myloadbalancer to configure HAProxy LB.

The role is created by the command ansible-galaxy init myloadbalancer inside /root/myroles folder.

The main.yml file inside the tasks will contain the following code —

The varaibles are present in the /myloadbalancer/vars/main.yml file and it will look like —

The configuration file will be present inside the /myloadbalancer/templates/haproxy.cfg and it contains —

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.

To use both the roles together, we can create any yml file that can be anywhere inside the os as the roles_path is already set in the ansible.cfg file.

The yml file will look like —

The final execution of the code will look like —

Here, the error comes because the firewall is already disabled in the managed nodes —

--

--