How to upgrade Ansible to 2.1 on Debian 8.4

An updated article for upgrading to Ansible 2.2.1 on Debian 8.7 is available at

Upgrading to Ansible 2.1 on Debian (validated on version 8.4) requires some pre-requisites to be in place, below are the steps required to upgrade.

Ensure that sudo is installed (skip this step if you already know that it is):

apt-get install sudo

Upgrade all packages:

sudo apt-get update
sudo apt-get upgrade

Install build pre-requisites:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Upgrade to the latest version of the Cryptography module:

sudo pip install cryptography --upgrade

If you encounter errors with the above command, run the following to reinstall PIP from the official PIP website as referred to at

sudo apt-get purge -y python-pip
sudo wget
sudo python ./
sudo apt-get install python-pip

Finally, upgrade Ansible to the latest version:

sudo pip install ansible --upgrade
  • Pat


    On Debian 8.7, I had the folowing error while making “pip install cryptography –upgrade”

    ImportError: No module named setuptools_ext

    Rolling back uninstall of cryptography
    Cleaning up…

    I’ve done this : “pip install -U cffi”

    And launched again the : “pip install cryptography –upgrade”
    And ansible has been succesfully upgraded to 2.2.1 on Debian 8.7.

    • Thanks Pat, also added information on how to reinstall pip as this can sometimes be required.

  • Ranjeet Ranjan

    I am getting below error.
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o
    build/temp.linux-x86_64-2.7/_openssl.c:434:30: fatal error: openssl/opensslv.h: No such file or directory
    compilation terminated.
    error: command ‘gcc’ failed with exit status 1

    Command “/usr/bin/python -u -c “import setuptools, tokenize;__file__=’/tmp/pip-build-TpKVIq/cryptography/’;f=getattr(tokenize, ‘open’, open)(__file__);‘rn’, ‘n’);f.close();exec(compile(code, __file__, ‘exec’))” install –record /tmp/pip-AZEZxk-record/install-record.txt –single-version-externally-managed –compile” failed with error code 1 in /tmp/pip-build-TpKVIq/cryptography/
    [[email protected] server-setup]#

    • Hi Ranjeet that error relates to the dependency libssl-dev not being installed, were there any errors when updating apt or installing the dependencies?

      This will reinstall libssl-dev

      sudo apt-get update
      sudo apt-get purge libssl-dev
      sudo apt-get install libssl-dev

      • Ranjeet Ranjan

        Thanks Ian for your promt response. I solved that dependencies. But still my Ansible version ansible
        config file = /etc/ansible/ansible.cfg
        configured module search path = Default w/o overrides

        But latest Ansible is: ansible-…>

        • Hi Ranjeet, you are correct, 2.2.1 is the current latest released version, however 2.3 is currently not yet formally released by Ansible, it is currently a release candidate.

          If you would like to install the latest development release, after upgrading to the latest release version, run the following command:

          pip install git+git:[email protected] –upgrade

%d bloggers like this: