How to install Ansible on Raspberry Pi OS (Bookworm)
By Luca Berton · Published 2024-01-01 · Category: installation
Step-by-step guide to install Ansible on Raspberry Pi OS (Bookworm). Set up Ansible on your Raspberry Pi for home automation, lab environments, and IoT.

How to Install Ansible on Raspberry Pi OS
In this guide, I'll show you how to install Ansible on Raspberry Pi OS (Bookworm). The Raspberry Pi is perfect for home labs and IoT automation. I'm Luca Berton, and I'll walk you through the setup.
See also: Ansible on Debian 12 Bookworm Automation Complete Guide
Prerequisites
- Raspberry Pi (3, 4, 5, or Zero 2 W)
- Raspberry Pi OS (Bookworm) installed
- SSH enabled or keyboard/monitor
- Internet connection
Step-by-Step Installation
Step 1: Connect via SSH
ssh pi@raspberrypi.localStep 2: Update the System
sudo apt update && sudo apt upgrade -yStep 3: Install Ansible
sudo apt install ansible -yStep 4: Verify Installation
ansible --versionStep 5: Test Ansible
ansible localhost -m pingAlternative: Install via pip (Latest Version)
sudo apt install python3-pip python3-venv -y
python3 -m venv ~/ansible-venv
source ~/ansible-venv/bin/activate
pip install ansibleSee also: Ansible apt Module: Install, Remove & Manage Packages on Debian/Ubuntu
Use Cases for Ansible on Raspberry Pi
- Home lab management — Configure multiple Pis from one
- IoT automation — Deploy configs to IoT devices
- Network automation — Manage home network equipment
- Learning environment — Practice Ansible skills affordably
- Home server — Automate media server, Pi-hole, Home Assistant
Example: Configure Multiple Pis
# inventory.ini
[pis]
pi-web ansible_host=192.168.1.101
pi-db ansible_host=192.168.1.102
pi-monitor ansible_host=192.168.1.103
[pis:vars]
ansible_user=pi# setup-pis.yml
---
- name: Configure all Pis
hosts: pis
become: true
tasks:
- name: Update packages
ansible.builtin.apt:
update_cache: true
upgrade: safe
- name: Install common tools
ansible.builtin.apt:
name:
- vim
- htop
- git
- tmux
state: presentFAQ
Does Ansible run well on Raspberry Pi?
Yes. Ansible runs as a control node on Raspberry Pi 3 and newer. Pi Zero/1 may be too slow for large playbooks.Can I manage x86 servers from a Raspberry Pi?
Absolutely. The Ansible control node (Pi) just needs SSH access to managed hosts. Architecture doesn't matter.See also: Ansible on Debian 11 Bullseye: Docker CE Installation Complete Guide
Conclusion
You've successfully installed Ansible on Raspberry Pi OS. For more guides, visit AnsiblePilot.
Related Articles
Category: installation