How to install Ansible in the latest Ubuntu 22.04.
Today we’re going to talk about the easier way to install and maintain Ansible inside Ubuntu 22.04 with the distribution tools. I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
How to install Ansible in Ubuntu 22.04
- universe
- PPA
Today we’re talking about how to install Ansible in Ubuntu 22.04 LTS Jammy Jellyfish. 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.
See also: Ansible terminology - ansible vs ansible-core packages.
Links
Playbook
How to install Ansible in Ubuntu 22.04 LTS Jammy Jellyfish with universe and PPA repositories.
universe
- code
#!/bin/bash
sudo apt update
sudo apt install ansible
- execution
$ ssh [email protected]
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-25-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Mon May 2 13:59:01 UTC 2022
System load: 0.07861328125 Processes: 96
Usage of /: 7.1% of 39.86GB Users logged in: 0
Memory usage: 22% IPv4 address for enp0s3: 10.0.2.15
Swap usage: 0% IPv4 address for enp0s8: 192.168.43.7
20 updates can be applied immediately.
16 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Last login: Mon May 2 13:50:17 2022 from 192.168.43.5
$ sudo su
root@ubuntu:/home/devops# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
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-jmespath python3-kerberos
python3-libcloud python3-lockfile python3-netaddr python3-ntlm-auth python3-packaging
python3-pycryptodome python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt
python3-selinux python3-simplejson python3-winrm python3-xmltodict
Suggested packages:
cowsay sshpass python3-sniffio python3-trio python-lockfile-doc ipython3 python-netaddr-docs
The following NEW packages will be installed:
ansible ieee-data python3-argcomplete python3-dnspython python3-jmespath python3-kerberos
python3-libcloud python3-lockfile python3-netaddr python3-ntlm-auth python3-packaging
python3-pycryptodome python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt
python3-selinux python3-simplejson python3-winrm python3-xmltodict
0 upgraded, 19 newly installed, 0 to remove and 16 not upgraded.
Need to get 17.5 MB/22.9 MB of archives.
After this operation, 243 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy/universe amd64 ansible all 2.10.7+merged+base+2.10.8+dfsg-1 [17.5 MB]
Fetched 11.6 MB in 6s (1825 kB/s)
Selecting previously unselected package python3-packaging.
(Reading database ... 63837 files and directories currently installed.)
Preparing to unpack .../00-python3-packaging_21.3-1_all.deb ...
Unpacking python3-packaging (21.3-1) ...
Selecting previously unselected package python3-pycryptodome.
Preparing to unpack .../01-python3-pycryptodome_3.11.0+dfsg1-3build1_amd64.deb ...
Unpacking python3-pycryptodome (3.11.0+dfsg1-3build1) ...
Selecting previously unselected package python3-dnspython.
Preparing to unpack .../02-python3-dnspython_2.1.0-1ubuntu1_all.deb ...
Unpacking python3-dnspython (2.1.0-1ubuntu1) ...
Selecting previously unselected package ieee-data.
Preparing to unpack .../03-ieee-data_20210605.1_all.deb ...
Unpacking ieee-data (20210605.1) ...
Selecting previously unselected package python3-netaddr.
Preparing to unpack .../04-python3-netaddr_0.8.0-2_all.deb ...
Unpacking python3-netaddr (0.8.0-2) ...
Selecting previously unselected package ansible.
Preparing to unpack .../05-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 .../06-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 .../07-python3-jmespath_0.10.0-1_all.deb ...
Unpacking python3-jmespath (0.10.0-1) ...
Selecting previously unselected package python3-kerberos.
Preparing to unpack .../08-python3-kerberos_1.1.14-3.1build5_amd64.deb ...
Unpacking python3-kerberos (1.1.14-3.1build5) ...
Selecting previously unselected package python3-lockfile.
Preparing to unpack .../09-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 .../10-python3-simplejson_3.17.6-1build1_amd64.deb ...
Unpacking python3-simplejson (3.17.6-1build1) ...
Selecting previously unselected package python3-libcloud.
Preparing to unpack .../11-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 .../12-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 .../13-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 .../14-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 .../15-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 .../16-python3-selinux_3.3-1build2_amd64.deb ...
Unpacking python3-selinux (3.3-1build2) ...
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-requests-toolbelt (0.9.1-1) ...
Setting up python3-ntlm-auth (1.4.0-1) ...
Setting up python3-pycryptodome (3.11.0+dfsg1-3build1) ...
Setting up python3-kerberos (1.1.14-3.1build5) ...
Setting up python3-simplejson (3.17.6-1build1) ...
Setting up python3-xmltodict (0.12.0-2) ...
Setting up python3-packaging (21.3-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.1.0-1ubuntu1) ...
Setting up python3-selinux (3.3-1build2) ...
Setting up python3-argcomplete (1.8.1-1.5) ...
Setting up python3-requests-ntlm (1.1.0-1.1) ...
Setting up python3-libcloud (3.2.0-2) ...
Setting up python3-netaddr (0.8.0-2) ...
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.10.2-1) ...
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.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
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.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0]
root@ubuntu:/home/devops#
PPA
- code
#!/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-core
- execution
root@ubuntu:/home/devops# apt update
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
16 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@ubuntu:/home/devops# apt 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.22).
software-properties-common set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
root@ubuntu:/home/devops# add-apt-repository --yes --update ppa:ansible/ansible
Repository: 'deb https://ppa.launchpadcontent.net/ansible/ansible/ubuntu/ jammy 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-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/ansible-ubuntu-ansible-jammy.list
Adding key to /etc/apt/trusted.gpg.d/ansible-ubuntu-ansible.gpg with fingerprint 6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
Get:5 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu jammy InRelease [18.0 kB]
Get:6 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu jammy/main amd64 Packages [1128 B]
Get:7 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu jammy/main Translation-en [756 B]
Fetched 19.9 kB in 1s (15.3 kB/s)
Reading package lists... Done
root@ubuntu:/home/devops# apt 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 python3-argcomplete python3-dnspython python3-jmespath python3-kerberos
python3-libcloud python3-lockfile python3-netaddr python3-ntlm-auth python3-packaging
python3-pycryptodome python3-requests-kerberos python3-requests-ntlm python3-requests-toolbelt
python3-selinux python3-simplejson python3-winrm python3-xmltodict
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
ansible
0 upgraded, 0 newly installed, 1 to remove and 16 not upgraded.
After this operation, 204 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 102295 files and directories currently installed.)
Removing ansible (2.10.7+merged+base+2.10.8+dfsg-1) ...
Processing triggers for man-db (2.10.2-1) ...
root@ubuntu:/home/devops# apt 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-libcloud python3-lockfile
python3-netaddr python3-pycryptodome python3-requests-toolbelt python3-selinux
python3-simplejson
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
ansible-core python3-nacl python3-paramiko python3-resolvelib sshpass
Suggested packages:
python-nacl-doc python3-gssapi python3-invoke
The following NEW packages will be installed:
ansible ansible-core python3-nacl python3-paramiko python3-resolvelib sshpass
0 upgraded, 6 newly installed, 0 to remove and 16 not upgraded.
Need to get 21.0 MB/21.1 MB of archives.
After this operation, 304 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu jammy/main amd64 ansible-core all 2.12.4-1ppa~jammy [954 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 python3-nacl amd64 1.5.0-2 [63.1 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 python3-paramiko all 2.9.3-0ubuntu1 [133 kB]
Get:4 https://ppa.launchpadcontent.net/ansible/ansible/ubuntu jammy/main amd64 ansible all 5.6.0-1ppa~jammy [19.9 MB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/universe amd64 sshpass amd64 1.09-1 [11.7 kB]
Fetched 21.0 MB in 8s (2587 kB/s)
Selecting previously unselected package python3-resolvelib.
(Reading database ... 67568 files and directories currently installed.)
Preparing to unpack .../0-python3-resolvelib_0.8.1-1_all.deb ...
Unpacking python3-resolvelib (0.8.1-1) ...
Selecting previously unselected package ansible-core.
Preparing to unpack .../1-ansible-core_2.12.4-1ppa~jammy_all.deb ...
Unpacking ansible-core (2.12.4-1ppa~jammy) ...
Selecting previously unselected package ansible.
Preparing to unpack .../2-ansible_5.6.0-1ppa~jammy_all.deb ...
Unpacking ansible (5.6.0-1ppa~jammy) ...
Selecting previously unselected package python3-nacl.
Preparing to unpack .../3-python3-nacl_1.5.0-2_amd64.deb ...
Unpacking python3-nacl (1.5.0-2) ...
Selecting previously unselected package python3-paramiko.
Preparing to unpack .../4-python3-paramiko_2.9.3-0ubuntu1_all.deb ...
Unpacking python3-paramiko (2.9.3-0ubuntu1) ...
Selecting previously unselected package sshpass.
Preparing to unpack .../5-sshpass_1.09-1_amd64.deb ...
Unpacking sshpass (1.09-1) ...
Setting up python3-resolvelib (0.8.1-1) ...
Setting up ansible-core (2.12.4-1ppa~jammy) ...
Setting up sshpass (1.09-1) ...
Setting up ansible (5.6.0-1ppa~jammy) ...
Setting up python3-nacl (1.5.0-2) ...
Setting up python3-paramiko (2.9.3-0ubuntu1) ...
Processing triggers for man-db (2.10.2-1) ...
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.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
root@ubuntu:/home/devops# ansible --version
ansible [core 2.12.4]
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.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0]
jinja version = 3.0.3
libyaml = True
root@ubuntu:/home/devops#
Conclusion
Now you know how to install ansible using universe and PPA repositories in Ubuntu 22.04 LTS Jammy Jellyfish. 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