Here is how to install Ansible on Debian 12. Tested and verified.
Prerequisites
- Debian 12 (bookworm) installed and updated
- Root or sudo access
- Internet connection
Step 1: Update System
sudo apt update && sudo apt upgrade -yStep 2: Confirm Ansible Is Available
Debian 12 (bookworm) ships Ansible directly in its main repository, so no third-party repository needs to be added for a working install. Check what version is on offer:
apt-cache policy ansibleIf you need a newer release than the one Debian ships, use the community-maintained Ansible repository (built for Ubuntu, but usable on Debian by mapping the codename):
# Optional: install a newer Ansible than Debian 12's default package
sudo apt install -y software-properties-common gnupg
UBUNTU_CODENAME=jammy
wget -O- "https://keyserver.ubuntu.com/pks/lookup?fingerprint=on&op=get&search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367" | sudo gpg --dearmor -o /usr/share/keyrings/ansible-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/ansible-archive-keyring.gpg] http://ppa.launchpad.net/ansible/ansible/ubuntu $UBUNTU_CODENAME main" | sudo tee /etc/apt/sources.list.d/ansible.list
sudo apt updateStep 3: Install Ansible
sudo apt install -y ansibleFor a minimal install with just the core engine (no bundled collections):
sudo apt install -y ansible-coreStep 4: Verify Installation
ansible --version
ansible localhost -m pingExpected output shows the installed version, followed by a "ping": "pong" response.
Step 5: Verify Collections and Configuration
# List installed collections
ansible-galaxy collection list
# Install additional collections as needed
ansible-galaxy collection install community.general
# Inspect the active configuration
ansible-config viewAnsible is agentless and has no daemon or background service β it connects to managed hosts over SSH only when you run a command or playbook, so there is nothing to systemctl enable or check with systemctl status.
Troubleshooting
Package Not Found
Refresh the local package index and confirm youβre on Debian 12 (bookworm):
sudo apt update
cat /etc/debian_version
apt-cache policy ansibleOutdated Ansible Version
Debianβs ansible package tracks the Debian release cycle, so it can lag behind the latest upstream release. If you need a specific or newer version, use the repository from Step 2, or install into an isolated environment with pip/pipx β see Install Ansible with pip in a Virtual Environment.
Uninstall
sudo apt remove -y ansibleRelated Guides
About the Author
I am Luca Berton, AI and Cloud Advisor. Book a consultation to get help with your infrastructure setup.