top of page

Task Automation using ANSIBLE - Simple Demo

Ansible is an open-source automation tool that allows you to automate the provisioning, configuration, and management of computer systems. It is designed to be simple, efficient, and easy to use. Ansible uses a declarative language to describe the desired state of systems, and it automatically takes care of the necessary steps to bring the systems into that desired state.


Ansible consists of several key components that work together to automate infrastructure management. Here are the main components of Ansible:

  1. Control/Management Node

  2. Inventory

  3. Playbook

  4. Modules

  5. Tasks

  6. handlers

  7. Variables

  8. Roles

You can read in detail about these components from the below mentioned Ansible documentation.


Use Case:

In this demo, we will install Ansible in one management/controller node. From there we will copy scripts into different Linux, AIX, and Windows servers. Execution of these scripts will generate a text file with information like system info, CPU info, memory info, disk usage, and network info of all the servers. A report text file will be generated for all the executions. Then we will copy all these files from different servers to the controller node. And in the end, delete these reports from all the servers to free up the disk space.


Code Repo:


Inventory File: inventory_master.txt

Ansible Playbook File: ansible_demo_playbook.yml


We have created different Ansible tasks for each operation. And imported these tasks into the playbook to use in the order we want.


Task 1: task_ping.yml

Ping different linux, aix and windows servers from the controller or management node to check the connectivity before starting with other steps


Task 2: task_copy_objects.yml

Copy the scripts from controller node on to different linux, aix and windows servers, to be executed later


Task 3: task_execute_script.yml

Execute scripts thet were copied by task 2 on different linux, aix and windows servers. This execution is initiated from the controller/management node.


Task 4: task_retrieve_reports.yml

From execution of scripts mentioned in Task3, a text file report will be generated on different servers. Copy these files from these servers on to the controller/management node.


Task 5: task_eliminate_objects.yml

In the end, delete all the reports generated on different servers to free up the disk space.


Command to execute the Ansible playbook:

ansible-playbook -i inventory_master.txt ansible_demo_playbook.yml

53 views1 comment

1 Comment


Rudra Prakash Pal
Rudra Prakash Pal
Jun 15, 2023

Explained well

Like
bottom of page