Vagrant Windows 超时配置设置无效

Vagrant Windows 超时配置设置无效

我已经在 Vagrant 中构建和使用 Linux 映像一段时间了,但最近才扩展到 Windows。我曾处理过映像来满足 sysprep 的要求,但这导致启动时间非常慢,并且随后的 WinRM 超时也存在问题。我尝试设置非常高的超时值,但似乎没有效果,即启动超时加倍,但它却下降了

Vagrant.configure(2) do |config|
  config.vm.boot_timeout = 1200
  config.vm.guest = "windows"
  config.vm.communicator = 'winrm'
  config.winrm.timeout = 120
  config.winrm.retry_limit = 10

在这个例子中,我打印了系统时间

Mon Mar 20 18:14:21 NZDT 2017

预计等待时间为 20 分钟

==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'WindowsDocker'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: cbe_default_1489986988330_5366
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 3389 (guest) => 13389 (host) (adapter 1)
    default: 5985 (guest) => 15985 (host) (adapter 1)
    default: 5986 (guest) => 15986 (host) (adapter 1)
    default: 5985 (guest) => 55985 (host) (adapter 1)
    default: 5986 (guest) => 55986 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 127.0.0.1:15985
    default: WinRM username: vagrant
    default: WinRM execution_time_limit: PT2H
    default: WinRM transport: negotiate
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

4 分钟后退出

Mon Mar 20 18:18:42 NZDT 2017

平台详细信息

  • 主机是 Windows 10
  • Vagrant 1.9.2
  • VirtualBox 5.1.18
  • 来宾 Windows Server 2016

答案1

此消息具有误导性

This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period

我已将 WinRM 超时从 120 秒更改为 30 分钟,现在客户机完成启动并且机器尝试连接。

config.winrm.timeout =   1800 # 30 minutes
config.vm.boot_timeout = 1800 # 30 minutes

相关内容