Ansible Playbook📃 which will Dynamically load Variable file named same as OS_Name

Hello Everyone!!🖐

In this Blog I am going to create a Ansible Playbook which will Dynamically load Variable file named same as OS_Name.

🔰For Create Same Playbook you need to follow the steps that are given below:-

STEP 1:-

Create a Folder of any Name in my case folder name is “webserver”

Creating Folder

STEP 2:-

Create file of any name in webserver folder

Creating file

STEP 3:-

Create ansible host file from any location:-

Creating ansible host file

STEP 4:-

Configure your ansible configuration file that is /etc/ansible.cfg

Configuration file of Ansible

💥NOTE:- Give Location of your Ansible host file :-

STEP 5:-

Content in /etc/ansible/hosts file

Content in /etc/ansible/hosts file

STEP 6:-

Content in file os.yml

Content file in os.yml

STEP 7:-

Create two more in folder webserver

Creating RedHat.yml file
Creating Ubuntu.yml

💥NOTE :- Both the name of file are same those i given above

STEP 8:-

Content of file RedHat.yml

Content in file RedHat.yml

STEP 9:-

Content in file Ubuntu.yml

Content in file Ubuntu.yml

STEP 10:-

Use Redhat and Ubuntu OS

This is my Redhat OS that is running in my local VM

Redhat VM

This is my Ubuntu OS that is running on AWS Cloud

STEP 11:-

Run the ansible playbook(os.yml) by using command “ansible-playbook os.yml”

Playbook Run

STEP 12:-

Use Ubuntu Instance Public IP in browser

Webserver Configure successfully

This shows Webserver in Ubuntu OS is Ready!!✅

STEP 13:-

Use RedHat vm IP in browser

Webserver Configure Successfully!!

This shows Webserver in RedHat vm is Ready!!✅

If you liked the above blog, please share it.

DM me on LinkedIn in case of suggestions/feedback/queries:

❗LinkedIN Profile Link:-





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

Recommended from Medium

Day 27/100 Completing Udemy Course!

Jenkins_input and Jenkins_timeout

Cloud Formation — Helper Scripts

Django Rest Framework — Part1

Connect 4: From CLI to Rails App

How To Learn and Grow as A Self-Taught Developer — Jeff Atwood’s Advice

Vector 2 Mod Apk 1.2.1 Unlimited Everything 2022

Integrating Ansible and Docker for a CI/CD Pipeline Using Jenkins

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
Buddhiprakash Jain

Buddhiprakash Jain

More from Medium

Requirement — The requirement is to create a RDS instance in AWS VPC Private Subnet, We need to…

File Organization 101

Significance of Digital Security

CS371p Spring 2022: Daniel Cai