Ansible Pilot

How to install Ansible in Debian 12 bookworm — Ansible install

The easier way to install the latest version of Ansible and maintain up-to-date in Debian 12 using APT and the "main" default repository.

October 3, 2023
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

How to install Ansible in Debian version 12?

Today we’re going to talk about the easier way to install and maintain Ansible inside Debian using the default “main” repository.

How to install Ansible in Debian

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.

The Best Resources For Ansible

Certifications

Video Course

Printed Book

eBooks

Step-by-step

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

code

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

execution

$ ssh [email protected]
$ sudo su
root@debian:/home/devops# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# cat /etc/debian_version 
12.1
# apt-get update
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://security.debian.org/debian-security bookworm-security InRelease
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
Fetched 52.1 kB in 0s (152 kB/s)    
Reading package lists... Done
# apt-cache search ansible
ansible - Configuration management, deployment, and task execution system
ansible-core - Configuration management, deployment, and task execution system
ansible-lint - lint tool for Ansible playbooks
python-ansible-runner-doc - library that interfaces with Ansible (docs)
python3-ansible-runner - library that interfaces with Ansible (Python 3.x)
podman-toolbox - unprivileged development environment using containers
python-network-runner-doc - abstraction of Ansible for interaction with networking devices (docs)
python3-network-runner - abstraction of Ansible for interaction with networking devices (Python 3.x)
python3-ansible-compat - Ansible compatibility goodies
python3-ansible-pygments - pygments lexer and style Ansible snippets
ara-client - ARA Records Ansible - Client
ara-server - ARA Records Ansible - Server
python-ara-doc - ARA Records Ansible - doc
python3-ara - ARA Records Ansible
ansible-mitogen - Fast connection strategy for Ansible
python3-reclass - hierarchical inventory backend for configuration management systems
reclass - hierarchical inventory backend for configuration management systems
reclass-doc - reclass documentation
ssg-applications - SCAP Guides and benchmarks targeting userspace applications
ssg-debderived - SCAP Guides and benchmarks targeting Debian-based OS
ssg-debian - SCAP Guides and benchmarks targeting Debian releases
ssg-nondebian - SCAP Guides and benchmarks targeting other GNU/Linux OS
vim-syntastic - Syntax checking hacks for vim
# apt-cache show ansible
Package: ansible
Version: 7.3.0+dfsg-1
Installed-Size: 204261
Maintainer: Lee Garrett <[email protected]>
Architecture: all
Replaces: ansible-base (<= 2.10.5+dfsg-2)
Depends: ansible-core (>= 2.11.5-1~), python3:any, openssh-client | python3-paramiko (>= 2.6.0), python3-distutils, python3-dnspython, python3-httplib2, python3-jinja2, python3-netaddr, python3-yaml
Recommends: python3-argcomplete, python3-cryptography, 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 the ansible collections.
Description-md5: 4f8f35d982ca2a9d6d35c1bb2053b0e1
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_7.3.0+dfsg-1_all.deb
Size: 16253908
MD5sum: 7b1b2cdc2cf66175fffc569031b7be49
SHA256: 14366f29001c3328e5025f862a301dd73f5ce3414a829ed2a5698456b6bee23e
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:
  ansible-core ieee-data libyaml-0-2 python-babel-localedata python3-anyio python3-argcomplete
  python3-babel python3-click python3-colorama python3-distutils python3-dnspython python3-h11 python3-h2
  python3-hpack python3-httpcore python3-httpx python3-hyperframe python3-jinja2 python3-jmespath
  python3-kerberos python3-lib2to3 python3-libcloud python3-lockfile python3-markdown-it
  python3-markupsafe python3-mdurl python3-netaddr python3-ntlm-auth python3-packaging
  python3-pycryptodome python3-pygments python3-requests-kerberos python3-requests-ntlm
  python3-requests-toolbelt python3-resolvelib python3-rfc3986 python3-rich python3-selinux
  python3-simplejson python3-sniffio python3-tz python3-winrm python3-xmltodict python3-yaml
Suggested packages:
  cowsay sshpass python3-trio python3-aioquic python-jinja2-doc python-lockfile-doc ipython3
  python-netaddr-docs python-pygments-doc ttf-bitstream-vera
