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

  • 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.
  • Here you can see on my localhost web server httpd is not installed. so let's deploy the playbook.
  • So here you can see the playbook is successfully deployed.
  • Now here you can see the package httpd is successfully installed, the webpage is copied and the webserver service started.
  • and that’s the content….!!!

THAT’S ALL ….

THANKYOU….!!!

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to make a socket chat with Python

Python packaging and dependency management using poetry

A magical day in Disney with Machine Learning — Part 2 Using APIs to get weather conditions and…

Amazon DynamoDB introduction

Schedule an EC2 instance

What is an API? A simple, Non-Technical Explanation

Deploying a Docker Image to an AWS ECS Cluster Using Terraform

Flogo Apps running as Azure Functions

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
Aaditya Tiwari

Aaditya Tiwari

More from Medium

CodingQuestions_1: Get Maximum Subarray Sum

Tayarra Hub: Rating sheet database

CS371p Spring 2022: Santi Dasari

HYSS (Highest Yield Savings Service )