SciDatajourney

What is Ansible and how it works. The Ansible Architecture – Detailed Explanation

Hello everyone welcome back to this session. So today in this session we are going to discuss the Ansible architecture right? So in our previous session, we saw how Ansible works, and what are the key components in Ansible.

Now we’ll go ahead and discover the other components that are there in Ansible and how these different components, work together to make configuration management a success when you’re using Ansible.

All right, so without wasting any time, let’s go ahead and start with the session. All right, so guys, this is the main overview of What is Ansible how Ansible works.

OK, so let’s go to every component, one by 1 one.

The Ansible architecture of how Ansible works

So basically in The Ansible architecture, you have something called an administrator who will write an Ansible playbook which will be nothing but what do I want to accomplish on the remote systems that I will be specifying in this code file?

OK, so once I’ve specified everything in the code file, the next step would be to put this code file on the Ansible master.

OK, so I’ll put everything or I will put this playbook on the ansible master, right? And the ansible master in turn has something called inventories and it has something called modules.

What is Ansible and how it works. The Ansible Architecture – Detailed Explanation

What are inventories?

Inventories are code files that will have the host’s IP addresses. What do I mean by that? All the slaves that exist on the Ansible cluster are called Ansible hosts, right?

Now How would the master know, know which host do I connect to that? That information is gathered from the inventories, right?

So in the inventories, basically you can Group A certain number of slaves and call them something. You can name each slave as a name as well, right?

For example, this system could be this particular system could be host one, this particular system could be host two, and this could be host 3. Or.

What I can do is I can put all of these servers in a group called host, or I can call it production, or I can call it testing right? So nomenclature, grouping everything happens in the inventories

What is the purpose of naming?

The purpose is that when I’m writing playbooks, I don’t have to worry about which IP address is my host on or which IP address should this command be executed on, right?

All I mentioned in the playbook is on what servers, what group of servers, or what name of servers I have to execute these commands on basically those names are resolved from the inventories that exist on the answerable master, and then your request is executed.

OK, so this is what inventories do guys. All the IP addresses that you have or all the remote systems that are connected to the answerable master, their information is stored in the inventories. The next step is modules.

Now what are modules?

Modules are nothing but pre-built functions in Ansible. What do I mean by pre-built? If there is anything that you have to do using Ansible, you should first check whether you have a module on that or not.

If you have a module on that particular task, it is better to call that module directly in the playbook than to write the logic in the playbook again, right?

So modules, in other terms it’s nothing but functions. It’s similar to functions that we have in programming languages, but in the case of modules, they are pre-built.

They come pre-installed with Ansible and you just have to know the modules to use them in your playbook. OK, you can directly call them in your playbook.

So these are what modules are.

Hosts

Then our next is these hosts. So these hosts are nothing but slaves and for the ansible master to connect to these hosts, it uses the SSH connection.

So what you have to do is your master should be able to SSH into your host without any password and without putting any key and we’ll see how we can accomplish it.

But, if that SSH connection is being formed, then your ansible master can also communicate with all the hosts that are present on the cluster all right.

So there are only two conditions the first condition I mentioned is that the SSH should be enabled and the second thing is that Python itself should be installed on all the hosts that want to connect to the answerable master right?

If these two conditions are fulfilled, your answerable master can successfully connect to all the hosts that are there on the cluster.

The summary of what we have discussed

OK, now to summarize what we just discussed, the first thing that you have is something called a playbook which is nothing but a small short code file which is written in YAML language and is basically.

They are the instructions as to what has to be done on the remote system, right?

Our next component is the Ansible master which has something called inventories and modules. Inventories are nothing but a list of IP addresses or the grouping of IP addresses into a particular name of servers.

Or it could be the individual name of servers as well that you want to define. All of that can be defined inside an inventory right?

The next thing that you have is something called modules, which are pre-built functions that you can directly call in your playbooks to execute certain tasks, right?

Those are modules and when you’re using modules, basically the good part about them or the best part about them is that you don’t have to declare them or define them.

You can directly call them in the ansible playbook. OK, the next thing is we have something called the hosts.

So hosts can be connected through SSH and Python if Python is installed on those hosts and if the ansible master can connect to all these hosts using SSH without any password and any key.

In that case, your Ansible master can successfully connect to these hosts irrespective of the fact whether you have paid attention to the installation or not.

There is nothing else that you have to configure. Ensure that Python is installed and you can do SSH and your ansible cluster will work like a charm.

All right. So, guys, this is what we were supposed to discuss. That is the Ansible architecture.

Conclusion

I think now you have gotten the right information on this topic which called “What is Ansible and how it works

In summary, the Ansible architecture offers an unmatched level of flexibility and ease of use for controlling IT infrastructure, making it a solid basis for automation.

Ansible is still a major force in automation as technology develops, enabling businesses to attain operational excellence. The Ansible architecture provides modules for seamless integration with various cloud platforms, enhancing its versatility.