Wednesday, September 21, 2022

Ansible Introduction

Ansible

Ansible refers to an open-source automation platform or tool that is useful for different IT tasks like configuration management, intra-service orchestration, application deployment, and provisioning. Automation is vital for managing complex IT environments and simplifying the complex tasks of the developers. Ansible is a top automation tool that helps in overcoming the challenges of automation and ensures better productivity gains.

It is simple, powerful and agentless. The biggest differentiator between Ansible and other tools lies in the architecture; it works on the “Push” model, i.e. no additional software is required to be installed in the server. By default it manages remote connections over SSH (Linux & Unix) or WinRM (windows).

Some of the top benefits of Ansible are:

Free – Ansible is an open-source tool that is available to the users for free.

Simple – Most users might worry about how Ansible works. But in reality, the setting up process, as well as the use, is very simple. The use of ansible software requires no exceptional skills in coding.

Efficient – Ansible is an efficient software. It requires no additional software for installation but offers room for the application resources on the server of the user.

Powerful – Ansible is a powerful tool that helps the users to model the highly complex workflows of the IT industry efficiently.

Agentless – The main benefit of using Ansible is that it is agentless. Without the use of any additional software, the clients can easily automate their systems.

Flexible – Irrespective of where the software is deployed, it allows the users to orchestrate the whole environment of the application.

Extensible – Depending on the networking and automation needs of the users, Ansible can easily offer extensions.





Simple Ansible Architecture



Is Ansible Free?

Yes, Ansible is an absolutely free and open source tool that is used for the above-mentioned purposes. Because Ansible adopts the standard GNU (General Public License), it can be used for commercial purposes as well as long as one respects the policies of GNU.


Why Ansible?

A single bash script would be great if you have to manage and configure a single system, you are the single user and yours is a single machine. But when you scale up across more number of computers, multiple tasks, more users and more admins, you will discover that the bash scripts are not enough and efficient. This exactly where Ansible comes into the picture. Ansible can be treated as nurtured bash or shell scripting that can configure your huge infrastructure topology in one go.

Plus, Ansible uses a very simple language called YAML (YAML Ain’t Markup Language) in the form of Ansible playbooks that allows you to describe your automation task in a way that is as good as colloquial language.


Ansible Components:

Master: This is the main machine that takes care of the configuration of machines with Ansible.
Inventory: An inventory is a file that describes the nodes that are accessible by Ansible. 
The nodes can be grouped in the inventory file and named accordingly
Playbook: YAML files that describe the automation tasks to be done by Ansible.

Simple Playbook:
---
hosts: localhost
- name: install python
  yum: name=python state=installed

Task: This is the block that describes the action to be taken by Ansible in statements. Ex: Install httpd.
Module: These are the executable plugins that do the task for us. There are many inbuilt modules which Ansible provides us. We can write our own custom-modules too.
Role: An Ansible playbook can get really huge in size over time and maintaining it would be really tough. Hence with roles, one can group the tasks into subsets and manage the content efficiently. These roles (groups of tasks) can be reused accordingly.
Play: Execution of a playbook is called a play.
Facts: These are the global variables that will be referred across Ansible playbooks.
Handlers: Used to invoke service status changes, like restarting or stopping a service or install or uninstall a package.

Following are the advantages mentioned below:

Ansible manages the machines in an agentless You do not have to install any Ansible agents/service software on the client machine.

Both push and pull of files/commands/codes are supported in Ansible.

Ansible is a security-focused tool. And it uses OpenSSH as the secure transport protocol.

Ansible scripts (popularly called as playbooks) are written in YAML and hence they are very easy to read.

Ansible is The core idea here is that you only do things if they are needed and things that are repeated without side effects.

If needed, then Ansible can easily connect with Kerberos, LDAP (Lightweight Directory Access Protocol) and other centralized authentication management systems.

An advantage of higher order significance is that one need not be an expert in bash or shell scripting.
 Ansible has it handled by itself. So, the working becomes quite easy and straight forward with Ansible.

One doesn’t really need to be a root user to run the Ansible playbook tasks on the nodes. It can acquire root privileges.

Adhoc Command:
Verify connectivity of host:  # ansible  <group> -m -ping
Rebooting host systems:  #ansible <group> -a “/sbin/reboot”
Creating a new user: # ansible <group> -m user -a “name=ansible password=<encrypted password>”
User Deletion: # ansible <group> -m user -a “name=ansible state=absent”
Permissions changing:  # ansible <group> -m file -a “dest=/home/ansible/file1.txt mode=777”
Verify package installation  with update: # ansible <group> -m yum -a “name=httpd state=latest”
Verify package installation without an update: # ansible <group> -m yum -a “name= httpd state=present”
Verify package version: # ansible <group> -m yum -a “name= httpd-1.8 state=present”
Verify package installation: # ansible <group> -m yum -a “name= httpd state=absent”
Display host information:  # ansible <group> -m setup | less

=========================================================================
Ansible Playbook:

Ansible Roles:

Ansible Galaxy:



How Ansible Works:



No comments:

Post a Comment

Sample Game App Deployment on EKS cluster

 https://padmakshi.medium.com/setting-up-an-eks-cluster-and-deploying-a-game-application-a-step-by-step-guide-08790e0be117