简体   繁体   English

如何在Raspbian上安装Ansible?

[英]How can I install Ansible on Raspbian?

I would like to install Ansible on my Raspberry Pi (raspbian/jessie) so that I can maintain it. 我想在我的Raspberry Pi(raspbian / jessie)上安装Ansible,以便我可以维护它。 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和PIP,但每个都有一个障碍。

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) 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 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... 从上面的错误中可以看出,“加密”表明它需要> python3我查看了安装要求 ,发现你需要python 3.5+如果你使用3.Rasbian附带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. 然后我尝试使用几个ppa(ppa:jonathonf / python-3.6和ppa:deadsnakes / ppa)安装python 3.6,但是没有可用于raspbian / jessie的发行版。

After that I started looking at pulling down and compiling python from source but I'm expecting I'll hit another hurdle. 之后我开始考虑从源头下拉并编译python,但我期待着我会遇到另一个障碍。

Ugh... 啊...

In summary, does anyone have any ideas how I can get Ansible installed on a Raspberry Pi? 总之,有没有人有任何想法如何在Raspberry Pi上安装Ansible?

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. 稍微陈旧的问题,但它是谷歌搜索如何在Raspbian上安装Ansible时出现的第一个结果所以我认为我会更新它。 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 但是目前Raspbian存储库中的Ansbile版本是2.2,这有点旧

Following instructions (with a little modification to overcome some errors) from the Ansible installation page you can do the following: Ansible安装页面按照说明(稍作修改以克服一些错误),您可以执行以下操作:

First run 第一次运行

sudo apt-get install dirmngr

Edit your /etc/apt/sources.list and append 编辑/etc/apt/sources.list并追加

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. 这将为您提供截至今天的2.7.8版本。

Edited to include missing command (thanks SpacePope) and correct formatting. 编辑包括缺少命令(感谢SpacePope)和正确的格式。

Jessie was released in 2015 and is officially obsolete. Jessie于2015年发布,正式淘汰。 Stretch is the current Raspbian repo, and it has python3.5 without adding PPAs. Stretch是当前的Raspbian repo,它有python3.5而不添加PPA。

You can then simply install Ansible with pip3. 然后,您只需使用pip3安装Ansible即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM