Get Complete setup for how to install ansible on ubuntu 18.04, 19.04,20.04, 21.04, 22.04
Not taking your time just go to installation steps
Step 1 Remove older packages
sudo apt remove ansible -ysudo apt-get -y autoremove
Step 2 Get software properties and update
sudo apt -y install software-properties-common sudo apt install software-properties-common sudo apt update -y
Step 3 Finally, install the latest version of Ansible on Ubuntu
sudo apt install ansible -y