4

I would like to install Ansible on my Raspberry Pi (raspbian/jessie) so that I can maintain it. Unfortunately, I don't seem to be able to install it. I've tried APT and PIP so far but each has a hurdle.

APT

pi@retropie:~ $ sudo apt-add-repository ppa:ansible/ansible

Traceback (most recent call last):
  File "/usr/bin/apt-add-repository", line 167, in <module>
    sp = SoftwareProperties(options=options)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 105, in __init__
    self.reload_sourceslist()
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 595, in reload_sourceslist
    self.distro.get_sources(self.sourceslist)
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 89, in get_sources
    (self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Raspbian/jessie

PIP (Python 2.7.9, pip 1.5.6)

pi@retropie:~ $ sudo pip install ansible

Downloading/unpacking ansible
  Downloading ansible-2.4.1.0.tar.gz (6.7MB): 6.7MB downloaded

    no previously-included directories found matching 'ticket_stubs'
    no previously-included directories found matching 'hacking'
Downloading/unpacking jinja2 (from ansible)
  Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB): 340kB downloaded
Downloading/unpacking PyYAML (from ansible)
  Downloading PyYAML-3.12.tar.gz (253kB): 253kB downloaded
  Running setup.py (path:/tmp/pip-build-bsUTB2/PyYAML/setup.py) egg_info for package PyYAML

Downloading/unpacking paramiko (from ansible)
  Downloading paramiko-2.3.1-py2.py3-none-any.whl (182kB): 182kB downloaded
Downloading/unpacking cryptography (from ansible)
  Downloading cryptography-2.1.2.tar.gz (441kB): 441kB downloaded
  Running setup.py (path:/tmp/pip-build-bsUTB2/cryptography/setup.py) egg_info for package cryptography
    error in cryptography setup command: Invalid environment marker: python_version < '3'
    Complete output from command python setup.py egg_info:
    error in cryptography setup command: Invalid environment marker: python_version < '3'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-bsUTB2/cryptography
Storing debug log for failure in /root/.pip/pip.log

Python 3

As you can see from the above error, "cryptography" indicates it needs > python3 I looked at the installation requirements and found that you need python 3.5+ if you use 3. Rasbian comes with 3.4...

I then tried to get python 3.6 installed using a couple of ppa's (ppa:jonathonf/python-3.6 and ppa:deadsnakes/ppa) but there aren't distros available for raspbian/jessie either.

After that I started looking at pulling down and compiling python from source but I'm expecting I'll hit another hurdle.

Ugh...

In summary, does anyone have any ideas how I can get Ansible installed on a Raspberry Pi?

Steve Stevens
  • 355
  • 4
  • 15
  • 1
    Crytpography 2.1.2 definitely supports python 2.7 according to both the package listing and their github. You have some other issue here. – Matthew Schuchard Oct 31 '17 at 11:49

2 Answers2

6

Slightly old question but its the first result that comes up when googling for how to install Ansible on Raspbian so thought I'd update it. If you're running stretch (or stretch-lite)

You can just do

sudo apt-get install ansible

However currently the version of Ansbile in the Raspbian repositories is 2.2 which is a little old

Following instructions (with a little modification to overcome some errors) from the Ansible installation page you can do the following:

First run

sudo apt-get install dirmngr

Edit your /etc/apt/sources.list and append

deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main

then run

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367    
sudo apt-get update 
sudo apt-get install ansible

This will give you version 2.7.8 as of today.

Edited to include missing command (thanks SpacePope) and correct formatting.

Hamza M
  • 61
  • 1
  • 3
  • Just a small addition to Hamza M: You need to run the following to get the pub key to that source - `sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367` – SpacePope Mar 02 '19 at 07:04
  • 1
    I really appreciate this answer. I had been struggling to install an up-to-date version of Ansible via source and or python so this is a great find. Worked like a charm. Cheers! – droid-zilla Apr 04 '19 at 06:06
2

Jessie was released in 2015 and is officially obsolete. Stretch is the current Raspbian repo, and it has python3.5 without adding PPAs.

You can then simply install Ansible with pip3.

tedder42
  • 23,519
  • 13
  • 86
  • 102