# devops / automation / ansible 101

Introduction to Ansible

Ansible is an open-source, agentless automation tool by Red Hat. It uses simple, human-readable YAML files called playbooks to automate configuration management, application deployment, and orchestration across your entire fleet.

$ ansible all -m ping -i inventory
server-01SUCCESS
server-02SUCCESS
server-03SUCCESS
Agentless
Design
YAML
Playbooks
# capabilities

Key Characteristics

Ansible is designed to be minimal in nature, consistent, and highly reliable. Here is what makes it stand out from legacy configuration tools.

no software to install

Agentless

No agents are required on managed nodes. It natively uses SSH for Linux/UNIX systems and WinRM for Windows.

state driven

Declarative Playbooks

You describe the desired state in YAML; Ansible figures out the exact commands and steps needed to get the system there.

safe

Idempotent Modules

Tasks are safe to run multiple times. If a system is already in the desired state, Ansible recognizes this and does absolutely nothing.

flexible

Extensible

Custom modules, plugins, and roles allow you to flexibly extend Ansible to orchestrate complex workflows, cloud providers, and networking devices.

# architecture

How Ansible Works

Ansible operates on a simple push-based architecture from a central control node out to your infrastructure.

Core Components

  • Control Node

    The machine where you run ansible or ansible-playbook (requires Linux/macOS with Python).

  • Managed Nodes

    The target servers, network devices, or virtual machines being automated.

  • Inventory

    A list (INI or YAML format) defining your managed hosts and organizing them into groups.

  • Modules

    Reusable units of code that execute tasks (e.g., package, file, service).

  • Playbooks

    An ordered list of plays (which map target hosts to specific tasks).

# commands

Modules & Quick Commands

Common Module Categories

  • System

    user, group, package, service

  • File

    copy, template, file

  • Command

    command, shell

  • Networking

    nxos, ios, eos, junos

  • Cloud / App

    aws, azure, gcp, docker, kubernetes

terminal
# Check host connectivity using the ping module
$ ansible all -m ping -i inventory
 
# Run an ad-hoc command on all hosts
$ ansible all -a "uptime" -i inventory
 
# Execute a declarative playbook
$ ansible-playbook -i inventory site.yml
$
# configuration

Automation Types: Push vs Pull

Configuration management tools generally fall into two architectural paradigms. Ansible uses the Push model, which is why it doesn't require agents.

Feature Push Architecture 🚀 Pull Architecture 🧲
Mechanism Control node sends instructions directly to the servers. Servers continuously fetch configs from a central master server.
Agent Requirement No agents needed (Agentless). Requires a background agent running on every host.
Speed Immediate execution when triggered. Execution depends on the agent's polling interval.
Tool Examples Ansible, Terraform Puppet, Chef