gpt4 book ai didi

python - Ansible 由于其构建的 ssh 问题而挂起

转载 作者:行者123 更新时间:2023-12-05 06:09:44 28 4
gpt4 key购买 nike

我使用 Jenkins 管道触发以下 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 在 Debug模式下运行如下:

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

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

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

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

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

我已经用 '/bin/sh -c '"'"'/usr/bin/python3 && sleep 0'"'"'' 上传了失败的(卡住)ssh 这里:https://drive.google.com/file/d/1yXictTMKfNDqu4wqQejyt5TVM483v7s2/view?usp=sharing

目标服务器 10.0.0.111 是 AiX 6.1。

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

最佳答案

ansible.cfg中设置:

[connection]
pipelining = False

AIX 似乎有问题 https://github.com/ansible/ansible/issues/17826

关于python - Ansible 由于其构建的 ssh 问题而挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64661218/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com