首页 文章

Vagrant / Ansible SSH错误

提问于
浏览
1

尝试使用Vagrant和Ansible配置Azure VM时出现以下错误:

➜  remote-dev git:(master) ✗ vagrant provision app
    ==> app: Running provisioner: ansible...
        app: Running ansible-playbook...
    PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/        dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit="app"         --inventory-file=/Users/user/vagrant/remote-dev/.vagrant/provisioners/ansible/inventory -vvvv site.yml
    Using /Users/user/vagrant/remote-dev/ansible.cfg as config file
    Loading callback plugin default of type stdout, v2.0 from /usr/local/Cellar/ansible/2.2.0.0_2/libexec/lib/python2.7/site-packages/ansible/plugins/        callback/__init__.pyc

    PLAYBOOK: site.yml *************************************************************
    1 plays in site.yml

    PLAY [all] *********************************************************************

    TASK [setup] *******************************************************************
    Using module file /usr/local/Cellar/ansible/2.2.0.0_2/libexec/lib/python2.7/site-packages/ansible/modules/core/system/setup.py
    <name.eastus.cloudapp.azure.com> ESTABLISH SSH CONNECTION FOR USER: vagrant
    <name.eastus.cloudapp.azure.com> SSH: EXEC ssh -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o         ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/Users/user/.ssh/vagrant.key"' -o KbdInteractiveAuthentication=no -o         PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=30 -o         ControlPath=/Users/user/.ansible/cp/ansible-ssh-%h-%p-%r name.eastus.cloudapp.azure.com '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c         '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-nplltooivdpoedgryzzyimyktrvyeduu; /usr/bin/python'"'"'"'"'"'"'"'"' && sleep 0'"'"''
    fatal: [app]: UNREACHABLE! => {
        "changed": false,
        "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh",
        "unreachable": true
    }

ping工作原理:

➜  remote-dev git:(master) ✗ ansible app -m ping
app | SUCCESS => {
   "changed": false,
    "ping": "pong"
}

运行ansible-playbook也是如此:

ansible-playbook appservers.yml

我的主机文件:

app ansible_ssh_host=name.eastus.cloudapp.azure.com ansible_ssh_port=22 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='/Users/user/.ssh/vagrant.key'

1 回答

  • 0

    它看起来像是修复它 control_path = %(directory)s/%%h-%%p-%%r 添加到我的ansible.cfg [ssh_connection] 下 .

    在运行调试输出中找到的下面复制的完整ansible ssh命令后,我走了那条路线并收到此错误:

    debug3:muxserver_listen:临时控制路径/ Users / <user> /.ansible / cp / <fqdn>
    unix_listener:“/ Users / <user> /.ansible / cp / <fqdn>”对于Unix域套接字来说太长了

    ssh -vvv -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -i
     /Users/<user>/.ssh/vagrant.key -o ForwardAgent=yes -o
     ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no
     -o Port=22 -o 'IdentityFile="/Users/<user>/.ssh/vagrant.key"' -o KbdInteractiveAuthentication=no -o
     PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
     -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=90 -o ControlPath=/Users/<user>/.ansible/cp/<fqdn> '/bin/sh -c'
    

    在ansible issue #11536找到了答案 .

相关问题