HTTP Authentication using Ansible.

HTTP Authentication using Ansible.

No alt text provided for this image

This article is based on the HTTP Authentication. If we access some webpages(for eg: Facebook, LinkedIn, etc) it asks us for authenticity like our username and password for further access. I represent my Controller Node with Black color and Managed Node with Blue color for better understanding. Here we make our webpage secure using ansible, so that only authentic person can access it. firstly check the ansible version using command.

ansible --version
No alt text provided for this image

Now we will check our inventory file for ensuring IPs of our Managed Node.

No alt text provided for this image

For checking the proper network connectivity of our Managed node, we have used this command.

ansible all -m ping
No alt text provided for this image

Now we create a separate directory for this named as ws1. In this we made our playbook named auth.yml

No alt text provided for this image

For this we go to the /etc/httpd/conf file. In this we go to the httpd.conf file. In the Document root /var/www/html , we change the AllowOverride None to AllowOverride AuthConfig. We can change it manually as well as through ansible playbook , here we prefer to go with ansible-playbook.

Here also we have another concept of 'htpasswd' , in this we can made any file and make a Database of authentic users and can store in this file.

Inside /var/www/html folder we made ".htaccess" file and mention all the necessary information like :-

  1. authname "LW"
  2. authtype basic
  3. authuserfile /etc/www.passwd
  4. require valid-user

Using playbook we restarted the httpd services in the managed node.

Also by using ansible-playbook we are going to create a small webpage named index.html. Now the playbook code for all these things is write here:-

No alt text provided for this image
ansible-playbook playbook_name.yml
No alt text provided for this image

here our playbook run successfully.

Now we are going to stop and then disable our firewalld. Then stop the SELinux by "setenforce 0" in Managed Node.

systemctl stop firewalld
systemctl disable firewalld
setenforce 0

Now we open up the IP address with page name like , then a login column will pop-up in the window for check your authenticity. If you are an authorized person, only then it will allow you to access the webpage.

http://192.168.43.23/index.html
No alt text provided for this image

put your Username and password here, and click on Sign In button.

No alt text provided for this image
No alt text provided for this image

This is the Small webpage I've created, that you will see after login.

Hope you will like this Article !! please give your valuable feedback about it. Looking forward to any correction.

Thank you All !!

To view or add a comment, sign in

More articles by Tanisha Jain

  • Configuring HTTPD server on Docker Container.

    In this article we are going to install and configure HTTPD server. Here we are using RHEL8 and top of it we installed…

    8 Comments
  • Network convivial

    Create a Setup so that you can ping google but not able to ping Facebook from same system. Today we are going to talk…

    4 Comments
  • Configure HADOOP and Start Cluster services using ANSIBLE.

    ANSIBLE : Ansible is an open-source software provisioning, configuration management and application-deployment tool…

    10 Comments
  • APACHE WEBSERVER CONFIGURATION IN DOCKER USING ANSIBLE:

    To do list :- Configure Docker Start and enable Docker services. Pull the httpd server image from the docker hub.

    6 Comments

Others also viewed

Explore content categories