What is Ansible?
It is a really simple IT automation tool that automates cloud provisioning, configuration management, application deployment, intra-service orchestrion, and many other IT needs.
Ansible Architecture –
It internally had lots of modules which is written in python and you can use these modules by the specific name given by the ansible. Ansible works by connecting different nodes and pusing out a small program called “Ansible Modules” to them. Ansible uses ssh protocol to connect and execute these modules in target nodes and after completion of the task, it remove the module.
Why do we need Ansible?
Well before talking about the advantages that ansible have, let us tell you the problem faced by the comapnies before any automation tools came in market.
Let us go 13 years back when networked computing was just started to growing, more and more people started using the internet and started deploying their webpages and started using web apps. Now companies have to manage these things and give reliability to their customers. For this companies system, administrators had to manage their servers with their hands.
But when lots of traffic started coming then they realize that managing servers every time by the manual hand is so difficult. Its also affects the velocity of the work of the developers although they are agile software developer who quickly design the software but IT operations were spending lots of time in configuring the systems. At last, the result was server provisioning and configuration management tools comes to flourish.
Considering the server administrator, they have to cut-copy-paste the file here and there is lots of server in a daily basis. These tasks are time-consuming and the main fact is that doing work by hand multiple times can make errors sometimes so it consumes more time to resolve the errors.
These all problems have one solution and the solution is – Ansible.
Now let comes to the main topic why we need ansible?
Ansible doesn’t require any agents and additional security infrastructure. It is very simple and easy to use. It uses simple language(YAML Language, in the form of Ansible Playbook) that allows you to describe your automation needs in a simple English language.
Before I explain some more further terms about it let me get you familiar with a few its terminologies:
Ansible Vocabulary :
- Controller Machine: Controller machines is that machine where we install ansible for doing the tasks.
- Inventory: It is the file where we put the information about the target nodes like – IP Address, username, password, and the connection type.
- Playbook: It is the file where we put all the tasks that we want to automate and configure in target nodes. The playbook should be written in YAML language and the extension should be .yml.
- Task: A block that defines the single execution of something. Playbook have multiple tasks.
- Module: A module is typically you can call as functions that are used to perform the task.
- Role: A pre-define way to organize the playbook for the different-different task for multiple nodes.
- Play: A task that is executed from start to end is known as play. In simple words, the execution of an ansible-playbook is known as Play.
- Facts: It is a global variable that stores all the information about the target nodes.
- Handlers: Used to trigger the services status changes, like restarting or stopping a service.
It allows to configure multiple nodes at just one single run. Through it you can choose which machine to configure.
Advantages of Using Ansible —
- Simple: Ansible uses YAML Language which use key-value pair in just simple English language called as playbook. It is really very simple to install in it. You can check my blog steps to install it.
- Agentless: ansible is completely agentless. There is no additional software or firewall/port is requires to run it. One of the best things about using ansible is that this software does not require to install in target nodes.
- Powerful and Flexible: Ansible has so many powerful features that give you the reliability to configure complex systems. Ansible’s capabilities allow you to orchestrate the entire application environment regardless of where it is deployed. It doesn’t require any information about the operating system of target nodes. It itself finds all the information and configure it.
- Efficient: Ansible modules work via JSON, programming languages that you already know.
What Ansible Can Do?
Ansible can work like other software what they do like Puppet, Chef, SaltStack etc. But ansible is not just limited to configuration managements. It can solve lots of problems. These are few of them –
- Provisioning: Suppose you made an App so for deploying it you need any server. You can use bare-metal servers or virtual machine booting, or creating virtual or cloud instances from templates, Ansible here also help you to set up all these things.
- Configuration Management: It establishes and maintains consistency of the product performance by recording and updating detailed information that describes an enterprise’s hardware and software. These include version updates and other things.
- Application Deployment: When you define your application with Ansible, it start doing these configuration step by step. For example, I want to set up a web app on the server then I need to follow these steps –
- Install httpd in the target node
- Copy the files in /var/www/httpd and /var/www/cgi-bin
- configure the firewall
- Start the service
It takes time and you have to type the command manually if you launch a web app on multiple servers. Don’t worry just write the tasks in an ansible-playbook and run it as many times as you want by only modifying the inventory file. It will configure all things by itself.
- Security and Compliance: You need to just define your security policy in ansible and it can automate the process for your all nodes. It will set up the security policy the same in all the computers just in a single go. This is the actual power of it.
- Orchestration: Configurations are of multiple types, it not only includes the system configuration. You need to define how multiple configurations interact and ensure the problem’s solution. It provides Orchestration in the sense of aligning the business request with the applications, data, and infrastructure. It defines the policies and service levels through automated workflows, provisioning, and change management.
Case Study – Lifesum Case Study-
Lifesum is a Stockholm-based digital health startup that offers its users a flexible plateform to support and encourage a healthy, balanced lifestyle. It has already achieved more than 6.5 million downloads across Europe. Lifesum app is available on android and iOS, and can be trailered by users and adapted to specific goals and aims, offering guidance based on individual data.
What is its business challenge?
The Lifesum platform consists of applications for iOS, Android, and web, and a joint backend API that supports them. The entire infrastructure of Lifesum is hosted on AWS primarily using the Ubuntu application server. It needed a simple powerful tool for configuration management, application deployment, and server provisioning.
In earlier, they used another too and various bash scripts to manage app deployments and remote command execution. It was definitely a big problem provisioning and managing multiple environments and the differences between them.
How is Lifesum using Ansible?
Lifesum started using Ansible in February 2014. Shortly after that every back-end and front-end engineer at Lifesum started using it to automate things. They use its Playbook to automatically spin up virtual development machines with Vagrant. Its goal was to ensure that everyone had exactly the same working environments as they deploy their applications regularly.
Three months later all our environments, from developer’s laptops to production instances on Amazon, were fully Ansible managed. They use AWS Auto Scaling and pre-bake Amazon AMI images with Ansible provisioning playbooks.
When EC2 instances are launched by Auto Scaling, Ansible, triggered by cloud-init, runs provisioning playbooks, once again ensuring up to date configuration changes are applied, and pulling the latest applications versions from repositories. Ansible has helped us to automate, significantly simplify, and speed up the process of dynamic resources scaling.
They also make use of a limited set of tasks, from provisioning playbooks to power one command application deployments. Its role and playbook can be used in various ways. Ansible has also aided us in ad-hoc remote commands, both across the whole infrastructure and in specific environments, such as minor configuration changes and services administration.
What are your results with Ansible?
We have limited experience with configuration management tools and Ansible shined among competitors and its power and simplicity. It allowed us to focus on getting things done well in a timely and reliable manner, intead of spending time learning to use the tools.
Application developments became an easy and smooth process. Every developer at Lifesum run deployments today with Ansible intead of a having a release manager handling a complex procedure. They deploy as many times per day as they wish and rollback fast when needed.
The greatest thing about Ansible and having infrastructure as code is that every instance can be rebuilt and reconfigured within minutes instead of hours. All this using a self-documented, repeatable process with guaranteed immutability.
Developers can focus on building and delivering great product features instead of solving inconsistencies, misconfigurations and software version problems, thanks to the Ansible provisioner in Vagrant.
As we integrated Ansible into the bootstrapping procedure of EC2 instances, I stay assured that the configuration of every instance looks exactly as desired and Auto Scaling can spin up new machines rapidly.