Have you ever found yourself repeating the same setup steps over and over again — whether it’s installing packages, creating users, or restarting services? Ansible lets you automate those tasks in a simple, human-readable way. You don’t need to be a developer, write complex scripts, or even install anything on your target machines.
This post kicks off our 5-part series on Ansible automation, guiding you from beginner to intermediate skills. Today, we’ll walk through installing Ansible, setting up your first inventory, and running your very first playbook. Let’s get started.
Why Ansible?
Ansible is a powerful automation tool used for configuration management, application deployment, and task automation. Here’s why it’s loved by sysadmins, developers, and even home lab enthusiasts:
- Agentless: It uses SSH to connect — no client software needed on your target machines.
- Simple syntax: Playbooks are written in YAML, which reads almost like English.
- Scalable: Works great for one machine or a hundred.
Whether you’re automating Linux server setups or streamlining tasks across multiple Raspberry Pis at home, Ansible is an excellent starting point.
What You Need to Get Started
To follow along, you’ll need:
- A control machine (where Ansible is installed): Linux, macOS, or WSL on Windows
- One or more remote machines to manage (can be local VMs, cloud servers, etc.)
Step 1: Install Ansible
On Ubuntu/Debian:
sudo apt update && sudo apt install ansible -y
On macOS (using Homebrew):
brew install ansible
You can verify installation with:
ansible --version
Understanding the Inventory File
Ansible keeps track of your target systems in an inventory. Here’s a simple example:
inventory.ini
[home_servers]
192.168.1.10
192.168.1.11
[home_servers:vars]
ansible_user=youruser
ansible_ssh_pass=yourpassword
Pro tip: It’s best to use SSH keys instead of passwords. We’ll explore that in a later post.
You can test connectivity with:
ansible all -m ping -i inventory.ini
If everything is configured correctly, you’ll get a “pong” back from each host.
Your First Ansible Playbook
Let’s automate a small but practical task: installing htop on your remote machines.
install_htop.yml
---
- name: Install htop on remote machines
hosts: home_servers
become: true
tasks:
- name: Install htop
apt:
name: htop
state: present
Run the playbook with:
ansible-playbook install_htop.yml -i inventory.ini
What Just Happened?
Let’s break it down:
hosts: home_servers— tells Ansible which group to targetbecome: true— run tasks as sudoapt:module — used to install packages on Debian-based systems
Ansible connected to each machine over SSH, ran the task, and reported the results — all without logging into each one manually.
Recap
You just:
- Installed Ansible on your control machine
- Created an inventory of target machines
- Ran a playbook to automate package installation
This may seem simple, but it’s the core foundation of much more powerful workflows.
What’s Next?
In Part 2, we’ll dig deeper into the anatomy of a playbook — tasks, variables, handlers, and how to make your automations reusable.
Stay tuned, and happy automating!