Skip to main content

Getting started with Ansible

·3 mins
Keerthi Chinthaguntla
Linux Ansible Linux Ansible External Archive
Author
Keerthi Chinthaguntla
Combining technical expertise with reflections on faith to create meaningful impact in both digital and spiritual realms
Table of Contents
Ansible - This article is part of a series.
Part : This Article
This article was originally published externally, read the original here.

Introduction to Red Hat Ansible
#

Red Hat Ansible is an open-source configuration management tool used for automating tasks, deploying applications, and orchestrating IT infrastructure. With Ansible, you can automate everyday tasks such as updating and patching systems, installing software, onboarding users, and provisioning infrastructure.

In this first article, we’ll cover basic terminology, reasons to choose Ansible, and how to install it. In the next article, we’ll dive into configuring Ansible.

Basic Ansible Terminology
#

Before diving into Ansible, let’s get familiar with some key terminology.

Node Terminology
#

  • Control Node: A host with Ansible installed, primarily used to run tasks on managed hosts. Any machine with Python can serve as a control node, except Windows.
  • Managed Nodes: The hosts managed using Ansible.
  • Inventory: A list of managed nodes.
  • Hostfile: An inventory file that can specify managed nodes using IPs or hostnames, and organize them into groups.

Modules
#

Modules are reusable code blocks that Ansible executes to perform tasks such as adding users, copying files, and pinging managed hosts.

Tasks and Playbooks
#

  • Tasks: Actions that Ansible performs on managed hosts, which can be executed using ad-hoc commands.
  • Playbooks: Lists of repeatable tasks written in YAML Ain’t Markup Language (YAML), offering readability and ease of sharing.

Why Ansible?
#

When choosing a new tool, the key question is: “Why Ansible over others?” Here are a few compelling reasons:

Agentless Architecture
#

Unlike Chef and Puppet, Ansible is agentless, meaning no additional software or daemons are needed on managed nodes. This approach reduces administrative overhead and enables quick setup, allowing you to focus on building playbooks.

Uses SSH for Communication
#

Ansible uses the SSH protocol by default for communication between control and managed nodes, providing secure file transfers with SFTP.

Parallelism with Forks
#

Ansible can communicate with multiple managed nodes simultaneously, enhancing execution speed. The default forks value is 5, but this can be customized in the configuration file.

Installing Ansible
#

For simplicity, our setup includes:

  • One control node: RHEL8
  • Four managed nodes: node1, node2, node3, node4
  • Operating System: Red Hat Enterprise Linux (RHEL)

Control Node Requirements
#

  • Python 2: Version 2.7 or Python 3: Version 3.5 or higher
  • Unsupported on Windows control nodes

Installation Methods
#

Ansible can be installed using:

  • Source Code
  • Python Package Manager (PIP)
  • Distro’s Package Manager (Recommended)

Install Ansible on a Red Hat Machine
#

# Using YUM
sudo yum install ansible -y

# Using DNF
sudo dnf install ansible -y

Verify the Ansible Installation
#

ansible --version

Sample Output:

ansible 2.8.5
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/kc/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Jun 12 2019, 01:12:31) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]

What’s Next?
#

Stay tuned for the next article where we’ll guide you through configuring your new Ansible installation for efficient automation!

Happy automating!

Ansible - This article is part of a series.
Part : This Article

Related

Bash bang commands: A must-know trick for the Linux command line
·3 mins
Keerthi Chinthaguntla
Linux Bash Command Line Terminal External Archive