How to install Ansible in Debian version 11? Today we’re going to talk about the easier way to install and maintain Ansible inside Debian using the default “main” repository. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

How to install Ansible in Debian

  • Included in the “main” default repository

Today we’re talking about How to install Ansible in Debian. The good news is that Ansible is included in the default repository so you could install it simply with your usual package manager “apt”. You could expect the latest version of Ansible in the “main” repository.

Join 50+ hours of courses in our exclusive community

Playbook

Install Ansible in Debian using the apt package manager and the “main” default repository.

code

  • install-ansible-debian.sh
#!/bin/bash
$ sudo apt-get update
$ sudo apt-get install ansible
$ sudo apt list –installed ansible

execution

ansible-pilot $ ssh [email protected]
Linux debian 5.10.0-9-amd64 #1 SMP Debian 5.10.70-1 (2021-09-30) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ sudo su
root@debian:/home/devops# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@debian:/home/devops# cat /etc/deb
debconf.conf    debian_version  
root@debian:/home/devops# cat /etc/debian_version 
11.1
root@debian:/home/devops# apt-get update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Hit:2 http://deb.debian.org/debian bullseye InRelease   
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://deb.debian.org/debian bullseye-backports InRelease [43.7 kB]
Get:5 http://deb.debian.org/debian bullseye-backports/main Sources.diff/Index [63.3 kB]
Get:6 http://deb.debian.org/debian bullseye-backports/main amd64 Packages.diff/Index [63.3 kB]
Get:7 http://deb.debian.org/debian bullseye-backports/main Sources T-2021-12-02-0202.04-F-2021-12-02-0202.04.pdiff [29 B]
Get:7 http://deb.debian.org/debian bullseye-backports/main Sources T-2021-12-02-0202.04-F-2021-12-02-0202.04.pdiff [29 B]
Get:8 http://deb.debian.org/debian bullseye-backports/main amd64 Packages T-2021-12-02-0202.04-F-2021-12-02-0202.04.pdiff [257 B]
Get:8 http://deb.debian.org/debian bullseye-backports/main amd64 Packages T-2021-12-02-0202.04-F-2021-12-02-0202.04.pdiff [257 B]
Fetched 254 kB in 1s (488 kB/s)
Reading package lists... Done
root@debian:/home/devops# apt-cache search ansible
ansible - Configuration management, deployment, and task execution system
ansible-lint - lint tool for Ansible playbooks
ansible-mitogen - Fast connection strategy for Ansible
shade-inventory - Ansible inventory script for OpenStack clouds
python3-reclass - hierarchical inventory backend for configuration management systems
reclass - hierarchical inventory backend for configuration management systems
reclass-doc - reclass documentation
vim-syntastic - Syntax checking hacks for vim
root@debian:/home/devops# apt-cache show ansible
Package: ansible
Version: 2.10.7+merged+base+2.10.8+dfsg-1
Installed-Size: 198790
Maintainer: Lee Garrett <[email protected]>
Architecture: all
Replaces: ansible-base (<= 2.10.5+dfsg-2)
Depends: python3-cryptography, python3-jinja2, python3-packaging, python3-yaml, python3:any, openssh-client | python3-paramiko (>= 2.6.0), python3-pycryptodome, python3-distutils, python3-dnspython, python3-httplib2, python3-netaddr
Recommends: python3-argcomplete, python3-jmespath, python3-kerberos, python3-libcloud, python3-selinux, python3-winrm, python3-xmltodict
Suggests: cowsay, sshpass
Breaks: ansible-base (<= 2.10.5+dfsg-2)
Description-en: Configuration management, deployment, and task execution system
 Ansible is a radically simple model-driven configuration management,
 multi-node deployment, and remote task execution system. Ansible works
 over SSH and does not require any software or daemons to be installed
 on remote nodes. Extension modules can be written in any language and
 are transferred to managed machines automatically.
 .
 This package contains ansible-base 2.10.x and ansible-collections 2.10.x merged
 into one package.
Description-md5: de0a87781a6b6efa86ca20d1d1c64ce8
Homepage: https://www.ansible.com
Tag: admin::automation, admin::configuring, admin::file-distribution,
 admin::package-management, implemented-in::python,
 interface::commandline, role::program, use::configuring,
 works-with::software:running
Section: admin
Priority: optional
Filename: pool/main/a/ansible/ansible_2.10.7+merged+base+2.10.8+dfsg-1_all.deb
Size: 17685468
MD5sum: 159657e0be3d3f212fde43db1ac986cd
SHA256: 66474117b31f9b0bc816331c7b5f7424c77a496db5063da0d761cdbc814ef644
root@debian:/home/devops# apt-get install ansible
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  ieee-data libyaml-0-2 python3-argcomplete python3-cffi-backend python3-cryptography
  python3-distutils python3-dnspython python3-jinja2 python3-jmespath python3-kerberos
  python3-lib2to3 python3-libcloud python3-lockfile python3-markupsafe python3-netaddr
  python3-ntlm-auth python3-packaging python3-pycryptodome python3-pyparsing
  python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt python3-selinux
  python3-simplejson python3-winrm python3-xmltodict python3-yaml
