What is Ansible and why is it used?
Previously, when there were just a few, perhaps only one server in an organization, sysadmins were responsible for manually managing the server, performing software installation and updates, configuration, and other IT tasks. However, things have changed and the world runs on software.
With the explosion of data, came complex applications. Organizations hosted many more applications on their servers and the bulk of IT operations could no longer be supported or scaled by manually managed applications. The demand for fast, consistent, and reliable configuration and orchestration tools birthed the development of technologies like Puppet, Chef, and Ansible that have been designed primarily for these purposes. These tools help system administrators, most of whom have had to upskill by undertaking Ansible training or training in other technologies, to manage multiple servers.
Of the three, Ansible comes with the additional capability of automating repetitive IT tasks mentioned above. It is also relatively easy to use and does not require coding knowledge therefore many beginners prefer to learn Ansible before advancing to the more complex configuration management tools.
What is Ansible?
Ansible is an open-source engine that provides simple automation for complex repetitive IT tasks like application deployment, workflow orchestration, configuration management, provisioning of infrastructure in IT environments. Ansible is preferred because it is easy to use, saves time, and provides large-scale productivity and scalability advantages, especially where an organization needs to configure a large number of servers, install several packages, or perform multi-tier deployments at once. It has been adopted widely for automation, DevOps, and system administration.
How does Ansible work?
Overall, Ansible works by bringing together IT resources from several systems across the server to support deployments and manages them from one platform. From this platform, it reads information about the nodes that one needs to manage.
Ansible has a simple and effective architecture and works by pushing small programs known as Ansible modules to your nodes to connect. These modules are executed over SSH thus Ansible does not need daemons, databases, libraries, or any special servers to operate. It simply uses commands or a text editor alongside a version control program to manage content. This explains why users do not need to have a programming background as they will not be required to write code to use Ansible.
The Ansible modules, when executed, will cause your system to comply with the desired state. A user is required to describe the infrastructure in a text file (INI). Ansible will then organize all the information about the desired state of the system into YAML playbooks which is a simple powerful automation language. Ansible then gathers all information about the nodes in your network such as IP addresses and other OS details into facts whose provisioning for different configurations on the platform is automated. Once this is done, the programs are deleted automatically. Ansible has more than 750 inbuilt modules.
What can Ansible do?
- Provisioning. Ansible can automate and manage the set-up process for servers in your infrastructure.
- Application deployment. Ansible is quite useful in implementing approaches like DevOps where automation of code deployment is critical to integrating code into production systems frequently and with short cycles during application development.
- Configuration management. Ansible helps with the automation of processes like networks, operating systems, configuration files, and data centers to maintain their optimal and consistent performance in the desired state.
- Infrastructure orchestration. Given the complex nature of IT environments, Ansible allows one to create and automate the complex workflows that run multiple playbooks so that all tasks within your networks, databases, data centers, and applications are managed and organized in a defined structure.
- Security and compliance. Ansible automates the deployment and integration of security policies and technologies with each other across the entire IT infrastructure.
Ansible offers several advantages over other configuration management tools like Chef and Puppet. These are:
- SSH Protocol
Ansible runs on SSH protocol to connect to servers and execute tasks. It does this using SSH keys with ssh-agent which connects to remote machines using the same username that you use on your system. This means that one does not require additional root login to access the server.
- Human-readable YAML language
As we have already seen, using Ansible does not require writing code thus no programming background is needed to operate it. Commands are written in a simple human-readable language known as
- Ansible is agentless
It does not depend on agent software to operate. In addition, it does not come with an additional layer of security infrastructure and is thus easy to deploy.
- It is declarative
Ansible only requires you to write a description of your desired state and all the other details will be executed to fulfill the description. One does not need to write scripts as it is with other languages.
- Use playbooks
Ansible playbooks are written in easy-to-read and edit YAML language. Playbooks can run on hundreds of nodes to speed up IT processes like deployments, software installations, updates, infrastructure provisioning, and many more while also eliminating the errors associated with manual handling. They are used to write modules that automate IT processes without any downside.
Ansible can automate an entire IT environment on virtually any platform including the cloud. Without automation, maintaining and scaling large-scale IT environments can be a resource-draining and time-consuming affair that is not without faults associated with manual operations. Automated configuration management across IT systems like databases, networks, servers, and other applications helps maintain their optimal performance without having to monitor them manually and this is what Ansible is designed to do.