Create an Ansible Playbook which will dynamically help us to configure OS of different distributions.

Create an Ansible Playbook which will dynamically load the variable file named same as OS_name and just by using the variable names we can Configure our target node.( Note: No need to use when keyword here. )
So for doing so first we would launch two OS on AWS cloud such that one is RedHat and the other is ubuntu. So that we could configure them for running web server separately.

Now we would update our inventory file with the IP addresses of the OS launched on the AWS server.

Now we would create two different variable files in the YML format and keep the file name the same as the OS i.e. RedHat and Ubuntu so that they would have the package name used in them for deploying web server over the Internet.

Now we would import the variable file in the YML file by writing {{ ansible distribution }} which would eventually be replaced by the exact same name of the Linux OS. And it would then replace the package name as httpd in the case of RedHat and apache2 in the case of Ubuntu.

Now we would run our playbook and check if any error comes up.

We could clearly see that there are no errors and our code was successful.
Now we can open our in our chrome browser and see that our web page is displayed according to the Linux OS.


Thank you, everyone.
Feel free to contact me in case of any doubts @ https://www.linkedin.com/in/shivansh-srivastava-77a3a31a5/