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.

Nityachawda
2 min readApr 2, 2021

Whenever we run any playbook it first gathers facts about the target node.

we can also see that information by printing ansible_facts using debug module.

We will be using ansible_facts for this task.

This is our playbook.

Suppose we have multiple variable file such as RedHat.yml, Ubuntu.yml.

We don’t have to specify which file to use, it will automatically choose .

So , my target node is RedHat . so, it will choose RedHat.yml file.

Inside Redhat.yml file I have mentioned the package to be installed and the destination to copy files.

This package and destination will be used in our playbook as variable.

Let’s run our playbook.

Let’s see if target node is configured.

Like this we can configure many nodes .

Thank You!!!

--

--