What is Ansible?

Ansible is an open source DevOps tool which can help the business in configuration management, deployment, provisioning, etc. It is straightforward to deploy; it leverages SSH to communicate between servers. It uses the playbook to describe automation jobs, and playbook uses a very simple language YAML.

Ansible provides reliability, consistency, and scalability to your IT infrastructure. You can automate configurations of databases, storage, networks, firewalls using Ansible. It makes sure that all the necessary packages and all other software are consistent on the server to run the application. Let’s take an example; you’ve got a debug version of an application that is built on visual C++. Now if you want to run that application on a computer, you would need to meet some prerequisites like Microsoft Visual C++ library DLLs, and you would need visual C++ installed in your computer. So, this is the part where Ansible will make sure that all these basic packages and all the software’s are installed in your computer so that your application can run smoothly on all the environments, may it be test or production environment. It also holds all the historical data of your application, so if at any time you want to roll back to the previous version, or you want to upgrade it, you can easily do that. Let’s take a look at some of the following features. Agentless – Which means there is no kind of software or any agent managing the node like other solution such as puppet and chef. Python – Built on top of python, which is fast and one of the robust programming languages in today’s world. SSH – Very simple passwordless network authentication protocol which is secure. So, your responsibility is to copy this key to the client Push architecture –  Push the necessary configurations to them, clients. All you have to do is, write down those configurations (playbook) and push them all at once to the nodes. You see how powerful it can be to push the changes to thousands of servers in minutes. Setup –  a minimal requirement and configuration needed to get it to work.

Ansible Architecture

Let us start with Public/Private Cloud which is the Linux server. It can also act as a repository for all IT installation and configurations. The above architecture has a bunch of host machines to which ansible server connects and pushes the playbooks through SSH. It has ansible automation engine using which users can directly run a playbook which gets deployed on the hosts. There are multiple components in the ansible automation engine. The first is a host inventory. It’s a list of all the IP addresses of all the hosts. Next, there are modules. Ansible comes with hundreds of inbuilt modules and modules are those pieces of code that get executed when you run a playbook. A playbook contains plays, a play contains different tasks, and a task includes modules. When you run a playbook, it’s the modules that get executed on your hosts, and these modules contain action in them. So, when you run a playbook, those action takes place on your host machines. You can make your custom modules also. All you must do is write a few lines of code and make it your module, and you can run it anytime you want. Then the architecture has playbooks. Playbooks here actually define your workflow because whatever tasks that you write in a playbook, it gets executed in the same order that you have written them. For example, if you have written that install a package first and then start, it’ll do the same. Playbooks are very simple to write YAML code. YAML code is a very simple data serialization language; it’s pretty much like English. Next, in the architecture are plugins. Plugins here are special kind of modules. These plugins get executed before a module is getting executed on the nodes. Plugins get executed on the main control machine for logging purposes. You’ve got call-back plugins because this enables you to hook into different ansible events for display and logging purposes. Cache plugins are used to keep a cache of facts to avoid costly fact-gathering operations. Ansible also has action plugins, which are front-end modules, and they can execute tasks on the controller machine before calling the modules themselves. The architecture has connection plugins. It is not always needed to use an SSH for connecting with your host machines; you can also use a connection plug-in. For example, ansible provides you with a docker container connection plugin and using that connection plug-in, you can easily connect to all your Docker containers and start configuring right away. That was all about the architecture. Next, let me tell you how exactly it works.

How Ansible Works?

Ansible works by connecting to nodes and pushing out small programs called as ansible modules. Ansible then executes these modules over SSH by default and then remove them when finished. Ansible management node is the controlling node, which controls the entire execution of the Playbook. It’s the node from which you are running the installation, and the inventory file provides the list of the host where the modules need to be run. The management node makes ssh connection, and then it executes the modules on the host machines and installs the product. It removes the modules once they are installed. So that’s how ansible works. Next, you may be interested in learning how to Install and configure Ansible.

Conclusion I hope now you have an idea about Ansible to get it started. Ansible is a game changer in how you manage the infrastructure and if you are Sysadmin or Developer, then can check out this hands-on training to advance the skills.

Ansible for Beginners   Ansible Basics and How it Works - 72Ansible for Beginners   Ansible Basics and How it Works - 62Ansible for Beginners   Ansible Basics and How it Works - 32