ssh - Ansible 数据无法发送到远程主机。确保可以通过 ssh 访问此主机
问题描述
我能够从源 ansible 服务器 source_user@10.0.0.110 (linux) 成功 ssh 到目标 dest_user@10.0.0.111 (aix)
但是,这对我的 ansible 剧本不起作用。
这是我的剧本:
---
- hosts: localhost
gather_facts: false
tasks:
- add_host: name={{ Dest_IP }}
groups=dest_nodes
ansible_user={{ User }}
- hosts: dest_nodes
gather_facts: false
vars:
ansible_ssh_extra_args: -o StrictHostKeyChecking=no
ansible_ssh_private_key_file: /app/mykeys/axm_id_rsa
tasks:
- name: Start APP service
include_tasks: "{{ playbook_dir }}/inner.yml"
这是我运行的输出错误:
ansible-playbook test.yml -e Dest_IP=10.0.0.111 -e User=dest_user
TASK [Start service] ***************************************************************************************************************************************************
task path: /app/axmw/Ansible/playbook/finacle_start_stop/inner.yml:1
<10.0.0.111> Attempting python interpreter discovery
<10.0.0.111> ESTABLISH SSH CONNECTION FOR USER: dest_user
<10.0.0.111> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/app/mykeys/axm_id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="dest_user"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/home/source_user/.ansible/cp/8245e98279 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\nAIX\nFOUND\n/usr/bin/python3.7\n/usr/bin/python3\nENDFOUND\n', '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\n')
<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: dest_user
<10.0.0.111> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/app/mykeys/axm_id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="dest_user"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/home/source_user/.ansible/cp/8245e98279 10.0.0.111 '/bin/sh -c '"'"'/usr/bin/python3.7 && sleep 0'"'"''
fatal: [10.0.0.111]: UNREACHABLE! => {
"changed": false,
"msg": "Data could not be sent to remote host \"10.0.0.111\". Make sure this host can be reached over ssh: ",
"unreachable": true
}
PLAY RECAP *************************************************************************************************************************************************************
10.0.0.111 : ok=1 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
如果我尝试上面由 ansible 生成的 ssh 命令也可以!
ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/app/mykeys/axm_id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="dest_user"' -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ControlPath=/home/source_user/.ansible/cp/8245e98279 10.0.0.111
这是我提到的 ansible.cfg,pipelining = True
因为一些项目需要它。
[source_user@sourcehost ~]$ cat /etc/ansible/ansible.cfg | grep -v '#'
[defaults]
[inventory]
[privilege_escalation]
[paramiko_connection]
[ssh_connection]
pipelining = True
transfer_method = smart
[persistent_connection]
[accelerate]
[selinux]
[colors]
[diff]
你能建议可以做些什么来解决这个问题吗?
解决方案
推荐阅读
- jquery - 对象扩展在 Internet Explorer 中不起作用
- javascript - 使用 Joomla 的 HTML 和 Javascript
- python - Python对象类可变默认值
- android - Android Benchmark 库的时间限制?
- python - 将元组的元素与字符串进行比较
- class - Flutter Dart - 动态获取类的属性
- python - 正确地将参数传递给类 - Kivy gui
- javascript - Axios 从 API 返回 HTML
- unity3d - 如何改变魔方的魔方将被渲染?
- scala - 从加特林 CSV 馈送器传递一个字符串数组