How to Install Ansible on Ubuntu

How to Install Ansible on Ubuntu
Ansible on Ubuntu can be installed via adding official PPA with sudo add-apt-repository --yes --update ppa:ansible/ansible, then running sudo apt install ansible. This article describes that, the difference between ansible and ansible-core packages, and pipx alternative in case apt is not your tool.
How do I install Ansible on Ubuntu using the PPA?
Adding official PPA with sudo add-apt-repository --yes --update ppa:ansible/ansible and then running sudo apt install ansible is the standard procedure for Ubuntu-based distribution in Ansible's official documentation.
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository --yes --update ppa:ansible/ansible
$ sudo apt install ansible
This exact procedure comes straight from installation guide of Ansible โ software-properties-common is the package that provides add-apt-repository command, so it should be installed first if your minimal Ubuntu image lacks it.
What's the difference between the ansible and ansible-core packages?
ansible-core is the minimalistic engine with a set of built-in modules and plugins. ansible package builds on top of ansible-core and adds large, community-curated collection of Ansible Collections.
According to the same installation guide, ansible-core is described as "a minimalist language and runtime package containing a set of built-in modules and plugins", whereas ansible is "a much larger 'batteries included' package, which adds a community-curated selection of Ansible Collections for automating a wide variety of devices."
Should I use the PPA or install Ansible with pipx instead?
PPA provides you with standard system-wide apt package. pipx is described in documentation as an alternative in case installing Ansible with pip directly is not an option on your system, providing isolation for the installation.
$ pipx install --include-deps ansible
$ pipx install ansible-core
As it is stated in the documentation, "on some systems, it may not be possible to install Ansible with pip, due to decisions made by the operating system developers. In such cases, pipx is a widely available alternative" โ pipx install --include-deps ansible gets you the full package, and pipx install ansible-core gets you just the minimalistic engine.
How do I check which version of Ansible I have installed?
Run ansible --version. It reports the version of underlying ansible-core package, regardless of which one โ full ansible or minimalistic ansible-core โ was installed.
$ ansible --version
Documentation is specific about it: version ansible --version reports "is for the associated ansible-core package that has been installed." So two different systems that report the same ansible --version output can actually have different sets of Ansible Collections installed if one has full ansible package and another one has ansible-core only.
How do I update Ansible after installing it from the PPA?
Running sudo apt update && sudo apt upgrade ansible updates the package, as usual for any apt package. Because the PPA is added, it is registered in /etc/apt/sources.list.d/, so every apt upgrade in the future would pick up the latest versions of Ansible published there.
$ sudo apt update && sudo apt upgrade ansible
There's nothing special to remember in Ansible updating process โ PPA stays registered in /etc/apt/sources.list.d/ after installation, so every apt upgrade would install the latest version of Ansible from it.
Our VPS plans and Bare Metal servers provide you with full access to apt and pipx, so working with Ansible on them is done according to these instructions, either when Ansible itself runs from them or when they are used as managed nodes.
Get started with Orbit Servers
Low-latency VPS, bare metal, and colocation across the US, EU, and APAC - provisioned instantly and built for performance-critical workloads.
Get startedRelated products
Written by
Julius