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. )

Jayesh Kumar
2 min readMar 25, 2021

--

We have launched two instance using AWS one is Redhat and one is Ubuntu .

Then we have to update our inventory file with the IP of the two instances so there is a connectivity between the instance and our VM

This is the inventory file updated .

Now we have assigned a variables , which will display the name of the Linux distribution on the webserver we launch.

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.

Here is our ansible Playbook

now we execute our playbook

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.

--

--

Jayesh Kumar
Jayesh Kumar

Written by Jayesh Kumar

Btech ECE pursuing student ....Arth Learner

No responses yet