Vagrant 对流浪汉的合理休假

Vagrant 对流浪汉的合理休假,vagrant,ansible,Vagrant,Ansible,我一直在尝试在我创建的流浪者盒子上使用我的YML文件,它是CentOS。但是,我始终会遇到此超时: ryan@ryan-Galago-UltraPro:~/Desktop/vagrant$ vagrant provision [default] Running provisioner: ansible... PLAY [Show off some basic Ansible features] *********************************** GATHERING FA

我一直在尝试在我创建的流浪者盒子上使用我的YML文件,它是CentOS。但是,我始终会遇到此超时:

ryan@ryan-Galago-UltraPro:~/Desktop/vagrant$ vagrant provision
[default] Running provisioner: ansible...

PLAY [Show off some basic Ansible features] *********************************** 

GATHERING FACTS *************************************************************** 
<10.0.x.x> ESTABLISH CONNECTION FOR USER: vagrant
<10.0.x.x> REMOTE_MODULE setup
<10.0.x.x> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/ryan/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=2222', '-o', 'IdentityFile=/home/ryan/.vagrant.d/insecure_private_key', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 'ConnectTimeout=10', '10.0.x.x', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1441243799.45-82681900071220 && echo $HOME/.ansible/tmp/ansible-tmp-1441243799.45-82681900071220'"]
fatal: [default] => SSH encountered an unknown error. The output was:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/ryan/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/home/ryan/.ansible/cp/ansible-ssh-10.0.x.x-2222-vagrant" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 10.0.x.x [10.0.x.x] port 2222.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 10.0.x.x port 2222: Connection timed out
ssh: connect to host 10.0.x.x port 2222: Connection timed out


TASK: [common | Install postgres] ********************************************* 
FATAL: no hosts matched or all hosts have already failed -- aborting


PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/ryan/site.retry

default                    : ok=0    changed=0    unreachable=1    failed=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
以及我正在使用的主机文件:

[vagrant]
default ansible_ssh_host=10.0.x.x ansible_ssh_user=vagrant ansible_ssh_port=2222
有人知道为什么当我运行《流浪规定》时,它在我身上超时了吗

更新: 我已尝试仅使用默认的vagrant主机文件:

 Generated by Vagrant

default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222

有没有办法将默认的ansible_ssh_主机从环回地址更改为其实际IP?

您是否能够使用
vagrant ssh连接到新创建的框

你的翻译是什么?您是使用VirtualBox作为VM提供程序还是其他什么


如中所述,可以尝试删除
ansible.inventory\u path=“hosts”
语句,因为Vagrant应该生成自己的ansible动态库存,因为您使用的是
ansible.groups
语句。

我刚刚发现了问题所在。以下是我需要做的几件事:

  • 在我的~/.ssh/config文件中列出一个环回地址条目,该条目将指向Vagrant不安全的私钥。一旦我这样做了,我就能够使用端口22和2222进行SSH(而不使用vagrantssh命令)。在本例中,我将主机命名为VagrantVM

  • 接下来,我需要调整用于引用ansible构建的主机文件:

    [流浪汉]
    VagrantVM ansible\u ssh\u user=vagrant ansible\u ssh\u port=2222


  • 一旦我做了这些调整,我运行了
    vagrant provision
    ,它成功了

    如果我删除它,它将从vagrant生成的主机文件中读取,并且无法匹配主机。是否有方法将vagrant生成的主机文件配置为指向正确的IP而不是环回IP查看
    。vagrant/provisioners/ansible/inventory/vagrant\u ansible\u inventory
    文件以查看vagrant生成了什么,然后将其发布到此处。如果使用ansible\u ssh\u port=22连接到10.0.x.x,会发生什么情况,而不是2222?当Vagrant配置环回地址时,它会设置端口转发,但仅在127.0.0.1上设置,而不是在真实IP上。它仍然超时。我试着连接端口22和222HMM。接下来要缩小范围的问题是,是否是VM未侦听传入连接的问题,或者是您的凭据不工作的问题。尝试使用
    SSH-i~/.vagrant.d/unsecure_private_key-p 2222自己打开到主机的SSH连接vagrant@127.0.0.1-vvv
    ,然后将该地址的输出与其他地址进行比较。Hmmm。。我用正在使用的实际IP(不是环回)进行了尝试,我得到了一个到主机的无路由,这很奇怪,因为虚拟机已启动,并且已连接到Internet。如果我进入虚拟机并在PC上ping IP,我就没有到主机的路由。。。所以很可能VM没有在监听。。。
     Generated by Vagrant
    
    default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222