Skip to content
IT glossary
DevOps and cloudUpdated December 3, 2026

Ansible

A tool for configuring servers and deploying software automatically. You write down what should be installed, configured, or running, then apply those instructions to the machines you select.

What Ansible does

Suppose a team adds five Linux servers to an existing web fleet. Instead of setting up each machine by hand, the team can run the same Ansible playbook it used for the original servers. Keeping that playbook in Git lets teammates review changes to the setup before applying them.

How a run works

Ansible starts on a control node, which might be your workstation or a CI runner. The inventory supplies the hosts Ansible can target, often grouped by role or environment. A playbook is a YAML file containing one or more plays. A play selects hosts and defines tasks, and each task typically calls a module that performs a specific operation, such as copying a file or managing a service.

Ansible typically connects to Linux hosts over SSH. It is called agentless because it does not need a dedicated background agent on each host. That does not eliminate prerequisites: the control node still needs working access, and most Linux modules need Python on the managed host.

Example: manage a web service

- name: Configure web hosts
  hosts: web
  become: true
  tasks:
    - name: Ensure Nginx is installed
      ansible.builtin.package:
        name: nginx
        state: present
    - name: Ensure Nginx runs now and starts at boot
      ansible.builtin.service:
        name: nginx
        state: started
        enabled: true

This play targets the inventory group web. It assumes Nginx is available from the hosts' configured repositories and that the connection user can escalate privileges with become. The first run changes whatever is missing; a second run makes no changes if the package and service already match the requested state. In particular, started does not restart a service that's already running.

Common uses and pitfalls

Teams use Ansible to configure operating systems, distribute application settings, and coordinate deployments. A role packages related tasks, templates, defaults, and handlers for reuse. A handler is useful when a service should reload only after a task actually changes its configuration file.

A playbook is not automatically idempotent. A shell task that appends a line will append it again on the next run unless you add a guard or use a module such as lineinfile that can ensure the line is present. Check mode (--check) can preview changes for supported modules, but it isn't a substitute for running the playbook in staging.

How it comes up in interviews

Interviewers often ask you to trace a second run or explain how to deploy without updating every server at once. For the first, point to the behavior of individual tasks rather than calling Ansible declarative. For the second, explain how serial limits a play to batches of hosts, and what you would verify before proceeding to the next batch.