Ansible失败,出现/bin/sh:1:/usr/bin/python:找不到 [英] Ansible fails with /bin/sh: 1: /usr/bin/python: not found
问题描述
我遇到了一个从未见过的错误.这是命令和错误:
I'm running into an error I've never seen before. Here is the command and the error:
$ ansible-playbook create_api.yml
PLAY [straw] ******************************************************************
GATHERING FACTS ***************************************************************
failed: [104.55.47.224] => {"failed": true, "parsed": false}
/bin/sh: 1: /usr/bin/python: not found
TASK: [typical | install required system packages] *****************************
FATAL: no hosts matched or all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/john/create_api.retry
104.55.47.224 : ok=0 changed=0 unreachable=0 failed=1
这是create_api.yml文件:
Here is the create_api.yml file:
---
- hosts: api
remote_user: root
roles:
- api
这是主机文件:
[api]
104.55.47.224
我可以删除角色部分,它不会进入第一个任务,而是使其只进入第/bin/sh: 1: /usr/bin/python: not found
行.这可能是怎么回事?
I can remove the roles section and it won't make it to the first TASK, it will instead make it will only make it to the line /bin/sh: 1: /usr/bin/python: not found
. What could be going on here?
注意::如果有人对IP地址执行ping操作而未得到响应,则您应该知道我自粘贴代码以来就更改了IP地址.
NOTE: In case anyone is pinging the IP address and failing to get a response, you should know I've changed the IP address since pasting code.
编辑 python是本地安装的,问题是它没有安装在运行Ubuntu 15.04的远程计算机上.
EDIT python was installed locally, the problem was that it was not installed on the remote machine, which was running Ubuntu 15.04
推荐答案
我偶然发现此错误在 Ubuntu 15.10 服务器上运行ansible,因为它随 Python 3.4.3 一起提供>和 ansible需要Python 2 .
I stumbled upon this error running ansible on Ubuntu 15.10 server, because it ships with Python 3.4.3 and ansible requires Python 2.
这是我的provision.yml
现在的样子:
- hosts: my_app
sudo: yes
remote_user: root
gather_facts: no
pre_tasks:
- name: 'install python2'
raw: sudo apt-get -y install python
tasks:
- name: 'ensure user {{ project_name }} exists'
user: name={{ project_name }} state=present
-
不要忘记使用apt-get的-y(对所有问题都说是)选项(否则原始模块将被静默卡住)
Don't forget the -y (says yes to all questions) option with apt-get (or raw module will get stuck silently)
gather_facts: no
行也很关键(因为没有python我们无法收集事实)gather_facts: no
line is also critical (because we can't gather facts without python)这篇关于Ansible失败,出现/bin/sh:1:/usr/bin/python:找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!