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.

Ritesh Singh
2 min readJan 4, 2021

--

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

Output

  • Now type the IP.

--

--