无法获得modernIE的vagrant特定盒子与vagrant一​​起工作

时间:2016-04-14 17:21:09

标签: vagrant virtualbox provisioning

我最近发现Microsoft提供了一个“Vagrant”选项,用于从microsoft developer下载他们的现代IE Windows机器,因为我一直在使用Vagrant来运行一些Windows环境,我认为它是一个很好的快捷方式,也许可以缓解我已经通过Vagrant已经提供的Windows机箱过期的许可问题。但是,它并不顺利。

首先,下载的文件夹文件名中有一堆空格需要删除才能防止Ruby爆炸。我做到了这一点,并且能够将盒子添加到Vagrant但现在Vagrant卡住等待机器启动。 VM实际上在后台启动,但Vagrant超时,因为它无法再与VM通信。设置超时比机器启动所需的时间长几分钟。

有没有人知道如何在不锁定许可证到期日期的情况下解决这个问题?我做错了什么,或者微软是否创建了这些Vagrant box VM而没有真正检查它们是否与Vagrant一​​起运行?

Host OS: El Capitan
Vagrant version: 1.8.1
Box: MSEdge - Win10TH2.box
VirtualBox version: 5.0.16

VagrantFile片段:

config.vm.define "crap", autostart: false do |win|
  win.vm.box = "~/win10.box"  # Renamed from "MSEdge - Win10_TH2.box"
  win.vm.communicator = "winrm"
  win.vm.network "private_network", ip: "192.168.11.7"
  win.vm.provider "virtualbox" do |v|
    v.name = "crap"
    v.gui = true
  end
end

错误:

Bringing machine 'crap' up with 'virtualbox' provider...
==> crap: Importing base box '~/win10.box'...
==> crap: Matching MAC address for NAT networking...
==> crap: Setting the name of the VM: crap
==> crap: Clearing any previously set network interfaces...
==> crap: Preparing network interfaces based on configuration...
    crap: Adapter 1: nat
==> crap: Forwarding ports...
    crap: 5985 (guest) => 55985 (host) (adapter 1)
    crap: 5986 (guest) => 55986 (host) (adapter 1)
==> crap: Booting VM...
==> crap: Waiting for machine to boot. This may take a few minutes...
    crap: WinRM address: 127.0.0.1:55985
    crap: WinRM username: vagrant
    crap: WinRM execution_time_limit: PT2H
    crap: WinRM transport: plaintext
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.

6 个答案:

答案 0 :(得分:3)

如果想要使用Windows Vagrant框,那么他很可能希望使用WinRM Vagrant configuration n。所以cdwilson的答案指向SSH并且不满足我。

另外,mr-rogerscdwilson都是错误的 - 来自https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/windows/的Vagrant框预装并配置了WinRM,只需查看herehere

这里的最后一个答案是制作一个自定义的Vagrant盒子,在更专业的场景中我也无法遵循。

但有帮助(遗憾的是手动工作,直到Microsoft正确配置它):我们必须更改网络列表管理政策

为此您需要手动启动VM并获取超时错误,进入本地安全策略 / 网络列表管理策略,双击{{1} },转到标签Network并将Network Location设置为私有,将Location type设置为用户可以更改位置

就是这样,现在假设correct Vagrantfile with WinRM configurationUser permissions可以正常工作。

但是mr-rogers是对的,请提升microsoft developer FEEDBACK

答案 1 :(得分:2)

