Debian package installation
For Debian users, as you may already know, if you want to use the latest versions of a tool, you need to be running the latest stable or testing release of the Debian OS. The testing release is not recommended, but is used by some people. Because Debian is very reliable, operating system administrators tend to set up a Debian server and then forget about it for years and years, because it continues to do what it is supposed to do without a single problem. Often, administrators tend to have lots of old, stable Debian releases running. We don't recommend using these if you want to have the latest Ansible version, with all its perks, modules, and plugins, unless you do an alternative installation (with PyPI, a source installation, or via a container).
We are going to be using Debian 9 (Stretch) as it is the latest Debian stable release. Debian 9 allows you to use many Ubuntu package sources for Ansible. We can either add the DEB line to the source.list file or add the Personal Package Archives (PPA) to the list. First, we need to install the software properties package:
sudo apt-get install -y software-properties-common
We then use a text editor and add the following DEB to /etc/apt/source.list:
deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main
Then authenticate the link by adding its key to apt:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
Usually, adding a repository requires you to update the package manager cache:
sudo apt update
Then we can install Ansible:
sudo apt install -y ansible