The following NEW packages will be installed:
  ansible ansible-core ieee-data libyaml-0-2 python-babel-localedata python3-anyio python3-argcomplete
  python3-babel python3-click python3-colorama python3-distutils python3-dnspython python3-h11 python3-h2
  python3-hpack python3-httpcore python3-httpx python3-hyperframe python3-jinja2 python3-jmespath
  python3-kerberos python3-lib2to3 python3-libcloud python3-lockfile python3-markdown-it
  python3-markupsafe python3-mdurl python3-netaddr python3-ntlm-auth python3-packaging
  python3-pycryptodome python3-pygments python3-requests-kerberos python3-requests-ntlm
  python3-requests-toolbelt python3-resolvelib python3-rfc3986 python3-rich python3-selinux
  python3-simplejson python3-sniffio python3-tz python3-winrm python3-xmltodict python3-yaml
0 upgraded, 45 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/30.1 MB of archives.
After this operation, 290 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Extracting templates from packages: 100%
Selecting previously unselected package python3-markupsafe.
(Reading database ... 33954 files and directories currently installed.)
Preparing to unpack .../00-python3-markupsafe_2.1.2-1+b1_arm64.deb ...
Unpacking python3-markupsafe (2.1.2-1+b1) ...
Selecting previously unselected package python3-jinja2.
Preparing to unpack .../01-python3-jinja2_3.1.2-1_all.deb ...
Unpacking python3-jinja2 (3.1.2-1) ...
Selecting previously unselected package python3-packaging.
Preparing to unpack .../02-python3-packaging_23.0-1_all.deb ...
Unpacking python3-packaging (23.0-1) ...
Selecting previously unselected package python3-resolvelib.
Preparing to unpack .../03-python3-resolvelib_0.9.0-2_all.deb ...
Unpacking python3-resolvelib (0.9.0-2) ...
Selecting previously unselected package libyaml-0-2:arm64.
Preparing to unpack .../04-libyaml-0-2_0.2.5-1_arm64.deb ...
Unpacking libyaml-0-2:arm64 (0.2.5-1) ...
Selecting previously unselected package python3-yaml.
Preparing to unpack .../05-python3-yaml_6.0-3+b2_arm64.deb ...
Unpacking python3-yaml (6.0-3+b2) ...
Selecting previously unselected package python3-pycryptodome.
Preparing to unpack .../06-python3-pycryptodome_3.11.0+dfsg1-4_arm64.deb ...
Unpacking python3-pycryptodome (3.11.0+dfsg1-4) ...
Selecting previously unselected package python3-lib2to3.
Preparing to unpack .../07-python3-lib2to3_3.11.2-3_all.deb ...
Unpacking python3-lib2to3 (3.11.2-3) ...
Selecting previously unselected package python3-distutils.
Preparing to unpack .../08-python3-distutils_3.11.2-3_all.deb ...
Unpacking python3-distutils (3.11.2-3) ...
Selecting previously unselected package python3-dnspython.
Preparing to unpack .../09-python3-dnspython_2.3.0-1_all.deb ...
Unpacking python3-dnspython (2.3.0-1) ...
Selecting previously unselected package ieee-data.
Preparing to unpack .../10-ieee-data_20220827.1_all.deb ...
Unpacking ieee-data (20220827.1) ...
Selecting previously unselected package python3-netaddr.
Preparing to unpack .../11-python3-netaddr_0.8.0-2_all.deb ...
Unpacking python3-netaddr (0.8.0-2) ...
Selecting previously unselected package ansible-core.
Preparing to unpack .../12-ansible-core_2.14.3-1_all.deb ...
Unpacking ansible-core (2.14.3-1) ...
Selecting previously unselected package ansible.
Preparing to unpack .../13-ansible_7.3.0+dfsg-1_all.deb ...
Unpacking ansible (7.3.0+dfsg-1) ...
Selecting previously unselected package python-babel-localedata.
Preparing to unpack .../14-python-babel-localedata_2.10.3-1_all.deb ...
Unpacking python-babel-localedata (2.10.3-1) ...
Selecting previously unselected package python3-sniffio.
Preparing to unpack .../15-python3-sniffio_1.2.0-1_all.deb ...
Unpacking python3-sniffio (1.2.0-1) ...
Selecting previously unselected package python3-anyio.
Preparing to unpack .../16-python3-anyio_3.6.2-1_all.deb ...
Unpacking python3-anyio (3.6.2-1) ...
Selecting previously unselected package python3-argcomplete.
Preparing to unpack .../17-python3-argcomplete_2.0.0-1_all.deb ...
Unpacking python3-argcomplete (2.0.0-1) ...
Selecting previously unselected package python3-tz.
Preparing to unpack .../18-python3-tz_2022.7.1-4_all.deb ...
Unpacking python3-tz (2022.7.1-4) ...
Selecting previously unselected package python3-babel.
Preparing to unpack .../19-python3-babel_2.10.3-1_all.deb ...
Unpacking python3-babel (2.10.3-1) ...
Selecting previously unselected package python3-colorama.
Preparing to unpack .../20-python3-colorama_0.4.6-2_all.deb ...
Unpacking python3-colorama (0.4.6-2) ...
Selecting previously unselected package python3-click.
Preparing to unpack .../21-python3-click_8.1.3-2_all.deb ...
Unpacking python3-click (8.1.3-2) ...
Selecting previously unselected package python3-h11.
Preparing to unpack .../22-python3-h11_0.14.0-1_all.deb ...
Unpacking python3-h11 (0.14.0-1) ...
Selecting previously unselected package python3-hpack.
Preparing to unpack .../23-python3-hpack_4.0.0-2_all.deb ...
Unpacking python3-hpack (4.0.0-2) ...
Selecting previously unselected package python3-hyperframe.
Preparing to unpack .../24-python3-hyperframe_6.0.0-1_all.deb ...
Unpacking python3-hyperframe (6.0.0-1) ...
Selecting previously unselected package python3-h2.
Preparing to unpack .../25-python3-h2_4.1.0-4_all.deb ...
Unpacking python3-h2 (4.1.0-4) ...
Selecting previously unselected package python3-httpcore.
Preparing to unpack .../26-python3-httpcore_0.16.3-1_all.deb ...
Unpacking python3-httpcore (0.16.3-1) ...
Selecting previously unselected package python3-pygments.
Preparing to unpack .../27-python3-pygments_2.14.0+dfsg-1_all.deb ...
Unpacking python3-pygments (2.14.0+dfsg-1) ...
Selecting previously unselected package python3-mdurl.
Preparing to unpack .../28-python3-mdurl_0.1.2-1_all.deb ...
Unpacking python3-mdurl (0.1.2-1) ...
Selecting previously unselected package python3-markdown-it.
Preparing to unpack .../29-python3-markdown-it_2.1.0-5_all.deb ...
Unpacking python3-markdown-it (2.1.0-5) ...
Selecting previously unselected package python3-rich.
Preparing to unpack .../30-python3-rich_13.3.1-1_all.deb ...
Unpacking python3-rich (13.3.1-1) ...
Selecting previously unselected package python3-rfc3986.
Preparing to unpack .../31-python3-rfc3986_1.5.0-2_all.deb ...
Unpacking python3-rfc3986 (1.5.0-2) ...
Selecting previously unselected package python3-httpx.
Preparing to unpack .../32-python3-httpx_0.23.3-1_all.deb ...
Unpacking python3-httpx (0.23.3-1) ...
Selecting previously unselected package python3-jmespath.
Preparing to unpack .../33-python3-jmespath_1.0.1-1_all.deb ...
Unpacking python3-jmespath (1.0.1-1) ...
Selecting previously unselected package python3-kerberos.
Preparing to unpack .../34-python3-kerberos_1.1.14-3.1+b7_arm64.deb ...
Unpacking python3-kerberos (1.1.14-3.1+b7) ...
Selecting previously unselected package python3-lockfile.
Preparing to unpack .../35-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 .../36-python3-simplejson_3.18.3-1_arm64.deb ...
Unpacking python3-simplejson (3.18.3-1) ...
Selecting previously unselected package python3-libcloud.
Preparing to unpack .../37-python3-libcloud_3.4.1-5_all.deb ...
Unpacking python3-libcloud (3.4.1-5) ...
Selecting previously unselected package python3-ntlm-auth.
Preparing to unpack .../38-python3-ntlm-auth_1.4.0-2_all.deb ...
Unpacking python3-ntlm-auth (1.4.0-2) ...
Selecting previously unselected package python3-requests-kerberos.
Preparing to unpack .../39-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 .../40-python3-requests-ntlm_1.1.0-3_all.deb ...
Unpacking python3-requests-ntlm (1.1.0-3) ...
Selecting previously unselected package python3-requests-toolbelt.
Preparing to unpack .../41-python3-requests-toolbelt_0.10.1-1_all.deb ...
Unpacking python3-requests-toolbelt (0.10.1-1) ...
Selecting previously unselected package python3-selinux.
Preparing to unpack .../42-python3-selinux_3.4-1+b6_arm64.deb ...
Unpacking python3-selinux (3.4-1+b6) ...
Selecting previously unselected package python3-xmltodict.
Preparing to unpack .../43-python3-xmltodict_0.13.0-1_all.deb ...
Unpacking python3-xmltodict (0.13.0-1) ...
Selecting previously unselected package python3-winrm.
Preparing to unpack .../44-python3-winrm_0.3.0-4_all.deb ...
Unpacking python3-winrm (0.3.0-4) ...
Setting up python3-sniffio (1.2.0-1) ...
Setting up python3-lockfile (1:0.12.2-2.2) ...
Setting up python3-requests-toolbelt (0.10.1-1) ...
Setting up python3-anyio (3.6.2-1) ...
Setting up python3-hyperframe (6.0.0-1) ...
Setting up python3-hpack (4.0.0-2) ...
Setting up python3-colorama (0.4.6-2) ...
Setting up libyaml-0-2:arm64 (0.2.5-1) ...
Setting up python3-ntlm-auth (1.4.0-2) ...
Setting up python3-pycryptodome (3.11.0+dfsg1-4) ...
Setting up python3-resolvelib (0.9.0-2) ...
Setting up python3-kerberos (1.1.14-3.1+b7) ...
Setting up python3-yaml (6.0-3+b2) ...
Setting up python3-click (8.1.3-2) ...
Setting up python3-markupsafe (2.1.2-1+b1) ...
Setting up python3-tz (2022.7.1-4) ...
Setting up python-babel-localedata (2.10.3-1) ...
Setting up python3-simplejson (3.18.3-1) ...
Setting up python3-xmltodict (0.13.0-1) ...
Setting up python3-jinja2 (3.1.2-1) ...
Setting up python3-pygments (2.14.0+dfsg-1) ...
Setting up python3-packaging (23.0-1) ...
Setting up python3-rfc3986 (1.5.0-2) ...
Setting up python3-jmespath (1.0.1-1) ...
Setting up python3-mdurl (0.1.2-1) ...
Setting up python3-h11 (0.14.0-1) ...
Setting up python3-markdown-it (2.1.0-5) ...
Setting up python3-requests-kerberos (0.12.0-2) ...
Setting up ieee-data (20220827.1) ...
Setting up python3-dnspython (2.3.0-1) ...
Setting up python3-selinux (3.4-1+b6) ...
Setting up python3-h2 (4.1.0-4) ...
Setting up python3-argcomplete (2.0.0-1) ...
Setting up python3-lib2to3 (3.11.2-3) ...
Setting up python3-distutils (3.11.2-3) ...
Setting up python3-httpcore (0.16.3-1) ...
Setting up python3-requests-ntlm (1.1.0-3) ...
Setting up python3-babel (2.10.3-1) ...
update-alternatives: using /usr/bin/pybabel-python3 to provide /usr/bin/pybabel (pybabel) in auto mode
Setting up python3-rich (13.3.1-1) ...
Setting up python3-libcloud (3.4.1-5) ...
Setting up python3-httpx (0.23.3-1) ...
Setting up python3-netaddr (0.8.0-2) ...
Setting up python3-winrm (0.3.0-4) ...
Setting up ansible-core (2.14.3-1) ...
Setting up ansible (7.3.0+dfsg-1) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for libc-bin (2.36-9+deb12u1) ...
root@debian:/home/devops# ansible --version
ansible [core 2.14.3]
  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
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
root@debian:/home/devops# apt list | grep ansible

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

