Ansible + Linux
Agentless configuration management with Ansible: YAML playbooks push idempotent changes over SSH to fleets of Linux hosts.
- Ansible
- Linux
- Learning curve
- Moderate
- Status
- Mature and maintained
- Reviewed
- November 2026
- Best for
- Configuring and patching fleets of Linux VMs and bare-metal servers
- Teams that want automation without installing agents or running a central server
- Repeatable runbooks: rolling restarts, certificate rotation, user and SSH key management
- Bootstrapping hosts after Terraform or OpenTofu has provisioned them
- Not ideal for
- Provisioning cloud infrastructure
Overview
Ansible connects from a control node to Linux hosts over SSH, copies small Python modules to each host, runs them and cleans up: no agent or central server is required. Playbooks written in YAML describe the desired state of packages, files, users and services, organised into roles and reusable collections from Ansible Galaxy. Operations teams use it to configure server fleets, apply patches and run repeatable procedures such as rolling restarts, often right after Terraform has created the machines.
What's inside
Simple playbooks are approachable for anyone who knows Linux administration. Idempotent roles, inventory structure and variable precedence take longer, and the Linux knowledge underneath (packages, systemd, permissions, networking) is the real prerequisite.
Ansible
Infrastructure
Hosts, deploys or connects the system
Learning: Easy
Status: Active
Linux
Infrastructure
Hosts, deploys or connects the system
Learning: Moderate
Status: Active
How it works
The control node builds a host list from inventory, renders tasks with Jinja2 variables, and pushes Python modules over SSH to each Linux host in parallel; each module compares current to desired state and reports ok, changed or failed.
- 1.
Other to infrastructure
`ansible-playbook` loads the inventory (a static INI or YAML file, or a dynamic inventory plugin querying AWS, Azure, GCP or VMware) and resolves group_vars, host_vars and role defaults by variable precedence.
- 2.
Infrastructure to infrastructure
It gathers facts (distribution, interfaces, memory) from each host unless disabled, then renders each task's arguments with Jinja2 and opens SSH connections to as many hosts as `forks` allows.
- 3.
Infrastructure to infrastructure
The module (for example `ansible.builtin.package`, `template` or `systemd_service`) is transferred and executed by the host's Python interpreter, escalating through `become` (usually sudo) where needed.
- 4.
Infrastructure to other
Each module checks current state before acting and returns ok, changed or failed as JSON; `--check --diff` previews the same run without applying changes.
- 5.
Other to infrastructure
Changed tasks notify handlers, such as restarting Nginx once at the end of a play, and `serial` batches limit how many hosts change at a time for rolling updates.
Strengths and drawbacks
Strengths
Agentless over SSH
Targets need only SSH and Python, which most Linux distributions already ship, so existing SSH keys, bastion hosts and sudo rules are reused as-is.
Readable YAML, idempotent modules
A task that ensures `nginx` is `state: present` reads as documentation, and well-written plays can run repeatedly with only drifted hosts reporting changes.
Broad collection ecosystem
Collections on Ansible Galaxy cover cloud APIs, network devices, databases and Kubernetes, and community roles exist for most common services.
Preview and test tooling
`--check --diff` shows intended changes, ansible-lint enforces conventions, and Molecule tests roles against containers or VMs before they reach production.
Drawbacks
Slow at large scale
Pushing Python modules over SSH is much slower than agent-based tools across thousands of hosts; teams tune forks, SSH pipelining and ControlPersist, use `strategy: free`, or schedule runs through AWX or Ansible Automation Platform.
Idempotency is not guaranteed
`shell` and `command` tasks run every time unless guarded with `creates`, `removes` or `changed_when`, and plays that only work on the first run leave hosts diverging over time.
No state, no drift detection
Ansible only knows what a run touched. Removing a task does not remove what it created on hosts, and drift is found only by running in check mode.
Variable precedence and YAML pitfalls
The long variable precedence order, Jinja2 quoting inside YAML and loosely typed values (`yes` versus `'yes'`) produce surprising results in large inventories.
Python and distro churn
Newer ansible-core releases drop support for older Python versions on managed nodes, stranding legacy distributions, and package names and service layouts differ across Debian, RHEL and SUSE families.
Scores
Editorial ratings out of 10, comparable across every stack in the guide. They are judgement, not benchmarks. How we score
- Speed of building
- 7.4 out of 10, catalog average 7.7
- Ease of learning
- 7.6 out of 10, catalog average 7.2
- Scalability
- 6.6 out of 10, catalog average 7.6
- Performance
- 5.4 out of 10, catalog average 7.5
- Maintainability
- 6.4 out of 10, catalog average 7.2
- Ecosystem
- 8.4 out of 10, catalog average 8.2
- Flexibility
- 7.8 out of 10, catalog average 7.4
How quickly a team ships features
Higher means easier to pick up
How far it grows before a redesign
Speed of the running application
How well the codebase ages
Libraries, hosting, docs and hiring
How many kinds of product it suits
How it scales
Handles a few hosts to a few thousand by tuning parallelism and splitting inventories; past that, scheduling, credentials and audit trails usually move to AWX or Ansible Automation Platform.
- Starting outMVP and first users
- A Git repository with an inventory file and a few playbooks, run from a laptop against a handful of servers.
- GrowingReal traffic, a few engineers
- Roles per service, group_vars per environment, Ansible Vault or an external secrets manager for credentials, dynamic cloud inventory and runs triggered from CI.
- LargeHeavy traffic or data
- AWX or Ansible Automation Platform scheduling jobs with RBAC, execution environments (container images) pinning ansible-core and collections, and rolling changes with `serial`.
- EnterpriseMany teams and regions
- Ansible Automation Platform across business units with central credentials, Event-Driven Ansible reacting to monitoring events, and Molecule-tested roles published to a private automation hub.
Where it fits
Common projects, from best fit to worst.
Fleet configuration and patching
Keep packages, sysctl settings, users, SSH hardening and service configs consistent across hundreds of servers, with patch windows run in batches.
Great fit
Rolling application deploys to VMs
`serial`, load balancer drain tasks and handlers implement rolling updates, though rollback is another play you have to write and test.
Good fit
Ad-hoc maintenance and incident tasks
Ad-hoc commands and short playbooks collect diagnostics, rotate certificates or restart services across a host group in one step.
Good fit
Provisioning cloud infrastructure
Cloud collections can create resources, but without state there is no plan, drift view or dependency graph; Terraform or OpenTofu fit better.
Poor fit
Alternatives
Similar stacks, and when you would choose them instead.
- Terraform + AWS
Pick Terraform when the job is creating cloud resources with tracked state and a plan; many teams use both, Terraform to provision and Ansible to configure.
CompareAnsible + Linux with Terraform + AWS - Kubernetes + Docker
Pick it when you would rather ship immutable container images than configure long-lived servers in place.
CompareAnsible + Linux with Kubernetes + Docker - Docker Compose + PostgreSQL
Pick it on a single host where containerising services is simpler than managing packages and config files on the OS.
CompareAnsible + Linux with Docker Compose + PostgreSQL
Sources
Reviewed on November 19, 2026 against the documentation below. Found something out of date? Suggest a correction. Read our methodology.
- Ansible documentation
Official Ansible docs.
- Ansible on GitHub
Source and release notes for ansible-core.
- Ansible Galaxy
Public hub for Ansible collections and roles.
Related stacks
Stacks that share technologies with Ansible + Linux.
LAMP
Linux, Apache, MySQL, and PHP, the classic open-source web hosting stack still underpinning large parts of the CMS and shared-hosting web.
- Linux
- Apache
- MySQL
- +1
Learning: Easy
Kubernetes + Helm
Helm charts package Kubernetes manifests as versioned, parameterised releases that can be installed, upgraded and rolled back.
- Kubernetes
- Helm
Learning: Hard
Prometheus + Grafana
Prometheus scrapes and stores time-series metrics and evaluates alert rules; Grafana queries it with PromQL for dashboards, the standard open-source metrics pairing.
- Prometheus
- Grafana
Learning: Moderate