How To Install Ansible on Debian 11

Install Ansible on Debian 11

In this tutorial, we will show you how to install Ansible on Debian 11. For those of you who didn’t know, Ansible is the simplest way to automate apps and IT infrastructure. Ansible uses port 22 (SSH) to connect to a remote machine and make the necessary changes. It is a cross-platform tool designed to handle system configurations while working with Linux, macOS, and Windows operating systems.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Ansible on a Debian 11 (Bullseye).


  • A server running one of the following operating systems: Debian 11 (Bullseye)
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Ansible on Debian 11 Bullseye

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade
sudo apt install gnupg2 curl wget

Step 2. Installing Ansible on Debian 11.

  • Install Ansible using Debian default repositories.

By default, Ansible is available in Debian’s default repositories, Now we run the following command to install it:

sudo apt install ansible
  • Install Ansible from the official repository.

Now we add the Ansible repository to your system:

nano /etc/apt/sources.list

Add the following line:

deb focal main

Next, add the Ansible GPG key using the following command:

apt-key adv --keyserver --recv-keys 93C4A3FD7BB9C367

Once done, Update the system package and install Ansible using the following command below:

sudo apt update
sudo apt install ansible

Verify the Ansible installation using the following command:

ansible --version
  • Install Ansible using Python.

A better solution over installing Ansible from the Debian package repository is to install it using Pip or Pip3:

sudo install python3 python3-pip

Once the installation is complete, use the pip command to install Ansible:

pip install ansible

Step 3. Configure Ansible Controller Hosts.

We create an inventory file to define your remote hosts IP address, username, password, and SSH port:

nano ~/.hosts

Add the following lines:

server1 ansible_host= ansible_user=root ansible_ssh_pass=password ansible_ssh_port=22
server2 ansible_host= ansible_user=root ansible_ssh_pass=password ansible_ssh_port=22

We will assume that our Debian-managed node server’s IP addresses are and

To allow the Ansible controller node to communicate with managed nodes, we must confirm that managed nodes are accessible on port 22 which is an SSH port. Execute the below command to confirm the connectivity one by one on all three managed nodes from the controller:

ssh root@
ssh root@

You will be prompted for the password of the root user of all the nodes. Ansible works very smoothly if you have password-less authentication configured between the Ansible controller and managed nodes. With different parameters in the Ansible command, password authentication can work too.

Let’s try to connect to managed nodes from the Ansible controller now:

ansible -m ping servers

Congratulations! You have successfully installed Ansible. Thanks for using this tutorial for installing the latest version of Ansible on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official Ansible website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button