What is Ansible?
Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. It includes its own declarative language to describe system configuration. Ansible was written by Michael DeHaan and acquired by Red Hat in 2015. Ansible is agentless, temporarily connecting remotely via SSH or Windows Remote Management (allowing remote PowerShell execution) to do its tasks. Initially it was released on 20th February 2012. The latest stable version is 2.10.2, released on October 6, 2020. It is written in python, powershell and ruby. Its supported OS are : Linux, unix-like, MacOS, Windows.
Architecture of Ansible :-
Unlike most configuration-management software, Ansible does not require a single controlling machine where orchestration begins. Ansible works against multiple systems in your infrastructure by selecting portions of Ansible’s inventory, stored as edit-able, version-able ASCII text files. Not only is this inventory configurable, but you can also use multiple inventory files at the same time and pull inventory from dynamic or cloud sources or different formats (YAML, INI, etc.). Any machine with Ansible utilities installed can leverage a set of files/directories to orchestrate other nodes. The absence of a central-server requirement greatly simplifies disaster-recovery planning. Nodes are managed by this controlling machine – typically over SSH. The controlling machine describes the location of nodes through its inventory. Sensitive data can be stored in encrypted files using Ansible Vault, since 2014. In contrast with other popular configuration-management software — such as Chef, Puppet, and CFEngine — Ansible uses an agentless architecture, with Ansible software not normally running or even installed on the controlled node.
Advantages of Ansible :-
1. Minimal in nature : Management systems should not impose additional dependencies on the environment.
2. Consistent : With Ansible one should be able to create consistent environments.
3. Secure : Ansible does not deploy agents to nodes. Only OpenSSH and Python are required on the managed nodes.
4. Highly reliable : When carefully written, an Ansible playbook can be idempotent, to prevent unexpected side-effects on the managed systems.
5. Minimal learning required : Playbooks use an easy and descriptive language based on YAML and Jinja templates.
Moules of Ansible :-
Modules are mostly standalone and can be written in a standard scripting language (such as Python, Perl, Ruby, Bash, etc.). One of the guiding properties of modules is idempotency, which means that even if an operation is repeated multiple times, it will always place the system into the same state.
Inventory Configuration of Ansible :-
The Inventory is a description of the nodes that can be accessed by Ansible. By default, the Inventory is described by a configuration file, in INI or YAML format, whose default location is in /etc/ansible/hosts. The configuration file lists either the IP address or hostname of each node that is accessible by Ansible. In addition, nodes can be assigned to groups.
Playbook in Ansible :-
Playbooks are YAML files that express configurations, deployment, and orchestration in Ansible, and allow Ansible to perform operations on managed nodes. Each Playbook maps a group of hosts to a set of roles. Each role is represented by calls to Ansible tasks.
What it can automate?
1. Provisioning: Set up the various servers you need in your infrastructure.
2. 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.
3. Application deployment: Make DevOps easier by automating the deployment of internally developed applications to your production systems.
Ansible can automate IT environments whether they are hosted on traditional bare metal servers, virtualization platforms, or in the cloud. It can also automate the configuration of a wide range of systems and devices such as databases, storage devices, networks, firewalls, and many others.
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.
Why we choose Ansible over others?
There are many other IT automation tools available, including more mature ones like Puppet and Chef, so why would you choose Ansible? The main reason is simplicity.
Some of the use cases of Ansible that are giving benefit to the technical industries and helping them to solve their challenges :-
1. Weekly system reboot: There’s nothing worse than doing the same thing for 8 hours a day! Eliminate repetitive, manual processes with automation.
2. Enforce security guidelines: Rules are rules. It’s best to automate in an effort to achieve strict security standards.
3. Monitor configuration drift: Use check mode with Ansible tasks to enforce desired settings and see if your configuration has drifted.
4. Disaster recovery: Disaster recovery can involve a wide range of components. Act across different variables of the technology stack to identify problems and eliminate cross team dependencies.
5. Command blaster: Remarkably easy to write, you can run commands across your environment for any number of servers.
6. Database binary patching: Several databases use outdated binary sets. Patch the binaries in accordance with the release of the latest patch.
7. Instance provisioning: Use modules for several cloud providers to create new instances and tailor their configuration.
8. Service license agreements: Mistakes cost time and money. Eliminate errors that can crop up in detailed software contracts.