Update Ansible on Ubuntu

In a previous tutorial, I explained how to install and use Ansible to execute automatic actions on your Windows and Linux servers.

Like all applications, Ansible is regularly updated and so to enjoy the latest features and bug fixes, you should also update Ansible.

The “problem” when you go through the official repositories of distributions is that you rarely have the latest versions of software available and this is valid for Ansible.

Ansible using Python, we will use pip to check if our version is up to date, to do this use the command below:

sudo pip list --outdated 

As we can see from the screenshot above, the installed version of Ansible is version 4.1.0 and version 5.6.0 is available, we also see that ansible-core is not up to date.

Before doing the update, I advise you to make a backup of your server, if you are on a virtual machine, a snapshot should do the trick.

Another precaution you can take is to save the list of Python modules and their version with the following command:

sudo pip list > file-name.txt

Now we can move on to updating Ansible, to update Ansible, we will use pip, enter the command below:

sudo pip install "ansible" --upgrade

Wait while Ansible and ansible-core update.

Once the update is complete, enter the command again: sudo pip list –outdated, ansible and ansible-core should no longer be in the list.

Before deleting the snapshot if you are on a VM or the backup, I advise you to test the proper functioning of Ansible, especially if you use it with Windows at the winrm level.

For this, you can use the playbook if below:

Which gives us :

ansible-playbook /folder/playbook/playbook-file.yml -i /foler/inventory-file -v

You can also use this command to use win_ping:

ansible all -i /foler/inventory-file -f 30 -m win_ping

Once everything is good, delete the snapshot.

Regarding the other python modules, if everything works, I do not advise you to update, especially what affects WinRM, I tried to update them all and the connection was no longer possible on the 2012R2 servers and lower.




Leave a Comment