What is Ansible?

What is Ansible?


0 comments

Ansible is an automation platform that implements a much easier way to deploy applications. Ansible is an open-source automation tool used to perform tasks that encompass provisioning, configuration management, continuous delivery, application deployment, networking, and security compliance. Ansible, or more precisely the Ansible Engine, is installed on a controller machine and provides a command-line interface (CLI) for executing imperative ad-hoc commands.

In addition, the Ansible Engine also provides another executable for operating against playbooks. Playbooks are a declarative definition of a set of sequential tasks run in parallel across a group of hosts. The imperative executable is ansible and the declarative executable is ansible-playbook. Both of these commands operate against a deployment topology definition contained in an inventory file.

The best part is that you don’t even need to know the commands used to accomplish a particular task. You just need to specify what state you want the system to be in and Ansible will take care of it. For example, to ensure that your web servers are running the latest version of Apache, you could use a playbook similar to the following and Ansible would handle the details.



–hosts:webservers
vars:
http_port:80
max_clients:200
remote_user:root
tasks:
–name:ensure apache is at the latest version
yum: name=httpd state=latest
–name:write the apache config file
template:src=/srv/httpd.j2 dest=/etc/httpd.conf
notify:
–restart apache
–name:ensure apache is running (and enable it at boot)
service:name=httpd state=started enabled=yes
handlers:
–name:restart apache
service:name=httpd state=restarted


Why Ansible?

You can use Ansible to automate different types of tasks:


  • Provisioning : Set up the various servers you need in your infrastructure.
  • Configuration management : Change the configuration of an application, OS, or device; start and stop services; install or update applications; implement a security policy; or perform a wide variety of other configuration tasks.
  • Application deployment : Make DevOps easier by automating the deployment of internally developed applications to your production systems.
  • Continuous Delivery : Integrate with source code control systems to automatically deploy new changes to software as soon as changes are committed
  • Orchestration : Ansible orchestrates the entire application, not only the application software but also the databases, storage, and networks
  • Security and Compliance : configure security policies as part of the deployment

Ansible Architecture

The Ansible architecture consists of several pieces that form its environment. The first is the modules. Modules are little programs that act as building blocks encapsulating common tasks such as using yum to install packages or ping to test the connection to a remote host. To date, there are 500 or more Ansible modules for common tasks and many more for middleware and infrastructure tools.

Plugins provide a way to extend Ansible’s functionality. Ansible provides some of its own and there is a framework for writing custom plugins.

The inventory file is the heart of the Ansible environment. The inventory file is a simple ini or YAML file that defines all of the remote hosts in scope. The inventory contains all of the server information for a deployment with deploy targets often organized in groups such as web servers, database servers, etc. One can also assign variables to servers using the inventory file.

Playbooks contain the definition of instructions for a deployment. The playbook defines a set of sequential tasks and actions that apply to a collection of remote servers defined in an inventory file. If the task is applied to a group of servers (such as all of the web servers) in the inventory file, that task will execute on all of the servers of the group in parallel and will not proceed until that task completes on all servers. It is important to remember that tasks in playbooks execute sequentially and if there is one negative to Ansible that would be it.



Installing Ansible

Installing Ansible is very easy. Most of the work involved is provisioning a VM server as an Ansible controller and at least one additional server for kicking the tires. In the real world, an application environment will have more than one remote host but for the purposes of this blog, one remote host is sufficient. In fact, my test environment piggybacks on a three-node Kubernetes cluster – so there is one Ansible controller and two remote deployable hosts. The only requirement for an Ansible controller is the ability to connect via SSH and a python interpreter. Note, Windows is not supported as a control node but is supported and a remote deployable host.

Installation instructions are very well documented at the Ansible Installation Guide web page so there is no real value added to doing so here in this blog. Ansible is supported on several Linux distributions. Pick one that best suits the requirements of your IT shop or your laptop and you should be up in minutes.

Ansible only needs to be installed on one machine and the installation does not leave anything behind – no databases or software on the controller or remote machines. So when it comes to upgrades, there is really nothing to address.


Next Steps

Hopefully, this has provided a high-level understanding of Ansible , it’s benefits, and what it can do you. You can get the Ansible Training Course is designed by DevOps Subject Matter Experts to help you understand Ansible concepts and perform hands-on Ansible deployment and operations.

Drop us a Query

About the author

Bhaskar

Bhaskar

The author has a keen interest in exploring the latest technologies such as AI, ML, Data Science, Cyber Security, Guidewire, Anaplan, Java, Python, Web Designing tools, Web Development Technologies, Mobile Apps, and whatnot. He bags over a decade of experience in writing technical content.

Corporate
whatsapp arrow
Loading...
// load third party scripts onload