Skip to main content

Command Palette

Search for a command to run...

A Step-by-Step Guide to Learn Ansible

Published
2 min read
H

Empowering communities via open source and education.

Introduction of Ansible

Ansible is an open-source tool used for IT automation. It helps automate tasks like configuring servers, deploying applications, and managing infrastructure. It uses simple text files called playbooks, written in YAML, to describe what needs to be done.

Why Use Ansible:

  1. Automation: Reduces manual effort by automating repetitive tasks.

  2. Simple: Easy to learn, with no special coding skills needed.

  3. Agentless: Doesn't require installing software on managed systems; uses SSH.

  4. Scalable: Manages many servers at once.

  5. Efficient: Ensures consistency across systems and prevents human errors.

Ansible environments have three main components:

Control node

A system on which Ansible is installed. You run Ansible commands such as ansible or ansible-inventory on a control node.

Inventory

A list of managed nodes that are logically organized. You create an inventory on the control node to describe host deployments to Ansible.

Managed node

A remote system, or host, that Ansible controls.

Installing Ansible on specific operating systems

  • sudo apt update
    Updates the list of available packages and their versions from repositories.

  • sudo apt install software-properties-common
    Installs a package that helps manage repositories and PPAs.

  • sudo add-apt-repository --yes --update ppa:ansible/ansible
    Adds the official Ansible repository to get the latest version and updates the package list.

  • sudo apt install ansible
    Installs Ansible on your system.

Start automating with Ansible

  • pip install ansible
    Installs Ansible using Python's package manager (pip).

  • mkdir ansible_quickstart && cd ansible_quickstart
    Creates a new folder named ansible_quickstart and moves into it. This will be your project directory.

Building an inventory

An inventory in Ansible is a file that lists the servers (managed nodes) you want to automate, organized into groups or categories.