What is Ansible?


Ansible, a versatile software tool, offers robust yet straightforward automation solutions for cross-platform computer support. Its primary audience is IT professionals who leverage its capabilities for tasks such as application deployment, workstation and server updates, cloud provisioning, configuration management, intra-service orchestration, and various routine systems administration activities. Notably, Ansible distinguishes itself by operating without dependency on agent software or the need for additional security infrastructure, ensuring a seamless and easily deployable automation experience.

As Ansible revolves around automation, it necessitates specific instructions to execute tasks. By documenting everything in straightforward script format, version control becomes a seamless process. This practical approach significantly contributes to the “infrastructure as code” paradigm in IT. It entails treating the maintenance of server and client infrastructure akin to software development, with repositories containing self-documenting, proven, and executable solutions. This ensures organizational continuity, unaffected by personnel changes.

Although Ansible plays a recognized role in automation, systems administration, and DevOps, everyday users also find it equally beneficial. Ansible empowers users to configure not only a single computer but potentially an entire network simultaneously and utilizing it doesn’t demand any programming expertise. The instructions crafted for Ansible are easily comprehensible by humans.
Ansible files are designed to be straightforward and accessible, whether you’re a novice in the realm of computers or an expert.

How Ansible works

Within Ansible, computers are categorized into two types: the control node and managed nodes. The control node, where Ansible runs, is essential, and there can be an additional backup control node if needed. On the other hand, a managed node refers to any device under the control node’s management.

Ansible operates by establishing connections with nodes (which could be clients, servers, or any configured devices) within a network. It accomplishes this by dispatching a compact program known as an Ansible module to the designated node. The execution of these modules occurs over SSH, and upon completion, Ansible removes them. The sole requirement for this interaction is that the Ansible control node possesses login access to the managed nodes. While providing access, the system supports alternative forms of authentication in addition to SSH keys.

What Ansible does

While the term “Ansible modules” may initially seem intricate, Ansible alleviates much of the complexity for users. These modules function as models for the desired state of a system, signifying that each module articulates what should be true on any given managed node. For instance, if a systems administrator determines that all workstations within an organization should run LibreOffice version X.Z, Ansible’s packaging module takes charge of verifying whether each node adheres to this requirement. If Ansible finds a managed node with LibreOffice X.Y installed, it identifies the operating system and executes the necessary routine to update it to LibreOffice X.Z. This approach allows for the seamless overnight updating of every workstation in the organization with the software endorsed by the IT department.

Beyond simply checking software versions, infrastructure maintenance encompasses utilizing Ansible modules. When people discuss employing Ansible, they are essentially alluding to the utilization of Ansible modules, as these constitute the functional components of Ansible that execute specific tasks. If there is a need to automate tasks across multiple computers, explore the array of Ansible modules to identify the one tailored for your task, then proceed to install Ansible to configure and execute that module.

For those with programming skills, the option to craft custom modules for specialized tasks is available. Furthermore, if the custom module proves widely applicable, there is the opportunity to submit it to the Ansible project for inclusion, enabling others to leverage and benefit from your contributions.

[Download the guide: Ansible Automation for Sysadmins]

Ansible playbooks

While modules serve as the tools to execute tasks, the method of utilizing them involves the use of an Ansible playbook. A playbook, written in YAML, serves as a configuration file outlining instructions for achieving the desired state on a managed node. Playbooks are designed to be straightforward, easily readable, and self-documenting.

Additionally, they adhere to the principle of idempotence, ensuring that running a playbook on a system at any time does not have adverse effects. If a playbook is executed on a system already configured to its desired state, the system should remain appropriately configured after the playbook completes.

A playbook can be as straightforward as the following example, which, as a privileged user, installs the Apache HTTP server on any node within an IT department’s webservers group.


– name: Apache server installed
hosts: webservers
become: yes

Playbooks have the potential to be intricate, incorporating conditionals and variables. However, Ansible modules handle the majority of the actual tasks, maintaining conciseness, readability, and clarity in playbooks despite their capability to orchestrate entire networks of managed nodes.

How to Install Ansible?

For Ubuntu/Debian

Open a Terminal:

The terminal is your gateway to the command line interface, where you interact with your operating system. Opening a terminal allows you to execute commands and initiate actions.

Update Package List

The package list contains information about available software packages. Updating it ensures that your system has the latest information about the packages it can install, preventing installation issues

sudo apt update

Install Ansible

This step installs Ansible on your Ubuntu/Debian system. The apt package manager is used to fetch and install Ansible from the official repositories.

sudo apt install ansible

Verify Installation

Verifying the installation ensures that Ansible has been successfully installed on your machine. The --version flag displays the installed Ansible version.

ansible –version

For CentOS/RHEL

Open a Terminal

Like in the Ubuntu/Debian installation, opening a terminal provides access to the command line, allowing you to execute commands.

Enable EPEL Repository

Extra Packages for Enterprise Linux (EPEL) is a repository that provides additional software packages. Enabling it ensures that Ansible is available for installation.

sudo yum install epel-release

Install Ansible

This step installs Ansible on your CentOS/RHEL system. The yum package manager fetches and installs Ansible from the EPEL repository.

sudo yum install ansible

Verify Installation

Confirming the installation checks that Ansible is correctly installed on your machine. The --version flag provides information about the installed Ansible version.

ansible –version

By following these detailed steps, you establish a solid foundation for using Ansible on your Ubuntu/Debian or CentOS/RHEL system. This marks the initial phase of your Ansible journey, setting the stage for creating inventories, writing playbooks, and diving into advanced automation scenarios.

Anatomy of Ansible: Understanding its Parts

  • Ansible comprises several components, each serving a unique purpose:
  • Inventory: Defines the hosts and groups that Ansible manages.
  • Playbooks: Written in YAML, playbooks describe the tasks and configurations to be applied.
  • Modules: Units of work executed by Ansible, handling everything from file operations to cloud provisioning.
  • Roles: Organize playbooks and provide a structure for reusable components.

Conclusion

In conclusion, Ansible stands as a versatile and user-friendly automation tool, empowering organizations to achieve operational excellence. Whether you’re a system administrator, developer, or IT manager, integrating Ansible into your workflow can revolutionize the way you manage and deploy infrastructure.

In the next section we will be looking the different terms used with ansible.

Recent Articles

spot_img

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox