What Is Ansible Uses, Benefits, Architecture

What Is Ansible? Uses, Benefits, Architecture

In this Ansible tutorial, I will give you a brief description of what Ansible is and why you should be using it. Ansible, or Ansible Tower, is a configuration management tool that makes it easy to deploy applications and services. Ansible was created in 2012 by Michael DeHaan who built a team around him in 2013. The project was crowdfunded on Kickstarter and is now being developed by Red Hat Ansible. Their goal is to create an easy-to-use, streamlined automation tool for system administrators, developers, and other IT professionals that reduces the time it takes to deploy applications and infrastructure. In this Ansible tutorial, I will discuss the given points:

  • What is Ansible?
  • How Does Ansible Work?
  • Ansible Features
  • Ansible Benefits: What Makes It So Popular?
  • Ansible Architecture
  • Ansible for DevOps

What is Ansible? 

Ansible is an efficient and easy-to-use IT automation tool and DevOps platform that drives your software and systems easy to deploy. It handles configuration management, application deployment, cloud provisioning, ad-hoc task execution, multi-node orchestration, and more including multi-tier containerized applications in ways that are natively scalable for any size of business. Free Trial

Ansible’s modules are written in Python and work over SSH. They support targeting a variety of popular platforms (including installed software packages on Red Hat Enterprise Linux and Debian) and devices like network equipment and Ceph storage clusters.

It provides a language to express the configuration of your systems instead of forcing you to use static files or manual processes. Ansible is beneficial for software deployment, restart services, plan jobs, and producing more cutting-edge IT tasks such as zero downtime rolling updates or continuous deployments.

Click Here to Read: What is Docker? The spark for the container revolution

How Does Ansible Work?

Ansible operates by linking to nodes and running tasks. The nodes are managed by an Ansible Controller, which is a software component that runs on a Unix (Linux, BSD, Mac OS X) or Windows machine. Tasks are written in YAML and can execute simple commands (such as service httpd restart), run scripts, execute shell commands and utilize Ansible modules.

Ansible uses a client-server architecture for communication. When Ansible is installed on a node, it registers itself with the Controller and periodically sends “heartbeats” to the Controller. The Controller keeps track of all of the nodes connected to it, storing their configuration in what is called the “Control Repository“. Ansible uses this repository to find out which nodes need to be managed and which tasks need to be performed against each node.

AAnsible utilizes a YAML file (called a “playbook”) that possesses the software configuration data for one or more than one system. You define your playbooks in YAML files, which means that the syntax should be easy to learn even for people who aren’t familiar with the Python programming language. And once the playbook is ready you can use it to deploy your code from either local machine or remote machines – it doesn’t matter. You only need SSH access, and the rest of the things will manage by Ansible.

Ansible Features

Ansible’s modular design allows you to:

  • Ansible works over SSH. Everything is encrypted, and all communication is authenticated.
  • Playbooks are simple YAML or JSON files that tell Ansible what to do.
  • Ansible uses a push model. We don’t need to install anything on your servers, so there are no clients to maintain.
  • Ansible is open source and written in Python, which makes it powerful and easy to extend. It’s also agentless, so you can work securely with any cloud, virtualization platform, container system, or bare metal infrastructure.
  • Manage nodes over SSH or natively on Windows and Linux
  • Deploy applications and systems
  • Perform ad hoc actions on any sets of nodes
  • Create reusable roles for complex, multi-node orchestration tasks
  • Extend Ansible with custom modules in any language or framework.
  • Ansible can deploy configurations across multiple operating systems, including AIX , Amazon Linux AMI, BSDs, CentOS, Debian GNU/Linux, Fedora, FreeBSD, Gentoo Linux, Microsoft Windows (using WinRM or native PowerShell Remoting), HPUX, Ubuntu and OpenSUSE.

Click Here to Read: What is Jenkins? | Jenkins For Continuous Integration

Ansible Benefits: What Makes It So Popular?

  • Easy to Understand: Ansible is easy to understand, quick to learn and written in a way that makes it easy for the user to get the most out of it.
  • Generic: Ansible is generic and can be operated across numerous platforms and software.
  • Distributed Execution: Ansible is distributed in execution and allows you to run commands across nodes without having to worry about your code.
  • Simple Inventory: Ansible uses a simple inventory process that makes it easier for DevOps professionals to manage multiple projects.
  • Extensible: Ansible is extensible using plug-ins, modules and roles for specific tools.
  • Reliable: Ansible provides a more reliable solution for distributed application management as compared to other solutions like Puppet or Chef.

Click Here to Read: What is DevOps? The Beginner’s Guide

Ansible Architecture

Ansible Architecture
Ansible Architecture

Ansible is the simplest and most powerful IT automation engine available today. Ansible architecture has a modular architecture, which means that it is composed of multiple components working together to perform tasks. We will look into Ansible’s architecture and see how all these components work together to deliver Ansible as a powerful tool with a simple configuration. Following are the components of ansible architecture:

Ansible Engine

Ansible Engine is the main component of Ansible. It is responsible for parsing and executing playbooks, handling variables and inventory sources, loading modules, and performing other essential tasks. This component accepts input YAML files (playbooks) and executes them according to the command line arguments provided by callers. The output of running playbooks can be viewed in both plain text format and HTML format.

Modules

Ansible modules are used to perform various tasks on remote systems such as copying files or managing services on those systems. Each module handles a specific task.

Ansible Controller 

It is responsible for controlling the managed nodes. The controller holds the inventory file which contains the details about all nodes in the environment which need to be managed. When there are changes made in the inventory file, then these changes are pushed to all the managed nodes by the controller node. Another important function of controllers is managing inventories, variables, and templates and schedule tasks for nodes through cron jobs.

Ansible Agent

The role of agents on each system being managed by Ansible is to collect data from them and send information back to the controller node.

Ansible Tower

A commercial product that manages pull dynamic inventory systems like LDAP, Microsoft AD, and other systems like AWS EC2. It also has a REST API that enables it to connect to the infrastructure.

Ansible Galaxy

The largest collection of community-made roles is available on the web.

Ansible Engine

The core engine executes playbooks in Ansible-managed environments and controls the flow for how tasks are executed.

Ansible Galaxy Command Line Interface (CLI)

A great way to interact directly with Ansible from the command line as well as interact with roles hosted on Galaxy.

Click Here to Read: What is Kubernetes (K8s)? A Kubernetes Basics Tutorial

Ansible for DevOps

Ansible and DevOps are a natural fit, so it’s no surprise that you can use Ansible to manage your DevOps infrastructure. Ansible has been built from the beginning with DevOps in mind. You can use Ansible from your own laptop or desktop in your office when you need to do some quick tests and see if your infrastructure works as expected before you deploy changes in production. Ansible allows you to automate different kinds of tasks like application deployments, configuration management, or continuous integration (CI). 

Using Ansible to automate all DevOps tasks, we can reduce everyday workload, and increase the efficiency of our jobs. For example, with Ansible we can optimize server provisioning (using {{ansible_pkg|puppet}}), or monitor system performance (i.e., using {{ansible_pkg|nagios}}). We can also use Ansible for application deployment (i.e., using {{ansible_pkg|fabric}}) and even for building new applications from scratch, automating everything from generating code to deploying it in the production environment (i.e., {{ansible_pkg|fabric3}}).

Some Useful Links

Conclusion

The bottom line is that Ansible automation is super-easy to use and get going, even for a non-developer with minimal experience. We’d highly recommend it to designers who are keen to learn more about automation, especially as there’s also an excellent Ansible community out there on GitHub who know all about the tool and will happily share their knowledge!

Leave a Reply