Suggested packages:
  cowsay sshpass python-cryptography-doc python3-cryptography-vectors python3-sniffio
  python3-trio python-jinja2-doc python-lockfile-doc ipython3 python-netaddr-docs
  python-pyparsing-doc
The following NEW packages will be installed:
  ansible ieee-data libyaml-0-2 python3-argcomplete python3-cffi-backend python3-cryptography
  python3-distutils python3-dnspython python3-jinja2 python3-jmespath python3-kerberos
  python3-lib2to3 python3-libcloud python3-lockfile python3-markupsafe python3-netaddr
  python3-ntlm-auth python3-packaging python3-pycryptodome python3-pyparsing
  python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt python3-selinux
  python3-simplejson python3-winrm python3-xmltodict python3-yaml
0 upgraded, 28 newly installed, 0 to remove and 1 not upgraded.
Need to get 32.9 MB of archives.
After this operation, 280 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian bullseye/main amd64 python3-cffi-backend amd64 1.14.5-1 [85.8 kB]
Get:2 http://deb.debian.org/debian bullseye/main amd64 python3-cryptography amd64 3.3.2-1 [223 kB]
Get:3 http://deb.debian.org/debian bullseye/main amd64 python3-markupsafe amd64 1.1.1-1+b3 [15.2 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 python3-jinja2 all 2.11.3-1 [114 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 python3-pyparsing all 2.4.7-1 [109 kB]
Get:6 http://deb.debian.org/debian bullseye/main amd64 python3-packaging all 20.9-2 [33.5 kB]
Get:7 http://deb.debian.org/debian bullseye/main amd64 libyaml-0-2 amd64 0.2.2-1 [49.6 kB]
Get:8 http://deb.debian.org/debian bullseye/main amd64 python3-yaml amd64 5.3.1-5 [138 kB]
Get:9 http://deb.debian.org/debian bullseye/main amd64 python3-pycryptodome amd64 3.9.7+dfsg1-1+b2 [9910 kB]
Get:10 http://deb.debian.org/debian bullseye/main amd64 python3-lib2to3 all 3.9.2-1 [77.8 kB]
Get:11 http://deb.debian.org/debian bullseye/main amd64 python3-distutils all 3.9.2-1 [143 kB]
Get:12 http://deb.debian.org/debian bullseye/main amd64 python3-dnspython all 2.0.0-1 [103 kB]
Get:13 http://deb.debian.org/debian bullseye/main amd64 ieee-data all 20210605.1 [1889 kB]
Get:14 http://deb.debian.org/debian bullseye/main amd64 python3-netaddr all 0.7.19-5 [253 kB]
Get:15 http://deb.debian.org/debian bullseye/main amd64 ansible all 2.10.7+merged+base+2.10.8+dfsg-1 [17.7 MB]
Get:16 http://deb.debian.org/debian bullseye/main amd64 python3-argcomplete all 1.8.1-1.5 [29.7 kB]
Get:17 http://deb.debian.org/debian bullseye/main amd64 python3-jmespath all 0.10.0-1 [21.7 kB]
Get:18 http://deb.debian.org/debian bullseye/main amd64 python3-kerberos amd64 1.1.14-3.1+b3 [24.1 kB]
Get:19 http://deb.debian.org/debian bullseye/main amd64 python3-lockfile all 1:0.12.2-2.2 [17.3 kB]
Get:20 http://deb.debian.org/debian bullseye/main amd64 python3-simplejson amd64 3.17.2-1 [61.7 kB]
Get:21 http://deb.debian.org/debian bullseye/main amd64 python3-libcloud all 3.2.0-2 [1615 kB]
Get:22 http://deb.debian.org/debian bullseye/main amd64 python3-ntlm-auth all 1.4.0-1 [21.6 kB]
Get:23 http://deb.debian.org/debian bullseye/main amd64 python3-requests-kerberos all 0.12.0-2 [13.0 kB]
Get:24 http://deb.debian.org/debian bullseye/main amd64 python3-requests-ntlm all 1.1.0-1.1 [6120 B]
Get:25 http://deb.debian.org/debian bullseye/main amd64 python3-requests-toolbelt all 0.9.1-1 [41.7 kB]
Get:26 http://deb.debian.org/debian bullseye/main amd64 python3-selinux amd64 3.1-3 [160 kB]
Get:27 http://deb.debian.org/debian bullseye/main amd64 python3-xmltodict all 0.12.0-2 [15.2 kB]
Get:28 http://deb.debian.org/debian bullseye/main amd64 python3-winrm all 0.3.0-2 [21.6 kB]
Fetched 32.9 MB in 6s (5494 kB/s)    
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LC_CTYPE = "UTF-8",
 LANG = "C.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("C.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package python3-cffi-backend:amd64.
