Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon ec2 Ansible error从主机接收到退出状态_Amazon Ec2_Ssh_Ansible - Fatal编程技术网

Amazon ec2 Ansible error从主机接收到退出状态

Amazon ec2 Ansible error从主机接收到退出状态,amazon-ec2,ssh,ansible,Amazon Ec2,Ssh,Ansible,我编写了一个看似简单的ansible任务来连接ec2实例并配置时区。主要任务如下 --- - name: Set Time Zone variables copy: content='Etc/UTC' dest=/etc/timezone owner=root group=root mode=0644 backup=yes 用于运行任务的命令是 ansible-playbook nectar.yml --extra-vars "ansible_python_interpreter=/us

我编写了一个看似简单的ansible任务来连接ec2实例并配置时区。主要任务如下

---
- name: Set Time Zone variables
  copy: content='Etc/UTC' dest=/etc/timezone owner=root group=root mode=0644 backup=yes
用于运行任务的命令是

ansible-playbook nectar.yml  --extra-vars "ansible_python_interpreter=/usr/local/bin/python env=DEVELOPMENT" -vvvv
我的ansible.cfg看起来像

[defaults]
inventory = hosts

[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
但我一直收到错误信息

<54.237.211.85> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<54.237.211.85> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o 'IdentityFile="./nectar-web.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/Users/reagan/.ansible/cp/5113bdcc33 -tt 54.237.211.85 '/bin/sh -c '"'"'/usr/local/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1522003225.61-27057727697133/command.py; rm -rf "/home/ubuntu/.ansible/tmp/ansible-tmp-1522003225.61-27057727697133/" > /dev/null 2>&1 && sleep 0'"'"''
<54.237.211.85> (0, '/bin/sh: 1: /usr/local/bin/python: not found\r\n', 'OpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 98004\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 54.237.211.85 closed.\r\n')
fatal: [54.237.211.85]: FAILED! => {
    "changed": false, 
    "module_stderr": "OpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 98004\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 54.237.211.85 closed.\r\n", 
    "module_stdout": "/bin/sh: 1: /usr/local/bin/python: not found\r\n", 
    "msg": "MODULE FAILURE", 
    "rc": 
为用户建立SSH连接:ubuntu
SSH:EXEC SSH-vvv-o ControlMaster=auto-o ControlPersist=60s-o Port=22-o'IdentityFile=“./nectar web.pem”'-o KbdInteractiveAuthentication=no-o PreferredAuthentications=gssapi带麦克风、gssapi keyex、基于主机、,publickey-o PasswordAuthentication=no-o User=ubuntu-o ConnectTimeout=10-o StrictHostKeyChecking=no-o ControlPath=/Users/reagan/.ansible/cp/5113bdcc33-tt 54.237.211.85'/bin/sh-c'''''/usr/local/bin/python/home/ubuntu/.ansible/tmp-tmp-1522003225.61-27057727697133/command.py;rm-rf“/home/ubuntu/.ansible/tmp/ansible-tmp-1522003225.61-27057727697133/“>/dev/null 2>&1&&sleep 0”
(0),/bin/sh:1:/usr/local/bin/python:not found\r\n',OpenSSH\u 7.4p1,LibreSSL 2.5.0\r\ndebug1:读取配置数据/etc/ssh/ssh\u config\r\ndebug1:自动多路复用:尝试现有主\r\ndebug2:fd3设置为非块\r\ndebug2:多路复用客户端\r\n交换:主版本4\r\ndebug3:多路复用客户端\u转发:请求转发:0本地,0远程\r\ndebug3:mux\u客户端请求\u会话:进入\r\ndebug3:mux\u客户端请求\u活动:进入\r\ndebug3:mux\u客户端请求\u活动:完成pid=98004\r\ndebug3:mux\u客户端请求\u会话:发送的会话请求\r\ndebug1:mux\u客户端请求\u会话:主会话id:2\r\ndebug3:mux\u客户端\u读取\u数据包:读取头失败:管道断开\r\ndebug2:Re接收到从主机0到54.237.211.85的共享连接的退出状态\r\n已关闭。\r\n')
致命:[54.237.211.85]:失败!=>{
“更改”:错误,
“模块标准”:"OpenSSH_7.4p1,LibreSSL 2.5.0\r\ndebug1:读取配置数据/etc/ssh/ssh_config\r\ndebug1:自动mux:尝试现有主\r\ndebug2:fd 3设置为非块\r\ndebug2:mux_客户端\r\ndebug3:mux_客户端\r\n转发:请求转发:0本地,0远程\r\ndebug3:mux_客户端\r\n请求会话:进入\r\ndebug3:mux\U客户端请求\u活动:输入\r\ndebug3:mux\U客户端请求\u活动:完成pid=98004\r\ndebug3:mux\U客户端请求\u会话:会话请求已发送\r\ndebug1:mux\U客户端请求\u会话:主会话id:2\r\ndebug3:mux\U客户端读取\u数据包:读取头失败:管道断开\r\ndebug2:接收到主服务器0的退出状态\r\n共享连接到54.237.211.85已关闭。\r\n“,
“模块\标准输出”:“/bin/sh:1:/usr/local/bin/python:未找到\r\n”,
“msg”:“模块故障”,
“rc”:

你知道为什么ansible在重用主连接时总是出现这个错误吗?

如果我必须在ubuntu AMI上运行一些东西,我会在playbook上做类似的事情

---
- hosts: all
  remote_user: someuser
  gather_facts: False
  pre_tasks:
    - name: Install python for Ansible
      raw: test -f /usr/bin/python || (apt -y update && apt install -y python-minimal)
      become: true
```

- setup: # aka gather_facts

尝试在目标计算机上安装python。 我有同样的错误:

dworker-01 | FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to dworker-01 closed.\r\n",
    "module_stdout": "/bin/sh: 1: /usr/local/bin/python: not found\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 127
}
目标机器:
apt-get-update&&apt-get-install-python


之后一切正常。

您试图在远程主机上执行
/usr/local/bin/python
,错误消息告诉您,它不在那里。