How to Install & Set Up Ansible
Install Ansible — agentless automation for provisioning, configuration management, and app deployment — then build an inventory, write an idempotent playbook, and organize it into roles.
Prerequisites
- ✓A Linux/macOS control node with Python 3.9+ — this is the only machine that needs Ansible installed
- ✓SSH access (key-based, ideally) to the machines you want to manage, plus a Python interpreter on each of them — no agent or daemon runs on the managed side
Why 'agentless' actually matters
Ansible doesn't run anything persistent on the machines it manages. Every run, the control node connects over plain SSH, copies over a small Python script for whatever module the task calls, executes it, and cleans up — there's no daemon to keep patched or a port to expose beyond SSH itself.
The other property worth understanding up front is idempotency: a well-written task describes a desired end state ('this package is installed', 'this file has this content'), not a command to run. Re-running the exact same playbook against a host that's already correct should report changed=0 across the board — that's what lets you safely run the same playbook nightly instead of only once.
Install with pip (recommended)
Install from your distribution
ansible-core is the engine; the full ansible metapackage (pip install ansible) additionally pulls in the large community collection of modules — install that instead of ansible-core if you need modules beyond the built-ins.
Install the bleeding-edge devel branch from source
For a feature or bugfix that hasn't shipped in a release yet, pip can install directly from the devel branch on GitHub — genuinely the same thing the release packages above build from, just unreleased.
devel is a moving target and not meant for production control nodes — use a release install for anything you depend on.
Verify the installation
Build an inventory
The inventory is just the list of hosts Ansible can target, grouped however makes sense for you — by role, by environment, whatever. INI is the classic format; YAML reads better once you start attaching per-group variables.
Ad-hoc commands — Ansible without a playbook
For a one-off task, you don't need a whole playbook — the ansible CLI runs a single module against a group directly. Good for checking connectivity, gathering facts, or a quick fix across a fleet.
Write your first playbook
A playbook is a YAML file of plays, each targeting a group of hosts and running an ordered list of tasks. Handlers are tasks that only fire when notified — the standard pattern for 'restart the service, but only if its config actually changed'.
--check simulates the run and --diff shows what would change, without touching anything — always worth running before the real thing on hosts you care about.
Organize larger projects with roles
Once a playbook grows past a handful of tasks, a role gives you a standard directory layout (tasks/, handlers/, templates/, defaults/, vars/) that Ansible auto-loads by convention — and it's reusable across playbooks and shareable via Ansible Galaxy.
Keep secrets out of Git with Ansible Vault
Passwords and API keys shouldn't sit in plaintext next to your playbooks. Vault encrypts a file (or just a single variable) with a password you supply at run time.
Documentation & Knowledge Base
Download Ansible— all versions & official links→Need Ansible deployed and managed for you?
We're OpenStack Dev — we design, deploy, and operate production DevOps infrastructure.