Ansible – Chapter 1: Anisble, A Quick Overview

Getting Started with Ansible: A Quick Overview

Ansible is here to simplify your infra life! This open-source automation tool is designed to make tasks like server provisioning, application deployment and configuration management a breeze. It doesn’t require any agents or config installed on the clients. In this quick overview, we’ll cover the basics of Ansible, from installation to running your first playbook.

Ansible Installation

Anisble is written in python, and can be installed using,
pip install ansible
Depneding on the OS you’re using there are other ways to get it installed. Checkout for details on disto specific install instructions.
Once you’ve successfully installed Ansible, you’re ready to start automating!

Inventory Files

The first step in managing remote systems with Ansible is creating an inventory file. This file lists the hosts you want to manage and can be written in either INI or YAML format.
Here’s a simple example in INI format:
web1 ansible_host=
web2 ansible_host=

db1 ansible_host=
db2 ansible_host=
And the equivalent YAML format will be:

The inventory file allows Ansible to know which hosts to target when running commands or playbooks.

Running Ad-Hoc Commands

Ansible provides a powerful feature called ad-hoc commands, which allows you to perform quick, one-off tasks on remote hosts. For example, you can use the `ansible` command to check the uptime of all your web servers like:
ansible web_servers -i inventory.ini -m command -a "uptime"
In this command:
– `web_servers` is the group of hosts from your inventory.
– `-i inventory.ini` specifies the inventory file.
– `-m command` tells Ansible to use the command module.
– `-a “uptime”` provides the command to run on the remote hosts.

Simple Playbooks

While ad-hoc commands are handy, Ansible’s real power shines through playbooks. Playbooks are written in YAML and allow you to define a series of tasks to be executed on remote hosts. Here’s a minimal playbook that ensures the Apache web server is installed and running:
- name: Ensure Apache is installed and running
  hosts: web_servers
    - name: Install Apache
      become: yes
        name: apache2
        state: present
    - name: Start Apache service
        name: apache2
        state: started
In this playbook, we specify the tasks we want to run on the `web_servers` group, ensuring that Apache is installed and its service is started.

Introduction to Roles

Roles are a way to organize and reuse Ansible playbooks. They encapsulate a set of tasks, variables, and files into a reusable package. Roles make it easy to structure your automation projects and share them with others.
This quick overview only scratches the surface of what Ansible can do. As you dive deeper into Ansible, you’ll discover its flexibility and power in automating your infrastructure and applications. Happy automating!

Leave a Reply

Your email address will not be published. Required fields are marked *

Your technology transformation partner

© 2023 biskitAI

Scroll to Top