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.

Prerequisite :

  • Ansible installed.
  • Inventory configured.

Step-1)Retreive the distro.

  • First, we need to retrieve the distribution from ansible facts after use it.
  • After we retrieve the distro, now we need to make the files respective to the distro, like — RedHat-8.yml, Ubuntu-16.yml, etc.

Step-2)Writing Playbook

  • First, we need to make the playbook for the distro.
  • Here we need to give a package according to the distro.
  • After that, we use this var at the time of installing the webserver from a playbook.
  • Now include the ansible facts with the yml file, it automatically detects the file name with the distro name from the ansible facts.

Step-3)Run the Playbook.

  • After this, run the playbook
ansible-playbook FILENAME.yml


  • Now type the IP.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store