(Reading database ... 25133 files and directories currently installed.)
Preparing to unpack .../00-python3-cffi-backend_1.14.5-1_amd64.deb ...
Unpacking python3-cffi-backend:amd64 (1.14.5-1) ...
Selecting previously unselected package python3-cryptography.
Preparing to unpack .../01-python3-cryptography_3.3.2-1_amd64.deb ...
Unpacking python3-cryptography (3.3.2-1) ...
Selecting previously unselected package python3-markupsafe.
Preparing to unpack .../02-python3-markupsafe_1.1.1-1+b3_amd64.deb ...
Unpacking python3-markupsafe (1.1.1-1+b3) ...
Selecting previously unselected package python3-jinja2.
Preparing to unpack .../03-python3-jinja2_2.11.3-1_all.deb ...
Unpacking python3-jinja2 (2.11.3-1) ...
Selecting previously unselected package python3-pyparsing.
Preparing to unpack .../04-python3-pyparsing_2.4.7-1_all.deb ...
Unpacking python3-pyparsing (2.4.7-1) ...
Selecting previously unselected package python3-packaging.
Preparing to unpack .../05-python3-packaging_20.9-2_all.deb ...
Unpacking python3-packaging (20.9-2) ...
Selecting previously unselected package libyaml-0-2:amd64.
Preparing to unpack .../06-libyaml-0-2_0.2.2-1_amd64.deb ...
Unpacking libyaml-0-2:amd64 (0.2.2-1) ...
Selecting previously unselected package python3-yaml.
Preparing to unpack .../07-python3-yaml_5.3.1-5_amd64.deb ...
Unpacking python3-yaml (5.3.1-5) ...
Selecting previously unselected package python3-pycryptodome.
Preparing to unpack .../08-python3-pycryptodome_3.9.7+dfsg1-1+b2_amd64.deb ...
Unpacking python3-pycryptodome (3.9.7+dfsg1-1+b2) ...
Selecting previously unselected package python3-lib2to3.
Preparing to unpack .../09-python3-lib2to3_3.9.2-1_all.deb ...
Unpacking python3-lib2to3 (3.9.2-1) ...
Selecting previously unselected package python3-distutils.
Preparing to unpack .../10-python3-distutils_3.9.2-1_all.deb ...
Unpacking python3-distutils (3.9.2-1) ...
Selecting previously unselected package python3-dnspython.
Preparing to unpack .../11-python3-dnspython_2.0.0-1_all.deb ...
Unpacking python3-dnspython (2.0.0-1) ...
Selecting previously unselected package ieee-data.
Preparing to unpack .../12-ieee-data_20210605.1_all.deb ...
Unpacking ieee-data (20210605.1) ...
Selecting previously unselected package python3-netaddr.
Preparing to unpack .../13-python3-netaddr_0.7.19-5_all.deb ...
Unpacking python3-netaddr (0.7.19-5) ...
Selecting previously unselected package ansible.
Preparing to unpack .../14-ansible_2.10.7+merged+base+2.10.8+dfsg-1_all.deb ...
Unpacking ansible (2.10.7+merged+base+2.10.8+dfsg-1) ...
Selecting previously unselected package python3-argcomplete.
Preparing to unpack .../15-python3-argcomplete_1.8.1-1.5_all.deb ...
Unpacking python3-argcomplete (1.8.1-1.5) ...
Selecting previously unselected package python3-jmespath.
Preparing to unpack .../16-python3-jmespath_0.10.0-1_all.deb ...
Unpacking python3-jmespath (0.10.0-1) ...
Selecting previously unselected package python3-kerberos.
Preparing to unpack .../17-python3-kerberos_1.1.14-3.1+b3_amd64.deb ...
Unpacking python3-kerberos (1.1.14-3.1+b3) ...
Selecting previously unselected package python3-lockfile.
Preparing to unpack .../18-python3-lockfile_1%3a0.12.2-2.2_all.deb ...
Unpacking python3-lockfile (1:0.12.2-2.2) ...
Selecting previously unselected package python3-simplejson.
Preparing to unpack .../19-python3-simplejson_3.17.2-1_amd64.deb ...
Unpacking python3-simplejson (3.17.2-1) ...
Selecting previously unselected package python3-libcloud.
Preparing to unpack .../20-python3-libcloud_3.2.0-2_all.deb ...
Unpacking python3-libcloud (3.2.0-2) ...
Selecting previously unselected package python3-ntlm-auth.
Preparing to unpack .../21-python3-ntlm-auth_1.4.0-1_all.deb ...
Unpacking python3-ntlm-auth (1.4.0-1) ...
Selecting previously unselected package python3-requests-kerberos.
Preparing to unpack .../22-python3-requests-kerberos_0.12.0-2_all.deb ...
Unpacking python3-requests-kerberos (0.12.0-2) ...
Selecting previously unselected package python3-requests-ntlm.
Preparing to unpack .../23-python3-requests-ntlm_1.1.0-1.1_all.deb ...
Unpacking python3-requests-ntlm (1.1.0-1.1) ...
Selecting previously unselected package python3-requests-toolbelt.
Preparing to unpack .../24-python3-requests-toolbelt_0.9.1-1_all.deb ...
Unpacking python3-requests-toolbelt (0.9.1-1) ...
Selecting previously unselected package python3-selinux.
Preparing to unpack .../25-python3-selinux_3.1-3_amd64.deb ...
Unpacking python3-selinux (3.1-3) ...
Selecting previously unselected package python3-xmltodict.
Preparing to unpack .../26-python3-xmltodict_0.12.0-2_all.deb ...
Unpacking python3-xmltodict (0.12.0-2) ...
Selecting previously unselected package python3-winrm.
Preparing to unpack .../27-python3-winrm_0.3.0-2_all.deb ...
Unpacking python3-winrm (0.3.0-2) ...
Setting up python3-lockfile (1:0.12.2-2.2) ...
Setting up python3-requests-toolbelt (0.9.1-1) ...
Setting up libyaml-0-2:amd64 (0.2.2-1) ...
Setting up python3-ntlm-auth (1.4.0-1) ...
Setting up python3-pycryptodome (3.9.7+dfsg1-1+b2) ...
Setting up python3-kerberos (1.1.14-3.1+b3) ...
Setting up python3-yaml (5.3.1-5) ...
Setting up python3-markupsafe (1.1.1-1+b3) ...
Setting up python3-simplejson (3.17.2-1) ...
Setting up python3-xmltodict (0.12.0-2) ...
Setting up python3-jinja2 (2.11.3-1) ...
Setting up python3-pyparsing (2.4.7-1) ...
Setting up python3-jmespath (0.10.0-1) ...
Setting up ieee-data (20210605.1) ...
Setting up python3-dnspython (2.0.0-1) ...
Setting up python3-selinux (3.1-3) ...
Setting up python3-argcomplete (1.8.1-1.5) ...
Setting up python3-lib2to3 (3.9.2-1) ...
Setting up python3-cffi-backend:amd64 (1.14.5-1) ...
Setting up python3-distutils (3.9.2-1) ...
Setting up python3-packaging (20.9-2) ...
Setting up python3-cryptography (3.3.2-1) ...
Setting up python3-requests-kerberos (0.12.0-2) ...
Setting up python3-netaddr (0.7.19-5) ...
Setting up ansible (2.10.7+merged+base+2.10.8+dfsg-1) ...
Setting up python3-requests-ntlm (1.1.0-1.1) ...
Setting up python3-libcloud (3.2.0-2) ...
Setting up python3-winrm (0.3.0-2) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+deb11u2) ...
root@debian:/home/devops# ansible --version
ansible 2.10.8
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
root@debian:/home/devops# apt list | grep ansible
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
ansible-lint/stable 4.3.7-1 all
ansible-mitogen/stable 0.3.0~rc1-4 all
ansible/stable,now 2.10.7+merged+base+2.10.8+dfsg-1 all [installed]
root@debian:/home/devops# dpkg -l | grep ansible
ii  ansible                       2.10.7+merged+base+2.10.8+dfsg-1 all          Configuration management, deployment, and task execution system
root@debian:/home/devops# 

before execution

$ ssh [email protected]
Linux debian 5.10.0-9-amd64 #1 SMP Debian 5.10.70-1 (2021-09-30) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ sudo su
root@debian:/home/devops# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@debian:/home/devops# cat /etc/deb
debconf.conf    debian_version  
root@debian:/home/devops# cat /etc/debian_version 
11.1
root@debian:/home/devops# apt list ansible --installed
Listing... Done
root@debian:/home/devops# 

after execution

root@debian:/home/devops# apt list ansible --installed
Listing... Done
ansible/stable,now 2.10.7+merged+base+2.10.8+dfsg-1 all [installed]
root@debian:/home/devops# dpkg -l | grep ansible
ii  ansible                       2.10.7+merged+base+2.10.8+dfsg-1 all          Configuration management, deployment, and task execution system
root@debian:/home/devops#

code with ❤️ in GitHub

Conclusion

Now you know how to install the latest version of Ansible in Debian using the “main” repository. Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my Udemy 300+ Lessons Video Course.

BUY the Complete Udemy 300+ Lessons Video Course

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Patreon Buy me a Pizza