Ansible ssh错误:mux_client_read_packet:读取标头失败:管道损坏接收到来自主服务器的退出状态

问题描述

我在/wd/remoteuser/stopALL.sh(即remotehost)上有一个脚本10.0.0.211,需要3秒才能完成执行,并具有对远程用户的完全许可775。

注意:运行ansible的主机上不存在/wd/remoteuser/stopALL.s h。

我希望从我的remotehost触发ansiblehost上的停止脚本。

下面是我如何运行Ansible剧本。

ansible-playbook /app/playbook/ovs.yml -i /app/playbook/ovs.hosts -t stop -f 5 -e Environment=PROD -e Country=SRILANKA -vvvv

cat /app/playbook/ovs.yml

---
- name: Play 1- check for login and mount point
  hosts: "*{{ Country }}_{{ Environment }}"
  user: "{{ USER }}"
  any_errors_fatal: true
  vars:
    ansible_ssh_extra_args: -o StrictHostKeyChecking=no -o ConnectTimeout=90 -o ServerAliveInterval=50
    ansible_ssh_private_key_file: /app/ssh_keys/id_rsa
  gather_facts: false

  tasks:

    - name: Execute backup stop1 script
      tags: stop,restart
      script: "{{ stopscript }}"
      args:
        chdir: "{{ stopscript | dirname }}"
      register: stopscriptoutput


    - name: Debug stopscript
      tags: stop,restart
      debug:
        msg: "{{ stopscriptoutput.stdout }}"

cat /app/playbook/ovs.hosts

[APP_SRILANKA_PROD]
10.0.0.211 USER=remoteuser stopscript=/wd/remoteuser/stopALL.sh countrydet=SRILANKA evt=PROD

输出

<10.0.0.211> (0,'','OpenSSH_7.4p1,OpenSSL 1.0.2k-fips  26 Jan 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,gss-gex-sha1-,gss-group14-sha1-]\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 = 190236\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\n')
fatal: [10.0.0.211]: Failed! => {
    "changed": false,"msg": "Could not find or access '/wd/remoteuser/stopALL.sh' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote,see the remote_src option"
}

NO MORE HOSTS LEFT *****************************************************************************************************************************************************

PLAY RECAP *************************************************************************************************************************************************************
10.0.0.211                : ok=0    changed=0    unreachable=0    Failed=1    skipped=0    rescued=0    ignored=0

此ssh读取标头失败:即使使用了如下所示的shell模块,管道破裂也出错。

- name: Execute backup stop1 script
  tags: stop
  shell: "sleep 90; {{ stopscript }}; sleep 90"
  register: stopscriptoutput

请提出如何解决ssh管道破裂错误并让脚本远程执行的建议?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)