USD ($)
$
United States Dollar
India Rupee

Basics of Ansible: Playbooks and Examples

Created by Deepak Sharma in Articles 23 Jun 2024
Share
«What is Server Virtualization: Explained

Introduction to Ansible

Do you know, Ansible is a free and open-source IT engine that automates application deployment, intra-service orchestration, cloud provisioning, and other IT tasks. Ansible is simple to set up because it does not require any agents or specialized security infrastructure. Ansible uses playbooks to describe automation jobs, and playbooks use a very simple language, YAML (a human-readable data serialization language that is commonly used for configuration files but could be used in many applications where data is stored), that is very simple for humans to understand, read, and write. As a result, even IT infrastructure support personnel may read and comprehend the playbook and debug it if necessary (YAML - It is in human-readable form).

Ansible was created with multi-tier deployment in mind. Ansible does not manage a single system at a time; instead, it models IT infrastructure by defining how all of your systems are linked. Ansible is totally agentless, which means it connects to your nodes via SSH (by default). However, if you prefer another way of connecting, such as Kerberos, Ansible provides that choice.

Ansible pushes little programs known as "Ansible Modules" after connecting to your nodes. Ansible executes such modules on your nodes and then removes them when they are finished. Ansible keeps track of your inventory in simple text files (the hosts file). Ansible makes use of the hosts file to group hosts and manage the operations on a certain group in playbooks.

Advantages of Ansible

● Free: Ansible is an open-source tool.

● It is quite simple to set up and use: Playbooks require no particular coding abilities (more on playbooks later).

● Powerful: Ansible lets you model even highly complex IT workflows.

● Flexible: You have the ability to orchestrate the complete application environment, regardless of where it is installed. You can also tailor it to your own requirements.

● Agentless: There is no need to install any additional software or open any firewall ports on the client systems you wish to automate. You also do not need to establish a distinct management structure.

● Efficient: Because no additional software is required, there is greater space on your server for application resources.

What is Configuration Management?

Ansible defines configuration management as the maintenance of product performance by keeping a record of and updating specific information that characterises an enterprise's hardware and software.

This information often contains the exact versions and updates done to installed software packages, as well as the locations and network addresses of hardware devices. For example, if you wish to install the new version of the WebLogic/WebSphere server on all of the machines in your organization, you cannot do so manually.

With Ansible playbooks and inventory, you can install WebLogic/WebSphere on all of your computers at once. Simply specify the IP addresses of your nodes in the inventory and create a playbook to install WebLogic/WebSphere. Run the playbook from your control machine to install it on all of your nodes.

How Ansible Works?

The picture given below shows the working of Ansible.

banner image

Ansible operates by connecting to your nodes and sending little programs known as "Ansible Modules" to them. Ansible then runs these modules (through SSH by default) and removes them after they're done. There are no servers, daemons, or databases necessary for your module library to run on any machine.

The management node in the above image is the controlling node (managing node) that oversees the entire playbook execution. It is the node from which the installation is being run. The inventory file contains a list of hosts where the Ansible modules must be run, and the management node connects via SSH to the host's machine, executes the tiny modules, and installs the product/software.

✓ To list the host inside inventory file use command:

banner image

✓ To list it as a graph, use command:

banner image

The beauty of Ansible is that it removes modules once they have been installed. It connects to the host system, performs the instructions, and if successful, removes the code that was copied on the host machine and executed.

Ansible - Environment Setup

Installation Process: Mainly, there are two types of machines when we talk about deployment −

● Control machine − Machine from where we can manage other machines.

● Remote machine − Machines that are handled/controlled by the control machine.

Multiple distant machines may be managed by a single control machine. So, in order to manage remote machines, we must install Ansible on the control machine.

Control Machine Requirements

Ansible can be run on any machine that has Python 2 (2.6 or 2.7) or Python 3 (3.5 and higher) installed. It should be noted that Windows does not support a control machine. Ansible manages a remote system via SSH by default.

Ansible doesn't create any databases. It does not require any daemons to launch or run. Ansible does not leave any software installed or running on distant devices while managing them. As a result, there is no need to worry about how to upgrade it while upgrading to a new version.

Ansible can be installed in a variety of methods on the control machine that meets the aforementioned prerequisites. Apt, yum, pkg, pip, OpenCSW, Pacman, and other tools can be used to install the most recent release.

1. Add user on each machine named for example (Ansible)

2. Configure SSH login between these servers (control and remotes) without a password

3. Install Ansible:

banner image

You are now ready to administer remote machines with Ansible after running the above line of code. Simply run Ansible --version to determine the version and whether or not Ansible was properly installed.


Understanding Ansible YAML Basics»
Deepak Sharma

He is a senior solution network architect and currently working with one of the largest financial company. He has an impressive academic and training background. He has completed his B.Tech and MBA, which makes him both technically and managerial proficient. He has also completed more than 450 online and offline training courses, both in India and ...

More... | Author`s Bog | Book a Meeting

Related Articles

#Explore latest news and articles

How to Learn Network Automation: Starter 23 Jul 2024

How to Learn Network Automation: Starter

Effective ways on how to learn network automation using Python for network automation engineers and start a journey to master this essential skill.
What is Machine Learning in AI? Explored 6 Jan 2024

What is Machine Learning in AI? Explored

Basics of what is Machine Learning in AI means. Understand the concepts, and its relation to artificial learning.
Network Automation Basics and Benefits 23 Jun 2024

Network Automation Basics and Benefits

Learn the fundamentals of what is network automation and its benefits. Know how network automation transforms operations, and efficiency in network management.

Comments (0)

Share

Share this post with others

Contact learning advisor

Captcha image