问题原文
原帖链接 · Madoc Comadrin · CC BY-SA 4.0
I am trying to use Ansible 2.7.7 to manage Ubuntu 16.04 cloud image but when I try to make connection I get error:
SSH Error: data could not be sent to remote host "192.168.111.11". Make sure this host can be reached over ssh
If I issue command ssh [email omitted] on the Ansible host I can connect to target server without problems. I can also sudo there without password prompt.
If look at logs of the target machine I see that Ansible successfully logged in to the machine:
Feb 20 11:44:51 ubuntu sshd[2870]: Accepted publickey for ubuntu from 192.168.111.111 port 56236 ssh2: RSA SHA256:yI...
Feb 20 11:44:51 ubuntu sshd[2870]: pam_unix(sshd:session): session opened for user ubuntu by (uid=0)
Feb 20 11:44:51 ubuntu systemd-logind[1090]: New session 13 of user ubuntu.
Feb 20 11:44:51 ubuntu sudo: ubuntu : TTY=unknown ; PWD=/home/ubuntu ; USER=root ; COMMAND=/bin/sh -c echo BECOME-SUCCESS-kldfjkldjhjljkl; /usr/bin/python
Feb 20 11:44:51 ubuntu sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Feb 20 11:44:51 ubuntu sudo: pam_unix(sudo:session): session closed for user root
Verbose output:
ansible-playbook -i inventory default.yaml -vvv
ansible-playbook 2.7.7
config file = /home/admin/ansible/ansible.cfg
configured module search path = [u'/home/admin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /home/admin/ansible/ansible-env/local/lib/python2.7/site-packages/ansible
executable location = /home/admin/ansible/ansible-env/bin/ansible-playbook
python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609]
Using /home/admin/ansible/ansible.cfg as config file
/home/admin/ansible/inventory did not meet host_list requirements, check plugin documentation if this is unexpected
/home/admin/ansible/inventory did not meet script requirements, check plugin documentation if this is unexpected
Parsed /home/admin/ansible/inventory inventory source with ini plugin
PLAYBOOK: default.yaml *******************************************************************************************************************************************************************************************************************
1 plays in default.yaml
PLAY [default] ***************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************
task path: /home/admin/ansible/default.yaml:3
Using module file /home/admin/ansible/ansible-env/local/lib/python2.7/site-packages/ansible/modules/system/setup.py
<192.168.111.11> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<192.168.111.11> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/a9e60c69b0 192.168.111.11 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-tenlfcstwmojszikegdyatixrzpwqwah; /usr/bin/python'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
fatal: [192.168.111.11]: UNREACHABLE! => {
"changed": false,
"unreachable": true
}
MSG:
SSH Error: data could not be sent to remote host "192.168.111.11". Make sure this host can be reached over ssh
What could be causing this issue?
已采纳解答
原帖链接 · Madoc Comadrin · CC BY-SA 4.0
Turns out my target system required tty when using sudo.
I was able to make connection my commenting out this line from ansible.cfg:
pipelining = True
Other option would have been disabling setting requiretty from sudoer file.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
