Ansible 失败并显示/bin/sh: 1:/usr/bin/python: not found [英] 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:未找到
.这里会发生什么?
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?
注意:如果有人在 ping IP 地址但没有得到响应,您应该知道我在粘贴代码后更改了 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
现在的样子:
This is how my provision.yml
looks now:
- 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
line 也很关键(因为我们不能没有 python 收集事实)gather_facts: no
line is also critical (because we can't gather facts without python)这篇关于Ansible 失败并显示/bin/sh: 1:/usr/bin/python: not found的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!