我创建了一个Vagrantfile,能够在Microsoft分发的盒子上自动配置WinRM。换句话说,这个Vagrantfile能够:

  • 禁用防火墙(Microsoft分发的框配置为 防火墙默认启用);
  • 将网络位置类型更改为“工作 网络“(由Microsoft分发的框配置为”公共 网络“默认情况下”;
  • 启用WinRM。

https://github.com/danielmenezesbr/modernie-winrm

答案 2 :(得分:1)

您使用的是从MS ??

下载的virtualBox图像吗?

你可以在第一次执行vagrant up时打开virtualBox并登录到该VM吗?我发现从MS下载的图像会提示有关“更新”的消息。如果在commandLine中执行vagrant up。提示不会被驳回。所以它超时了。

根据我的经验,只有第一次执行会遇到这个。

答案 3 :(得分:1)

developer.microsoft.com提供的流浪汉机器本身是使用SSH访问(而不是WinRM)构建的,但这并不意味着可以在门外配置SSH。

这是我得到的错误(因为没有安装sudo):

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: IEUser
    default: SSH auth method: password
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/User/Desktop/Vagrant Boxes/8.1
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir -p C:\Users\IEUser>

Stdout from the command:



Stderr from the command:

sh: sudo: command not found

如果您使用SSH登录(通过vagrant ssh;密码为Passw0rd!)并发出以下命令,则可以使用winrm:

cmd /c "reg add HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /d 0 /t REG_DWORD /f /reg:64"
powershell "Set-NetConnectionProfile -InterfaceIndex ((Get-NetConnectionProfile).InterfaceIndex) -NetworkCategory Private"
cmd /c "winrm quickconfig -q -force"
cmd /c 'winrm set winrm/config/winrs @{MaxMemoryPerShellMB="512"}'
cmd /c 'winrm set winrm/config @{MaxTimeoutms="1800000"}'
cmd /c 'winrm set winrm/config/service @{AllowUnencrypted="true"}'
cmd /c 'winrm set winrm/config/service/auth @{Basic="true"}'
cmd /c "sc config WinRM start= auto"
cmd /c 'netsh firewall add portopening TCP 5985 "Port 5985"'
cmd /c 'winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} '

也许Windows可以很快重新打包这些机器。 Upvoting this developer FEEDBACK可能有所帮助。

答案 4 :(得分:1)

如上面的答案所述,必须启用WinRM。 为了避免在那里描述的步骤,我创建了一个派生的VagrantBox。

此Vagrantbox默认启用WinRM(和RDP),因此无需修改即可启动(https://atlas.hashicorp.com/mrh1997/boxes/vanilla-win7-32bit):

vagrant init mrh1997/vanilla-win7-32bit
vagrant up

您可以使用以下命令连接到该框:

vagrant powershell   # commandline via WinRM
vagrant rdp          # GUI via RDP
vagrant ssh          # commanline via SSH

答案 5 :(得分:1)

如其他答案中所述,从https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/下载的框默认启用SSH。但是,它们与流浪者期望的默认SSH配置不匹配。

具体而言,上述任何答案均未提及config.ssh.insert_key = false

  

Vagrant配置为生成随机密钥对并插入它   在客人机器上,但看起来Vagrant不知道该怎么做   这与您的客户操作系统。请通过设置禁用密钥插入   Vagrantfile中的config.ssh.insert_key = false

     

执行此操作后,请运行vagrant reload以使设置生效。

     

如果您想让Vagrant了解如何在此操作系统上插入密钥,请   打开有关您的环境的详细信息。

以下配置选项让我可以对今天下载的全新Win10 VM进行SSH访问:

config.vm.guest = :windows
config.vm.boot_timeout = 600
config.vm.graceful_halt_timeout = 600
config.ssh.username = "IEUser"
config.ssh.password = "Passw0rd!"
config.ssh.insert_key = false

这是输出:

$ vagrant up --provider virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'msdev-win10'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: msdev-win10_default_1471207782454_14791
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: IEUser
    default: SSH auth method: password
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 5.0.20
    default: VirtualBox Version: 5.1
==> default: Mounting shared folders...
    default: /vagrant => /Users/chris/Projects/vagrant/msdev-win10
$ vagrant ssh
==> default: The machine you're attempting to SSH into is configured to use
==> default: password-based authentication. Vagrant can't script entering the
==> default: password for you. If you're prompted for a password, please enter
==> default: the same password you have configured in the Vagrantfile.
IEUser@127.0.0.1's password: 
-sh-4.1$