Dynamic Configuration of Target nodes using variable files named same as OS using Ansible

Nirali Arora
3 min readMay 29, 2021

TASK DESCRIPTION

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.

For this task, we’ll be using two target nodes: one is RedHat Linux and another one is Ubuntu.

I have launched Ubuntu instance in AWS cloud and RedHat Linux is running in my local system.

Let’s start the task :)

Step 1: Launching OS

Ubuntu on aws cloud and linux in local.

Step 2: Configuring inventory file ip.txt

Step 3: Updating inventory file in ansible configuration file

# vi /etc/ansible/ansible.cfg

Step 4: Create the variable file: RedHat.yml

Step 5: Create another variable file: Ubuntu.yml

Step 6: Now create the playbook to configure the webserver: task14.yml

We ping to the hosts in order to check the connectivity between the controller node and target node.

Now run the playbook

Check both the webservers in browsers with respective ip addresses of the system.

THIS IS REDHAT LINUX OS

AND THIS IS COMING FROM UBUNTU OS

We have successfully completed the task.

Github URL for playbook and variable files: https://github.com/nirali1219/ARTH_task14.3

KEEP LEARNING!! KEEP SHARING!!

Thank You :)

--

--

Nirali Arora

ARTH Learner | AWS | Devops | Docker | Ansible | Kubernetes | MLOPS | Linux | Python | Python flask | AI | ML | DL | CV | MongoDB | Hadoop | GIT | GitHub