【发布时间】:2015-09-03 01:36:19
【问题描述】:
我一直在尝试在我构建的 Vagrant box 上使用我的 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.
我查看了整个 Internet 以找出为什么它一直超时但什么也没有出现,所以我向 StackOverFlow 询问任何类型的建议。这是我的 VagrantFile 的样子:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "cento"
config.vm.provision "ansible" do |ansible|
ansible.groups = {
"vagrant" => ["10.0.x.x"]
}
ansible.extra_vars = { ansible_ssh_user: "vagrant" }
ansible.sudo = true
ansible.verbose = "vvvv"
ansible.playbook = "site.yml"
ansible.inventory_path = "hosts"
end
end
我正在使用的主机文件:
[vagrant]
default ansible_ssh_host=10.0.x.x ansible_ssh_user=vagrant ansible_ssh_port=2222
有没有人有任何理由说明我运行vagrant provision 时会超时?
更新: 我试过只使用默认的流浪主机文件:
Generated by Vagrant
default ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222
有没有办法将默认 ansible_ssh_host 从环回地址更改为它的实际 IP?
【问题讨论】:
-
如果使用 ansible_ssh_port=22 而不是 2222 连接到 10.0.x.x 会发生什么?当 Vagrant 配置回送地址时,它会设置端口转发,但仅在 127.0.0.1 上设置,而不是在真实 IP 上设置。
-
它仍然超时。我尝试连接端口 22 和 2222
-
嗯。接下来要缩小的范围是虚拟机是否存在未侦听传入连接的问题,或者您的凭据无法正常工作。尝试使用
ssh -i ~/.vagrant.d/insecure_private_key -p 2222 vagrant@127.0.0.1 -vvv自己打开与主机的 SSH 连接,然后将其输出与其他地址进行比较。 -
嗯 .. 我用正在使用的实际 IP(不是环回)尝试了它,但我没有到主机的路由,这很奇怪,因为 VM 已启动并连接到互联网
-
另外,如果我进入 VM 并在我的 PC 上 ping IP,我得到 No Route To Host...所以很可能,VM 没有在监听...