Ansible Architecture

Ansible Architecture: Before moving further, let’s learn some important terms used in ansible:

TermsExplanation
Ansible serverIt is a system or machine in which ansible is installed, from where the playbooks and tasks will be executed.
ModulesSet of commands which are executed on the client-side.
TaskA task is a part which contains a single method or procedure that is required to be completed.
RoleA way of managing tasks and relevant files, which are later required in the playbook.
InventoryThe data of the ansible client-server is stored in this file.
FactThe information is taken from the client-server using global variables with the help of the “gather facts” operation.
playIt refers to the execution of the playbook.
HandlerThese are regular tasks in an ansible-playbook, which are called at the time of execution if the notifier is present.
NotifierIt calls a handler if the output is changed.
TagIt is a fixed name for a task that is used to continue a specific task.

Whenever a user or client execute a playbook, the Ansible orchestration engine comes into play. The engine interacts with the user providing him/her services like an online database such as a public/private cloud. In the diagram given below, you can see how a user is interacting with the engine, which in the end, gets connected to the host.

Ansible Architecture

Can you identify what inventory, APIs, modules and plugins are doing in the Ansible orchestration engine? They have particular tasks which they perform whenever there is the execution of a playbook.

Inventory: It contains all types of data, whether it is the IP addresses, databases and servers in the form of lists of hosts managed by inventories. It's the first thing that will be encountered when you approach the engine because you can’t move further without knowing what your actual requirement is.

APIs: It transports the public or private cloud services. APIs can also be used for controlling nodes. Using it, you can write plugins and external data sources connected to inventory data using API.

Module: As we have already mentioned that ansible sends small programs or modules after establishing a connection with nodes or hosts, and after their execution, they are removed. There is no need for a database or server as the module can stay on any machine. To keep surveillance on the changed content, you can select a text editor or version control, or a terminal. Also, you can execute the module using the command line, for example:

ansible webservers -m servers -a “name=httpd state=started”

ansible webservers -m ping

ansible webservers -m command -a “/sbin/reboot/ -t now”

NOTE: Each module returns JSON format data. It gives them the freedom to write these modules in any programming language.

Ansible Architecture

Here you can see we have executed the ping module on localhost.

Plugins: It is a block of a program that uses the core functionality of ansible. Plugins provide impressive quality, flexibility and different features to use it. They are quite easy, and we can write our own.

Playbooks: These are the codes you write in YAML format and explain the next task to be performed and executed in your machine's ansible software. They also record the deployment, configuration, and other important functions. To build a full infrastructure, you must have three main things: raw material, tools, and manual instructions; similarly, in an ansible workshop, modules behave as tools, hosts inventories are the raw materials, and playbooks are manual instructions.

At the low level, these playbooks are used for configuration management and deployment. But on a large scale or at an advanced level, they can allot work to other hosts, deliver sequential updates, as well as interact with multiple monitoring servers. There are multiple ways of managing playbooks as they are human-readable and easy understandable texts.

Hosts: Ansible automates some node systems, which are called hosts. It can be automated by other machines such as RedHat, Linux, windows, mac, etc. In these systems, files can be stored in any format depends on the plugins and environment provided in your system.

Networking: Ansible automates different networks for getting access to the main services such as IT operations and other development-related operations. It follows a data model, which is quite different from an Ansible automation engine as it can be easily spread on different hardware.  

Cloud: It is a remote server where you can manage, store, and process your data using networking.  The data is not stored on the local server, whereas it is stored on the internet remotely. The Ansible cloud has no limits as it keeps on adapting and updating according to new IT needs. It is capable of managing and deploying your infrastructure, with other features like:

  • Controlling of servers
  • Networking and cloud-routing
  • VPN
  • Different policies

CMDB: It is a kind of repository which behaves as a warehouse for software installation. It can store any playbook, modules, or any other function.