Before you start installing any third party packages, make sure that current packages are up to date and that all necessary upgrades are done. It’s always best to start off with an updated and patched system for security and stability reasons.

I will perform the following before installing python or Ansible:

Type the below commands into your terminal window:

Step 1:

sudo apt update

This will show how many packages there are for updating

You can also see an itemized list of packages by running the command

Apt list – -upgradeable

sudoupdate

Step 2:

sudo apt upgrade (you will be prompted to press y to proceed)

This will update the package databases as well as upgrade these installed packages

sudoupgrade

Once we have completed the update/upgrade we can move onto installing the Python and Ansible packages.

Step 3:

sudo apt-add-repository –yes –update ppa:ansible/ansible

Depending on your install method you may need to install the (sudo apt install software-properties-common) command before.

sudoansible

Step 4:

Now that we have added the repository we can install Ansible with the below command:

sudo apt install ansible

sudoinstallansible

At this point you may wish to check if python is already installed as it may be updated already with the ansible install. To confirm if there is a version install type the following:

python3 – -version

If not installed continue to step 4:

Step 5:

sudo apt install python3.8

sudoinstallpython

Step 6:

Confirm Installs:

python3 – -version

pythonversion

ansible – -version

ansibleversion