HTTP Authentication using Ansible.
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
Now we will check our inventory file for ensuring IPs of our Managed Node.
For checking the proper network connectivity of our Managed node, we have used this command.
ansible all -m ping
Now we create a separate directory for this named as ws1. In this we made our playbook named auth.yml
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 :-
- authname "LW"
- authtype basic
- authuserfile /etc/www.passwd
- 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:-
ansible-playbook playbook_name.yml
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
put your Username and password here, and click on Sign In button.
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 !!
Informative article Tanisha Jain 👍
Brilliantly done✨ Tanisha Jain
Tanisha Jain nice article buddy