Happy new year!

Ansible is an open source configuration management tool written in python that I find quite useful for automating manual system administration tasks. Below is a How-To on installing it on Ubuntu or any similar debian based linux distro e.g Pop OS. I will be installing Ansible version 4.9.0, which is the latest version at the time of writing.

Add the Ansible Ubuntu PPA

sudo add-apt-repository ppa:ansible/ansible

Output:

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.
Press [ENTER] to continue or Ctrl-c to cancel.

Once you select enter, the PPA’s GPG keys will be added to your system, and your local apt cache will be automatically updated.

Install Ansible

sudo apt install ansible

Unfortunately after running the above command I encountered this error:

Unpacking ansible-core (2.11.7-1ppa~impish) ...
dpkg: error processing archive /tmp/apt-dpkg-install-3dggwb/4-ansible-core_2.11.7-1ppa~impish_all.deb (--unpack
):
 trying to overwrite '/usr/bin/ansible', which is also in package ansible 2.10.7+merged+base+2.10.8+dfsg-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../5-ansible_4.9.0-1ppa~impish_all.deb ...
Unpacking ansible (4.9.0-1ppa~impish) over (2.10.7+merged+base+2.10.8+dfsg-1) ...
Errors were encountered while processing:
 /tmp/apt-dpkg-install-3dggwb/4-ansible-core_2.11.7-1ppa~impish_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

For some reason, the apt utility crashed on my system while extracting the newly downloaded ansible version. I had an older version previously installed.

To fix it I did:

sudo apt --fix-broken install 

Output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  ieee-data python3-argcomplete python3-jmespath python3-kerberos python3-libcloud python3-lockfile
  python3-netaddr python3-ntlm-auth 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-core
0 upgraded, 1 newly installed, 0 to remove and 28 not upgraded.
5 not fully installed or removed.
Need to get 0 B/938 kB of archives.
After this operation, 5,738 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 445944 files and directories currently installed.)
Preparing to unpack .../ansible-core_2.11.7-1ppa~impish_all.deb ...
Unpacking ansible-core (2.11.7-1ppa~impish) ...
Setting up python3-bcrypt (3.1.7-4) ...
Setting up python3-resolvelib (0.5.4-1) ...
Setting up sshpass (1.09-1) ...
Setting up python3-paramiko (2.7.2-1ubuntu1) ...
Setting up ansible-core (2.11.7-1ppa~impish) ...
Setting up ansible (4.9.0-1ppa~impish) ...
Processing triggers for man-db (2.9.4-2) ...

Looks like ansible installed successfully.

Confim that both Ansible and Ansible Vault are installed correctly

Ansible vault is a utility that comes pre-packaged with ansible, and is used for managing secrets and credentials that are required by ansible playbooks.

ansible --version

Output:

ansible [core 2.11.7] 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/isaiah/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/isaiah/.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
ansible-vault --version

Output:

ansible-vault [core 2.11.7] 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/isaiah/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/isaiah/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-vault
  python version = 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
  jinja version = 2.11.3
  libyaml = True

If your outputs are similar to the ones above, then your ansible installation was a success.