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