Ansible Quick Start Guide
上QQ阅读APP看书,第一时间看更新

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
A faster way to add a DEB line at the end of the source file is as follows: echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/source.list

Then authenticate the link by adding its key to apt:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
For the latest Debian release, the PPA repository can be used directly  as well, by adding the link to the APT repository: sudo apt-add-repository ppa:ansible/ansible

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

Most of the tutorials in further chapters are  carried out on Debian 8 (Jessie) with Ansible installed and updated using Python PyPI. This is just as stable, up to date, and reliable as any other standard way of installing Ansible on an operating system's latest release.