【问题标题】:Ansible error Received exit status from masterAnsible 错误 Received exit status from master
【发布时间】:2018-09-03 21:32:22
【问题描述】:

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

---
- 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": 

关于为什么 ansible 在重用主连接时不断收到此错误的任何想法?

【问题讨论】:

  • 您正在尝试在远程主机上执行/usr/local/bin/python,错误消息告诉您,它不存在。

标签: amazon-ec2 ssh ansible


【解决方案1】:

如果我必须在 vanilla ubuntu AMI 上运行某些东西,我已经在剧本之上做了类似的事情。

---
- 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

【讨论】:

    【解决方案2】:

    尝试在目标机器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 &amp;&amp; apt-get install python
    之后就OK了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-20
      • 1970-01-01
      • 1970-01-01
      • 2022-06-11
      • 2013-07-18
      • 2019-07-31
      • 2020-11-04
      • 2018-03-28
      相关资源
      最近更新 更多