There are many ways to install Ansible or the latest ansible-core on a particular host, but to learn and start using Ansible as configuration management or as an automation tool, preferably you will need a Linux host that will be your control node. The control node could be any popular Linux distribution available or any Unix-like OS like macOS or Solaris. I will review the installation process using Ubuntu 20.04 and probably the two fastest ways to install Ansible, first using apt which is the default Ubuntu package manager, and using pip, the Python package manager. By the way, you can also use Ansible to install Ansible on a managed node too. If you prefer simplicity and regular software updates regarding the Ansible software you can choose the apt route, but if your want the latest and greatest version of Ansible software on your system pip is the way.
Install using apt
To install Ansible via apt open your terminal and type the following commands:
First, download package information from all configured sources and optionally install the available upgrades.
$ sudo apt update
$ sudo apt upgrade -y
Second, before installing you can check which version of Ansible is available on your configured sources.
$ sudo apt search ansible
Then if you want to proceed with the available Ansible version go ahead and install Ansible.
$ sudo apt install ansible
Finally, check your Ansible installed version.
$ ansible --version
Later on, if you want to remove the Ansible packages and also remove packages that are no longer required use the following commands.
$ sudo apt remove ansible-base
$ sudo apt autoremove
$ sudo apt autoclean
Install using pip
Next to install Ansible via pip lets first install pip
For this particular task let’s use the friendly apt command.
$ sudo apt install python3-pip
Next, we will use the actual Python package manager (pip3) to install Ansible.
$ pip install ansible
After installation, you will need to log out and log in back into your system so Ansible is added to your environment path.
Now check your version of Ansible.
$ ansible --version
Enjoy Ansible, happy provisioning, and configuration management.