Skip to main content

What is Ansible? Where it is used and what are Inventories and Playbooks?

 In this article we are going to talk about ansible. Ansible is one of the most popular tool and especially very popular in the community of DevOps. Today i am going to demystify what ansible is, what is the problem that it's trying to solve and will give you the most easiest understandable explanation of what ansible is, what problem it solves and where you can use it.  Before we understand what ansible is we need to understand what is the problem that ansible is trying to solve, so we are going to take that now and also let me mention one more thing that ansible is more popular not in the software developer or software engineer community but moreover in the production engineer community. There are different sets of challenges that are handled by the production engineer people who takes your software or your web application and move it on to the production environment the virtual machine  like AWS, Google cloud or whatever your favorite cloud provider is and there are different set of challenges that are handled by these production engineer, ansible is one of the most favorite tool for all these production engineer

 

 

So ansible is a tool that helps you to either move things into production or the things which are already in the production there are some config management or there are some updation that needs to be made in the production it just helps you to automate that task. So I will be explaining in the plain very simplistic possible language, so let me first introduce you to the scenario of why ansible is necessary. In general it’s not about just one machine which is handling your database, your front end, your backend and everything. Usually we prefer to deploy multiple machines so that either load can be balanced in the production or maybe some other reasons as well maybe you want to have a separate mail server say separate database server so it is very clear that you are not going to be putting everything in just one virtual machine or one instance there would be many.

ansible

That is all clear to us but let's just say there is something that you want to change in all the machine maybe there is an version update in the operating system from Ubuntu 18 to Ubuntu 18.5 or 8 or 19 the version is now changing and you want to make that version change or probably there is some updated feature that you have launched in your application and your application is running in three different computers to have a load balancing what you're going to do at that time you probably will use an approach which in which you are going to have a system and you're going to go ahead and use  SSH or any other ways to connect those system you are going to login into each system every single time and will perform that update surely possible a lot of people does that and still this is one of the general  way by a lot of people but this is not a feasible approach when you are scaling up quite a lot you have fleets of servers and probably you are having 100 different machines that is not even possible and even if you are doing it this is going to take a whole lot of your time

and by the time there is also a possibility that not all of your users are getting all that updated features.

 

 

Welcome to ansible to solve this problem, ansible helps us to actually put up a config file and then ansible will automatically be connected to all different machines and will release those updates whether that's operating system patching maybe an operating system upgrade, maybe a configuration update, maybe you want to run an update on just the database whatever you want to do ansible comes in between and it does that now before we talk and explore a little bit more on ansible.

  Now, if you are really interested in  what ansible is you need to understand these three things:-

1.Inventory:- consider this scenario

ansible scenario


where I am putting up two of them in the blue and one of them in orange you can consider this orange one as a database probably MySql or probably a mail server the top two ones are the web server probably to load balance or probably to have a back end and front end however you want to understand that that's totally okay then there is something known as playbook I will come back on to that as well
 and then in between stands the ansible so this is the scenario that we have right now now let's go back and let me explain you what all these things are the first thing that we talked about is inventory, now inventory is one of the key component of how ansible works.

 

Ansible allows us to have a separation as well as a segregation of the servers for example 

inventory


in this iamge there is a
  mail server and there are two of the web servers that are running now obviously just for an example these are web servers So probably they will be running, both of them will be running Apache or probably Nginx and then there are Database servers probably all three of them might be running  things like Mongodb or probably MySql, so imagine the scenario where you want to run and update in just the MySql you obviously don't want to touch other these things you just want to touch these servers and that is exactly the reason why ansible allows us to have inventory means categorization and put your servers into a certain category these are very helpful in later on phases and this is a simple example up here.

inventory example


 Now all what ansible uses are Yaml files and Yaml is one of the most easiest way of writing the code its moreover a serialization and this is an
actual code of how you categorize your servers and how you basically make an inventory

coming back now you understand that how the inventory is being done and how you can categorize your servers into web maybe mail servers maybe all of that that is the one major component of how ansible works moving a little bit more

 

 

 2.Playbook:- Now playbook is actually a set of instructions just like in the programming world we have loops and functions and all of that in the world of ansible we have a playbook this playbook is actually a set of instructions to perform that they run an operating system update or probably create 10 different users whatever you really want to do this is what you mentioned in the playbook so I hope you get the idea that this is the playbook now how does it work and how this all actually comes all together in the playbook you define all the things that you want to do probably you want to do an OS upgrade and that upgrade needs to be done in all of these three a virtual machine regardless of what categories they are being in possible and until or probably there is a kind of a further subset of instruction in which you want to do an Nginx update or Apache update and  this update needs to go into this and this virtual machine only that's where the inventory comes in you can have a categorization and you can just put an instruction in your playbook that hey i want all the machines to have an update in Ubuntu.

                                                                                                Now  what happens actually is sets of instructions goes from  Playbook  to Ansible and then ansibe performs all the operations like upgrading the Ubuntu version from 18 to 19 and probably after that you can set instructions to have an update in Apache and after we are done with it we want you to take that app and deploy it. All that is done with Ansible very easily

 


Comments

Popular posts from this blog

WHAT IS FULL-STACK DEVELOPER AND HOW TO BECOME A FULL-STACK DEVELOPER??

  Full stack web development is one of the  most popular developer occupations today  but there remain some confusion about  what a full stack web   developer is  and how different Front-end development from back-end web development  in this article we'll go through exactly  what a full stack web developer we'll also look at  how to become a full stack web developer. WHAT IS FRONT-END WEB- DEVELOPMENT Before we dive straight into   full stack web development we  first need to understand the two main  fields that   make up a full stack web  developers i.e front-end web  development and back-end web development.  Front-end web development involves the  actual presentation of your website, in  other words how the information on your  website is laid out both in browsers and  on mobile devices. Becoming   a Full-stack developer requires to have knowledge in HTML CSS and JAVASCRIPT....

What is Machine Learning and how to get started with Machine Learning?

“ COMPUTERS ARE ABLE TO SEE, HEAR AND LEARN. WELCOME TO THE FUTURE ” –   DAVE WATERS   In this article we will go through what is machine learning and what are the steps to learn machine learning So let's get started! Now the terms - Machine learning and AI artificial intelligence is closely related And it's not wrong to say that the abstraction level of between these two words is fairly thin line and they can be   used Interchangeably. Let's talk about machine learning and AI. Now machine learning and AI   are branches of computer science. They are closely related, but according to me, what my personal thought is machine learning is closely related to data mining rather than AI. AI is completely a different thing But what you think of machine learning is closely related to data mining And you have been already using it quite a lot. Now, you might be thinking where We are already using machine learning? Now although you have just heard the term machine le...

How to learn Python fast?

We all know that python is one of the best beginner-friendly programming language that can really help you kick-start your career as a programmer. So today i will go through how you can learn python as fast as possible. In this article we will be discussing 10 really good tips for how you can learn python fast and how you can grow as an effective programmer If this is your first programming language it can be a bit overwhelming at the start, so you might have an idea of where you want to start but you may lack a complete structure on how to actually achieve your goal. There are different ways to learn a language and everyone has their own method for achieving the same result.  1.Understand the why :   Why should you learn python and why python the right language for you to actually learn. So python can be used in lots of different   fields like Machine learning, Data science, Web development, Game development and lots of other things, so figuring out why you are actually...