Ansible

Linu Bajy
2 min readMar 13, 2022

--

Hello everyone,

Let me introduce to Ansible. Ansible is a configuration management tool. Okay, too many big words! Now, why do we really need ansible? And how did it come to picture?

There can be multiple servers that needs to be managed .Moreover, each server comes with certain configurations, meaning different packages to be installed or different scripts to be executed based on it OS version or its OS type, different commands etc.

Imagine that you have a script that we want to run in 20 servers. There are two ways to solve this, one it to manually go into each of the servers and run the script. But this is obviously time consuming . Another scenario is that if all the servers have different OS version, the package manager to install the packages would be different. So now, we have to customize this based on the OS.

Ansible solves both the problems, and more :)

Ansible has the concept of gathering facts about the OS versions based on built-in modules that can help us identify the OS . It can also execute the scripts in all the servers with a single command. It can store information about servers in host file . Ansible stores the sensitive data by encrypting it. These are some of the many benefits that Ansible provides.

An important concept of Ansible is a PUSH based configuration tools. It means :

  • The receiving server nodes need not have any agents installed. It just pushes these changes (Scripts)to the server. The receiving node must have python installed , but no other agents.
  • Communication is initiated from Master to the slave node.
  • It doesn’t provide the advantage of pull based configuration. In pull based configuration, communication is initiated from client .The slave node checks for changes in the master node, at regular intervals. If there is any mismatch , slave node executes the steps that has been configured in the master node.

Ansible scripts are written using YAML (Yet Another Markup Language as its commonly abbreviated ) Configuration language. Every YAML script starts with 3 hyphens , which indicate the start of a new YAML document . Indentation is very important part of the format in the script. It can be one or more white spaces.

Example of a YAML script

---
host: localhost
become: yes
tasks:
-name: Print a line
debug:
msg: "This is a simple task to display a line"

Cheers!

--

--

Linu Bajy
Linu Bajy

Written by Linu Bajy

Enthusiastic Learner . DevOps Professional .

No responses yet