ansible-core/stable,now 2.14.3-1 all [installed,automatic]
ansible-lint/stable 6.13.1-1 all
ansible-mitogen/stable 0.3.3-9 all
ansible/stable,now 7.3.0+dfsg-1 all [installed]
python-ansible-runner-doc/stable 2.3.1-2 all
python3-ansible-compat/stable 3.0.1-1 all
python3-ansible-pygments/stable 0.1.1-5 all
python3-ansible-runner/stable 2.3.1-2 all
root@debian:/home/devops# dpkg -l | grep ansible
ii  ansible                      7.3.0+dfsg-1                   all          Configuration management, deployment, and task execution system
ii  ansible-core                 2.14.3-1                       all          Configuration management, deployment, and task execution system          Configuration management, deployment, and task execution system
root@debian:/home/devops#

before execution

$ ssh [email protected]
$ sudo su
root@debian:/home/devops# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
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/debian_version 
12.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 7.3.0+dfsg-1 all [installed]
root@debian:/home/devops# dpkg -l | grep ansible
ii  ansible                      7.3.0+dfsg-1                   all          Configuration management, deployment, and task execution system
ii  ansible-core                 2.14.3-1                       all          Configuration management, deployment, and task execution system

Recap

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

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

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Follow me

Subscribe not to miss any new releases