Sitemap

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. ( Note: No need to use when keyword here.)

2 min readDec 15, 2020
Press enter or click to view image in full size
  • Here you can see I have created one workspace which contains four files :
  • RedHat-8.yml: This file contains package name httpd for Redhat os with document root.
  • Ubuntu-18.yml: This file contains package name apache2 for ubuntu os with document root.
  • homepage.html: This file contains the webpage content.
  • code.yml: This file contains the ansible-playbook code which helps me to dynamically load the variable file named same as OS_name and just by using the variable names. for which I have used the var files as ansible facts where I have written distribution minus with distribution major version. so if we configure the webserver on the top of RedHat and Ubuntu, if the system feels they are running on the top of Redhat, it uses RedHat-8.yml while for ubuntu, it uses Ubuntu-18.yml.
Press enter or click to view image in full size
  • Here you can see on my localhost web server httpd is not installed. so let's deploy the playbook.
Press enter or click to view image in full size
  • So here you can see the playbook is successfully deployed.
Press enter or click to view image in full size
  • Now here you can see the package httpd is successfully installed, the webpage is copied and the webserver service started.
Press enter or click to view image in full size
  • and that’s the content….!!!

THAT’S ALL ….

THANKYOU….!!!