Ansible由于其构造的ssh问题而挂起

2024-09-29 02:20:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用詹金斯管道触发下面的ansible剧本

- name: Play 2- Configure Source nodes
  hosts: "{{ location }}"
  user: remoteuser
  strategy: free
  gather_facts: false
  vars:
    ansible_ssh_extra_args: -o StrictHostKeyChecking=no -o ConnectionAttempts=5
    ansible_ssh_private_key_file: /app/automation/id_rsa

  tasks:
    
    - name: Execute script 
      shell: "/app/mybkp.sh"

上述ansible playbook在调试模式下运行如下:

ansible-playbook orabackup.yml_final -i ora.hosts -f 90 -e location=MYIP -e ansible_ssh_use_tty=no -vvv

下面是Jenkins冻结且永远无法完成的输出

PLAY [Play 2- Configure Source nodes] ******************************************
META: ran handlers
<10.0.0.111> Attempting python interpreter discovery
<10.0.0.111> ESTABLISH SSH CONNECTION FOR USER: remoteuser
<10.0.0.111> SSH: EXEC ssh -o 'IdentityFile="/app/automation/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="remoteuser"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ConnectionAttempts=5 10.0.0.111 '/bin/sh -c '"'"'echo PLATFORM; uname; echo FOUND; command -v '"'"'"'"'"'"'"'"'/usr/bin/python'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.7'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.6'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.5'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python2.7'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python2.6'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/libexec/platform-python'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/bin/python3'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python'"'"'"'"'"'"'"'"'; echo ENDFOUND && sleep 0'"'"''
<10.0.0.111> (0, 'PLATFORM
AIX
FOUND
/usr/bin/python3
ENDFOUND
', 'This system is for the use of authorized users only. Individuals using this computer system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to the law enforcement officials
')
<10.0.0.111> Python interpreter discovery fallback (unsupported platform for extended discovery: aix)
Using module file /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py
Pipelining is enabled.
<10.0.0.111> ESTABLISH SSH CONNECTION FOR USER: remoteuser

<10.0.0.111> SSH: EXEC ssh -o 'IdentityFile="/app/automation/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="remoteuser"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ConnectionAttempts=5 10.0.0.111 '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"''

由ansible构建的ssh在上面的Jenkins日志中可见,当在putty终端中手动执行时,ssh也会冻结/挂起,并且永远不会返回

此问题不会发生在其他IP上,但特定于此IP 10.0.0.111

我从ssh命令中删除了 '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"'',手动尝试了一下,结果成功了

我已经在调试模式下上传了工作ssh而没有 '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"''在这里:https://drive.google.com/file/d/1MGWpWK2IeWa_LlifixrLTCwxv1IfvH2t/view?usp=sharing

我上传了失败的(冻结)ssh,其中 '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"''在这里:https://drive.google.com/file/d/1yXictTMKfNDqu4wqQejyt5TVM483v7s2/view?usp=sharing

目标服务器10.0.0.111是AIX6.1

你能建议我如何解决这个问题吗


Tags: ofthenoappbinusrshsleep