What Is Ansible and How Does It Work?
What Is Ansible and How Does It Work?
We all know that the key to success for any IT system is keeping it updated. However; most people don’t know that there’s another key too, one that ultimately decides on the longevity of that success. Simplicity is a much underrated term elsewhere, but not in the IT industry. The more simple the system, the better the chance of success. Ansible is the perfect example of this; prepare to have your doubts about simple yet effective IT systems quashed.
What is Ansible?
Ansible is a software platform for managing and combining multi node software deployment, as well as ad-hoc changes in the execution and configuration management of a system. If that Wikipedia-inspired definition was too much to digest, let’s do this the Ansible way – in other words, the simple way! Here’s how Ansible works, with an overview of some of its salient features.
How does Ansible work?
Ansible doesn’t break its process into steps or procedures. To understand how the software works however, we need to look at the different stages one at a time. This will show us how Ansible delivers a great performance with very little overhead. So, let’s get started!
1. Setting up the Architecture
Ansible connects nodes and pushes out small programs called ‘Ansible Modules’. These modules act as the resource for the desired state of the system. Ansible executes these modules and removes them once the execution is complete. As users, we just need to work on our terminal, text editor and in some cases a version controller to keep track of the changes.
2. SSH keys and their role
SSH keys are promoted as the best way to access Ansible. However; you can choose other options like Kerberos as well. Authorization keys are supported and they can control the access of different modules to different users, which will come in handy in many IT systems. Furthermore, root logins are not necessarily required to access Ansible.
Eg:
ssh-agent bash ssh-add ~/.ssh/id_rsa
3. Managing Inventory
Ansible puts all the machines that it is managing on a system in a simple INI file. The machines are grouped as per the user’s choice inside the INI file. New machines can be added without any SSL signings, which also takes out the pain of NTP or DNS issues. As well as that, Ansible can easily plugin to sources such as Rackspace, EC2, Openstack and others. Here’s what the inventory looks like:
[webservers]
www1.example.com
www2.example.com
[dbservers]
db0.example.com
db1.example.com
4. Using Ansible
Once your instance is available, you can just start using Ansible without any extra overheard. All the requirements in the form of resource modules and running commands have already been taken care of. Ansible itself comes with its entire arsenal full of modules. It couldn’t be more simple!
Eg:
ansible all -m ping ansible foo.example.com -m yum -a "name=httpd state=installed" ansible foo.example.com -a "/usr/sbin/reboot"
Key Features of Ansible:
1. Models the IT infrastructure around the systems interrelating with each other, thus ensuring faster end results.
2. Module library can reside on any system, without the requirement of any server, daemons or databases.
3. No additional setup required, so once you have the instance ready you can work on it straight away.
4. Easier and faster to deploy as it doesn’t rely on agents or additional custom security infrastructure.
5. Uses a very simple language structure called playbooks. Playbooks are almost similar to the plain English language for describing automation jobs.
6. Ansible has the flexibility to allow user-made modules that can be written in any programming language such as Ruby, Python. It also allows adding new server side behaviors extending Ansible’s connection types through Python APIs.