Created an Ansible Playbook which will dynamically load the variable file named same as OSname and just by using the variable names we can Configure our target node.

Ishika Mandloi
3 min readFeb 1, 2021

In this task we have created a playbook that will automatically configure our target Nodes with the help of variable file that are named same as the os name in ansible facts.

Firstly, update the ip of systems in inventory.

check if hosts are active, by pinging them

#ansible -m ping all

To see ansible facts for that host we have command:

#ansible all -m setup

you can see ansible_distribution note the name and version of os as we have to make yml file with “osname-version.yml” .

These are the variable files for Ubuntu-20.yml and RedHat-8.yml

Now this will be our final playbook to configure RedHat and Ubuntu OS with httpd webserver.

we have to mention the yml files in vars_files.

This is content in mywebpage.html that will be shown on website.

Running t14.yml….

Checking for the webpage using ip of the OS …

success!!!!!

Thank you!!!

Keep learning✌✌😊

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response