Webserver using Ansible

This tutorial is all about the installing of the Ansible in your RHEL 8 and setting up the Apache HTTPD webserver using the Ansible automation.


Ansible is an open-source configuration management tool. One can perform the automation using the Ansible. In this article, we will set up an Apache HTTPD web server on Redhat Enterprise Linux 8. 

Apache HTTPD

Apache HTTPD is a software provided by Apache. This software will let anyone set up the web server that is to host their information on the web and access them through the URL.

Setting up the Webserver

We can install Ansible on one system, where that system is known as the controller node and can run the Ansible playbooks to install and configure the other systems known as a managed node.

To install Ansible on the controller node, we need to install Python3 on the Redhat system.

After installing the Python3, you can install Ansible on the system using the pip3.

Now, create a file to store the list of IP addresses of the different managed nodes.

Then store the list of IP addresses of the managed nodes and the password. Here in this case the IP address of the managed node along with the password is mentioned.

Later to connect to the other system using SSH, you need to install the ssh pass program on your controller node. 

Now, ensure to put the location of the inventory file that contains the list of all the IP address of the managed nodes in the Ansible configuration file.


Now, configure the file with the path of the inventory


Now, it is the time to develop the automation script and run it using the Ansible on the managed nodes to set up the Apache webserver. Let us create a file with an extension of yml.


Develop the code by using the YAML language where the code looks like key-value pair and Ansible works on this YAML language.

To download the code file from the ” GitHub Repository


The meaning of the above code signifies as:

The following tasks are to be executed:

  1. The package is the module that contains the httpd software and it has to be installed.
  2. Service is another module to start the httpd service
  3. Copy module will help to copy my HTML file from the controller node to the managed node and the file contains the information that has to be hosted on my webserver.
  4. Firewall module will disable the firewall and open the 8080 port and can reach it using the HTTP protocol.

Later you need to save the file and run the file using the Ansible to configure the webserver on the managed node.


The following actions will be shown on your command prompt and finally completes the configuration of the webserver on the controller node.

This is the end of this tutorial of setting up the Apache webserver using the Ansible. For any sort of doubts or the errors during the execution, you can reach out through the comment box. 


Later you can check the webserver with the help of IP address and can reach the server by typing the IP as URL in the web browser.

Spread knowledge

Leave a Comment

Your email address will not be published.