Skip to main content
Lexicon
Lexicon
Ansible

Ansible

Difficulty: Intermediate
6 min read
Updated 2026-08-20

In plain English

Plain definition

Ansible is a tool that lets an engineer describe, in a simple text file, the state a set of servers or network devices should be in, and then have that state applied automatically across many machines at once. There is no permanent software installed on the machines being managed; Ansible connects to them temporarily, usually over SSH, runs its instructions, and disconnects.

How Ansible runs a playbook

Ansible is agentless and push-based. Automation logic is expressed as declarative YAML documents called playbooks, composed of ordered plays and tasks. Each task invokes a named module (for example a package manager module or a file-state module) against a defined inventory of hosts. Ansible connects to managed nodes over SSH (or WinRM for Windows targets), transfers small Python (or PowerShell) payloads, executes them, and reports per-host results back to the control node. Idempotency is a design property of well-written modules and tasks: re-running the same playbook against a host already in the desired state should produce no further change.

What teams use it for

Teams use Ansible to remediate configuration drift, deploy applications, orchestrate patching, configure network devices and bootstrap infrastructure. Its agentless model reduces the attack surface and maintenance burden associated with persistent agents, but it also means correctness depends heavily on inventory accuracy, credential handling and network reachability at run time. Because playbooks execute with whatever privilege the connecting user holds (often elevated via become), keeping the control node’s credentials and the managed-node sudo policy to least privilege is a control in its own right, not an optional hardening step.

Where Ansible fits in the toolchain

Ansible belongs to the configuration-management and orchestration layer of the stack, typically above provisioning tools (which create compute, network and storage resources) and below or alongside deployment pipelines. In many toolchains Ansible is invoked from continuous-integration or continuous-delivery pipelines to apply configuration after infrastructure has been provisioned, or is used independently for fleet-wide configuration enforcement. Ansible Automation Platform (Red Hat’s commercial distribution) adds a control plane, role-based access control, credential vaulting and scheduling around the open-source engine, but the underlying execution model of inventories, playbooks and modules remains the same.

A playbook that installs and starts nginx

This minimal playbook ensures a package is present and a service is running on a group of hosts named webservers:

---
- name: Ensure nginx is installed and running
  hosts: webservers
  become: true
  tasks:
    - name: Install nginx
      ansible.builtin.package:
        name: nginx
        state: present
    - name: Ensure nginx is running
      ansible.builtin.service:
        name: nginx
        state: started
        enabled: true

Run it in check mode first (a dry run) against a non-production inventory to see what would change before it touches real hosts.

Idempotency is not automatic

Using Ansible does not, on its own, make automation idempotent. Idempotency is a property of individual modules and how tasks are written, not a guarantee provided automatically by the engine. A task built around a raw shell or command module that runs an imperative command (for example, appending a line to a file with echo >>) can produce a different result on every run. Automation you can safely repeat comes from state-declaring modules, and from testing playbooks in check mode before applying them across a fleet.

  • Playbook: the YAML file defining plays and tasks that Ansible executes.
  • Inventory: the list of managed hosts and groups a playbook targets.
  • Module: the unit of work (for example, package, service, file) that a task invokes.
  • Idempotency: the property that re-running the same operation produces no unintended additional change.
  • Ansible Vault: the built-in mechanism for encrypting sensitive variables and files within a playbook repository.

Further reading and verification

Readers evaluating Ansible for a specific environment should confirm the exact platform version, supported connection plugins and privilege-escalation configuration against the current vendor documentation before relying on any version-specific behaviour, since automation-tool release cadence and module deprecations change over time.

About this page

Credited to

Dates

Published

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.