How to install Ansible in the latest Ubuntu 21.10. Today we’re going to talk about the easier way to install and maintain Ansible inside Ubuntu 21.10 with the distribution tools. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
How to install Ansible in Ubuntu 21.10
- universe
- PPA
Today we’re talking about How to install Ansible in Ubuntu 21.10? We’re going to see the easy way to install and maintain Ansible inside Ubuntu with the distribution tools. We are going to see how to install Ansible in two different ways. The first method to install Ansible is using the universe repository, the default that you get after installation. The main advantage of using the universe repository is that you don’t require any external repository. And the second method to install Ansible is using the PPA repository. Please bear in mind that adding an additional repository has a different quality assurance of software.
Playbook
Install Ansible in Ubuntu 21.10 with universe and PPA
universe code
#!/bin/bash
sudo apt update
sudo apt install ansible
universe execution
$ ssh [email protected]
The authenticity of host 'ubuntu2110.example.com (192.168.0.203)' can't be established.
ECDSA key fingerprint is SHA256:v0BXVb5/2XfPoqb/bk70pOsw0tvVh/THiqblJnCXhg4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ubuntu2110.example.com,192.168.0.203' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 21.10 (GNU/Linux 5.13.0-19-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Mon Nov 1 15:30:37 UTC 2021
System load: 0.31 Processes: 102
Usage of /: 3.2% of 38.71GB Users logged in: 0
Memory usage: 17% IPv4 address for enp0s3: 10.0.2.15
Swap usage: 0% IPv4 address for enp0s8: 192.168.0.203
0 updates can be applied immediately.
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
$ sudo su
root@ubuntu:/home/devops# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.10
Release: 21.10
Codename: impish
root@ubuntu:/home/devops# apt-get install ansible
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package ansible
root@ubuntu:/home/devops# apt-get update
Get:1 http://archive.ubuntu.com/ubuntu impish InRelease [270 kB]
Get:2 http://security.ubuntu.com/ubuntu impish-security InRelease [99.5 kB]
Get:3 http://archive.ubuntu.com/ubuntu impish-updates InRelease [108 kB]
Get:4 http://archive.ubuntu.com/ubuntu impish-backports InRelease [90.7 kB]
Get:5 http://archive.ubuntu.com/ubuntu impish/universe amd64 Packages [13.1 MB]
Get:6 http://security.ubuntu.com/ubuntu impish-security/main amd64 Packages [16.8 kB]
Get:7 http://security.ubuntu.com/ubuntu impish-security/main Translation-en [7296 B]
Get:8 http://security.ubuntu.com/ubuntu impish-security/universe amd64 Packages [9368 B]
Get:9 http://security.ubuntu.com/ubuntu impish-security/universe Translation-en [5276 B]
Get:10 http://security.ubuntu.com/ubuntu impish-security/universe amd64 c-n-f Metadata [116 B]
Get:11 http://security.ubuntu.com/ubuntu impish-security/multiverse amd64 c-n-f Metadata [116 B]
Get:12 http://archive.ubuntu.com/ubuntu impish/universe Translation-en [5463 kB]
Get:13 http://archive.ubuntu.com/ubuntu impish/universe amd64 c-n-f Metadata [279 kB]
Get:14 http://archive.ubuntu.com/ubuntu impish/multiverse amd64 Packages [209 kB]
Get:15 http://archive.ubuntu.com/ubuntu impish/multiverse Translation-en [108 kB]
Get:16 http://archive.ubuntu.com/ubuntu impish/multiverse amd64 c-n-f Metadata [8124 B]
Get:17 http://archive.ubuntu.com/ubuntu impish-updates/main amd64 Packages [75.3 kB]
Get:18 http://archive.ubuntu.com/ubuntu impish-updates/main Translation-en [23.1 kB]
Get:19 http://archive.ubuntu.com/ubuntu impish-updates/restricted amd64 Packages [18.2 kB]
Get:20 http://archive.ubuntu.com/ubuntu impish-updates/restricted Translation-en [2868 B]
Get:21 http://archive.ubuntu.com/ubuntu impish-updates/universe amd64 Packages [24.4 kB]
Get:22 http://archive.ubuntu.com/ubuntu impish-updates/universe Translation-en [10.5 kB]
Get:23 http://archive.ubuntu.com/ubuntu impish-updates/universe amd64 c-n-f Metadata [112 B]
Get:24 http://archive.ubuntu.com/ubuntu impish-updates/multiverse amd64 c-n-f Metadata [116 B]
Get:25 http://archive.ubuntu.com/ubuntu impish-backports/main amd64 c-n-f Metadata [112 B]
Get:26 http://archive.ubuntu.com/ubuntu impish-backports/restricted amd64 c-n-f Metadata [116 B]
Get:27 http://archive.ubuntu.com/ubuntu impish-backports/universe amd64 c-n-f Metadata [116 B]
Get:28 http://archive.ubuntu.com/ubuntu impish-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 19.9 MB in 5s (3738 kB/s)
Reading package lists... Done
root@ubuntu:/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 python3-argcomplete python3-dnspython python3-ecdsa python3-jmespath python3-kerberos
python3-libcloud python3-lockfile python3-netaddr python3-ntlm-auth python3-packaging
python3-pycryptodome python3-pyparsing python3-requests-kerberos python3-requests-ntlm
python3-selinux python3-winrm python3-xmltodict
Suggested packages:
cowsay sshpass python-lockfile-doc ipython3 python-netaddr-docs python-pyparsing-doc
The following NEW packages will be installed:
ansible ieee-data python3-argcomplete python3-dnspython python3-ecdsa python3-jmespath
python3-kerberos python3-libcloud python3-lockfile python3-netaddr python3-ntlm-auth
python3-packaging python3-pycryptodome python3-pyparsing python3-requests-kerberos
python3-requests-ntlm python3-selinux python3-winrm python3-xmltodict
0 upgraded, 19 newly installed, 0 to remove and 24 not upgraded.
Need to get 31.8 MB of archives.
After this operation, 276 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://archive.ubuntu.com/ubuntu impish/main amd64 python3-pyparsing all 2.4.7-1 [61.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu impish/main amd64 python3-packaging all 20.9-2 [29.9 kB]
Get:3 http://archive.ubuntu.com/ubuntu impish/main amd64 python3-pycryptodome amd64 3.9.7+dfsg1-1build3 [9939 kB]
Get:4 http://archive.ubuntu.com/ubuntu impish/main amd64 python3-dnspython all 2.0.0+really1.16.0-2ubuntu2 [96.9 kB]
Get:5 http://archive.ubuntu.com/ubuntu impish/main amd64 ieee-data all 20210605.1 [1887 kB]
Get:6 http://archive.ubuntu.com/ubuntu impish/main amd64 python3-netaddr all 0.8.0-1 [308 kB]
Get:7 http://archive.ubuntu.com/ubuntu impish/universe amd64 ansible all 2.10.7+merged+base+2.10.8+dfsg-1 [17.5 MB]
Get:8 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-argcomplete all 1.8.1-1.5 [27.2 kB]
Get:9 http://archive.ubuntu.com/ubuntu impish/main amd64 python3-ecdsa all 0.16.1-1 [82.9 kB]
Get:10 http://archive.ubuntu.com/ubuntu impish/main amd64 python3-jmespath all 0.10.0-1 [21.7 kB]
Get:11 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-kerberos amd64 1.1.14-3.1build3 [22.3 kB]
Get:12 http://archive.ubuntu.com/ubuntu impish/main amd64 python3-lockfile all 1:0.12.2-2.2 [14.6 kB]
Get:13 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-libcloud all 3.2.0-2 [1554 kB]
Get:14 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-ntlm-auth all 1.4.0-1 [20.4 kB]
Get:15 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-requests-kerberos all 0.12.0-2 [11.9 kB]
Get:16 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-requests-ntlm all 1.1.0-1.1 [6160 B]
Get:17 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-selinux amd64 3.1-3build2 [155 kB]
Get:18 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-xmltodict all 0.12.0-2 [12.6 kB]
Get:19 http://archive.ubuntu.com/ubuntu impish/universe amd64 python3-winrm all 0.3.0-2 [21.7 kB]
Fetched 31.8 MB in 7s (4814 kB/s)
Selecting previously unselected package python3-pyparsing.
(Reading database ... 61891 files and directories currently installed.)
Preparing to unpack .../00-python3-pyparsing_2.4.7-1_all.deb ...
Unpacking python3-pyparsing (2.4.7-1) ...
Selecting previously unselected package python3-packaging.
Preparing to unpack .../01-python3-packaging_20.9-2_all.deb ...
Unpacking python3-packaging (20.9-2) ...
Selecting previously unselected package python3-pycryptodome.
Preparing to unpack .../02-python3-pycryptodome_3.9.7+dfsg1-1build3_amd64.deb ...
Unpacking python3-pycryptodome (3.9.7+dfsg1-1build3) ...
Selecting previously unselected package python3-dnspython.
Preparing to unpack .../03-python3-dnspython_2.0.0+really1.16.0-2ubuntu2_all.deb ...
Unpacking python3-dnspython (2.0.0+really1.16.0-2ubuntu2) ...
Selecting previously unselected package ieee-data.
Preparing to unpack .../04-ieee-data_20210605.1_all.deb ...
Unpacking ieee-data (20210605.1) ...
Selecting previously unselected package python3-netaddr.
Preparing to unpack .../05-python3-netaddr_0.8.0-1_all.deb ...
Unpacking python3-netaddr (0.8.0-1) ...
Selecting previously unselected package ansible.
Preparing to unpack .../06-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 .../07-python3-argcomplete_1.8.1-1.5_all.deb ...
Unpacking python3-argcomplete (1.8.1-1.5) ...
Selecting previously unselected package python3-ecdsa.
Preparing to unpack .../08-python3-ecdsa_0.16.1-1_all.deb ...
Unpacking python3-ecdsa (0.16.1-1) ...
Selecting previously unselected package python3-jmespath.
Preparing to unpack .../09-python3-jmespath_0.10.0-1_all.deb ...
Unpacking python3-jmespath (0.10.0-1) ...
Selecting previously unselected package python3-kerberos.
Preparing to unpack .../10-python3-kerberos_1.1.14-3.1build3_amd64.deb ...
Unpacking python3-kerberos (1.1.14-3.1build3) ...
Selecting previously unselected package python3-lockfile.
Preparing to unpack .../11-python3-lockfile_1%3a0.12.2-2.2_all.deb ...
Unpacking python3-lockfile (1:0.12.2-2.2) ...
Selecting previously unselected package python3-libcloud.
Preparing to unpack .../12-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 .../13-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 .../14-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 .../15-python3-requests-ntlm_1.1.0-1.1_all.deb ...
Unpacking python3-requests-ntlm (1.1.0-1.1) ...
Selecting previously unselected package python3-selinux.
Preparing to unpack .../16-python3-selinux_3.1-3build2_amd64.deb ...
Unpacking python3-selinux (3.1-3build2) ...
Selecting previously unselected package python3-xmltodict.
Preparing to unpack .../17-python3-xmltodict_0.12.0-2_all.deb ...
Unpacking python3-xmltodict (0.12.0-2) ...
Selecting previously unselected package python3-winrm.
Preparing to unpack .../18-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-ntlm-auth (1.4.0-1) ...
Setting up python3-pycryptodome (3.9.7+dfsg1-1build3) ...
Setting up python3-kerberos (1.1.14-3.1build3) ...
Setting up python3-libcloud (3.2.0-2) ...
Setting up python3-ecdsa (0.16.1-1) ...
Setting up python3-xmltodict (0.12.0-2) ...
Setting up python3-pyparsing (2.4.7-1) ...
Setting up python3-jmespath (0.10.0-1) ...
Setting up python3-requests-kerberos (0.12.0-2) ...
Setting up ieee-data (20210605.1) ...
Setting up python3-dnspython (2.0.0+really1.16.0-2ubuntu2) ...
Setting up python3-selinux (3.1-3build2) ...
Setting up python3-argcomplete (1.8.1-1.5) ...
Setting up python3-requests-ntlm (1.1.0-1.1) ...
Setting up python3-packaging (20.9-2) ...
Setting up python3-netaddr (0.8.0-1) ...
Setting up python3-winrm (0.3.0-2) ...
Setting up ansible (2.10.7+merged+base+2.10.8+dfsg-1) ...
Processing triggers for man-db (2.9.4-2) ...
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
root@ubuntu:/home/devops# apt list installed ansible -a
Listing... Done
ansible/impish,now 2.10.7+merged+base+2.10.8+dfsg-1 all [installed]
root@ubuntu:/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.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
PPA code
- install-Ansible-PPA.sh
#!/bin/bash
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt remove ansible
sudo apt install ansible-base
PPA execution
#!/bin/bash
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt remove ansible
sudo apt install ansible-base
execution
root@ubuntu:/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.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
root@ubuntu:/home/devops# apt-get remove ansible
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
ieee-data libsodium23 python3-argcomplete python3-dnspython python3-ecdsa python3-jmespath
python3-kerberos python3-libcloud python3-lockfile python3-nacl python3-netaddr
python3-ntlm-auth python3-packaging python3-paramiko python3-pycryptodome python3-pyparsing
python3-requests-kerberos python3-requests-ntlm python3-resolvelib python3-selinux
python3-winrm python3-xmltodict sshpass
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
ansible
0 upgraded, 0 newly installed, 1 to remove and 24 not upgraded.
After this operation, 204 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 100734 files and directories currently installed.)
Removing ansible (2.10.7+merged+base+2.10.8+dfsg-1) ...
Processing triggers for man-db (2.9.4-2) ...
root@ubuntu:/home/devops# apt-get install software-properties-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
software-properties-common is already the newest version (0.99.13).
The following packages were automatically installed and are no longer required:
ieee-data libsodium23 python3-argcomplete python3-dnspython python3-ecdsa python3-jmespath
python3-kerberos python3-libcloud python3-lockfile python3-nacl python3-netaddr
python3-ntlm-auth python3-packaging python3-paramiko python3-pycryptodome python3-pyparsing
python3-requests-kerberos python3-requests-ntlm python3-resolvelib python3-selinux
python3-winrm python3-xmltodict sshpass
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.
root@ubuntu:/home/devops# add-apt-repository --yes --update ppa:ansible/ansible
Repository: 'deb http://ppa.launchpad.net/ansible/ansible/ubuntu/ impish main'
Description:
Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications- automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.
http://ansible.com/
More info: https://launchpad.net/~ansible/+archive/ubuntu/ansible
Adding repository.
Adding deb entry to /etc/apt/sources.list.d/ansible-ubuntu-ansible-impish.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ansible-ubuntu-ansible-impish.list
Adding key to /etc/apt/trusted.gpg.d/ansible-ubuntu-ansible.gpg with fingerprint 6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367
Get:1 http://ppa.launchpad.net/ansible/ansible/ubuntu impish InRelease [18.0 kB]
Hit:2 http://archive.ubuntu.com/ubuntu impish InRelease
Hit:3 http://archive.ubuntu.com/ubuntu impish-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu impish-backports InRelease
Get:5 http://ppa.launchpad.net/ansible/ansible/ubuntu impish/main amd64 Packages [880 B]
Get:6 http://security.ubuntu.com/ubuntu impish-security InRelease [99.5 kB]
Get:7 http://ppa.launchpad.net/ansible/ansible/ubuntu impish/main Translation-en [516 B]
Get:8 http://security.ubuntu.com/ubuntu impish-security/main amd64 Packages [16.8 kB]
Get:9 http://security.ubuntu.com/ubuntu impish-security/main Translation-en [7296 B]
Get:10 http://security.ubuntu.com/ubuntu impish-security/universe amd64 Packages [9368 B]
Get:11 http://security.ubuntu.com/ubuntu impish-security/universe Translation-en [5276 B]
Fetched 158 kB in 1s (147 kB/s)
Reading package lists... Done
root@ubuntu:/home/devops# apt-get install ansible
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
ieee-data python3-argcomplete python3-dnspython python3-ecdsa python3-jmespath python3-kerberos
python3-libcloud python3-lockfile python3-netaddr python3-ntlm-auth python3-pycryptodome
python3-requests-kerberos python3-requests-ntlm python3-selinux python3-winrm python3-xmltodict
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
ansible-core
The following NEW packages will be installed:
ansible ansible-core
0 upgraded, 2 newly installed, 0 to remove and 24 not upgraded.
Need to get 0 B/20.7 MB of archives.
After this operation, 276 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 66007 files and directories currently installed.)
Preparing to unpack .../ansible-core_2.11.6-1ppa~impish_all.deb ...
Unpacking ansible-core (2.11.6-1ppa~impish) ...
Selecting previously unselected package ansible.
Preparing to unpack .../ansible_4.7.0-1ppa~impish_all.deb ...
Unpacking ansible (4.7.0-1ppa~impish) ...
Setting up ansible-core (2.11.6-1ppa~impish) ...
Setting up ansible (4.7.0-1ppa~impish) ...
Processing triggers for man-db (2.9.4-2) ...
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
root@ubuntu:/home/devops# apt list installed ansible -a
Listing... Done
ansible/impish,now 4.7.0-1ppa~impish all [installed]
ansible/impish 2.10.7+merged+base+2.10.8+dfsg-1 all
root@ubuntu:/home/devops# ls -al /etc/apt/sources.list.d/
total 12
drwxr-xr-x 2 root root 4096 Nov 1 14:37 .
drwxr-xr-x 7 root root 4096 Oct 14 12:36 ..
-rw-r--r-- 1 root root 136 Nov 1 14:37 ansible-ubuntu-ansible-impish.list
root@ubuntu:/home/devops# cat /etc/apt/sources.list.d/ansible-ubuntu-ansible-impish.list
deb http://ppa.launchpad.net/ansible/ansible/ubuntu/ impish main
# deb-src http://ppa.launchpad.net/ansible/ansible/ubuntu/ impish main
root@ubuntu:/home/devops# ansible --version
ansible [core 2.11.6]
config file = /etc/ansible/ansible.cfg
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.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
jinja version = 2.11.3
libyaml = True
Conclusion
Now you know how to install ansible using universe and PPA repositories in Ubuntu 21.10. 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.
My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
Donate
Want to keep this project going? Please donate