01 Overview
Ansible connects over SSH and applies YAML playbooks to bring servers into a declared state — installing packages, templating config files, restarting services — with no agent required on the target hosts.
→ official documentation02 Installation
Pick a platform. Each step is copy-pasteable on its own.
01 Update package index
sudo apt update
02 Install the PPA (optional, latest release)
sudo apt install -y software-properties-common sudo add-apt-repository --yes --update ppa:ansible/ansible
03 Install Ansible
sudo apt install -y ansible
04 Verify
ansible --version
01 Enable EPEL
sudo dnf install -y epel-release
02 Install Ansible
sudo dnf install -y ansible
03 Verify
ansible --version
01 Install via Homebrew
brew install ansible
02 Verify
ansible --version
Note — commands assume sudo privileges and an up-to-date package index. Pin a specific version in production rather than tracking latest.
03 Install script
The steps above bundled into a single idempotent shell script for provisioning boxes unattended.
install-ansible.sh
Ubuntu/Debian target · safe to re-run · exits non-zero on failure
04 Cheatsheet
The commands reached for most often once Ansible is installed.
| Command | What it does |
|---|---|
| ansible all -m ping -i inventory | Check connectivity to all hosts |
| ansible-playbook site.yml | Run a playbook |
| ansible-playbook site.yml --check | Dry-run without making changes |
| ansible-playbook site.yml --limit web | Run against one host group |
| ansible-vault encrypt secrets.yml | Encrypt a file with Ansible Vault |
| ansible-galaxy install role_name | Install a role from Galaxy |
| ansible-inventory --list | Print the resolved inventory as JSON |