【问题标题】:Can't get modernIE's vagrant specific box to work with vagrant无法让 ModernIE 的 vagrant 特定框与 vagrant 一起使用
【发布时间】:2016-08-06 09:45:55
【问题描述】:

我最近发现微软提供了一个“Vagrant”选项,用于从microsoft developer 下载他们的现代 IE Windows 机器,因为我一直在使用 Vagrant 来运行一些 Windows 环境,我认为这将是一个不错的快捷方式并且也许可以缓解我已经通过 Vagrant 获得的 Windows 盒子的过期许可问题。然而,事情并不顺利。

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

有谁知道如何在不锁定许可证到期日期的情况下解决此问题?是我做错了什么,还是微软创建了这些 Vagrant 盒子 VM 并没有实际检查它们是否与 Vagrant 一起运行?

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

VagrantFile sn-p:

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.

【问题讨论】:

    标签: vagrant virtualbox provisioning


    【解决方案1】:

    如果有人想使用 Windows Vagrant 盒子,那么他很可能想留在WinRM Vagrant configurationn。所以cdwilson 的答案指向 SSH 并没有让我满意。

    另外,mr-rogerscdwilson 都是错误的 - https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/windows/ 的 Vagrant 盒子预装和配置了 WinRM,看看 herehere

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

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

    为此,您需要手动启动虚拟机并出现超时错误,进入本地安全策略/网络列表管理策略,双击Network,转到标签Network Location 并将Location type 设置为private,将User permissions 设置为用户可以更改位置

    就是这样,现在假设correct Vagrantfile with WinRM configurationvagrant up 将正常工作而不会出现任何错误。

    但是mr-rogers是对的,请为microsoft developer FEEDBACK点赞!

    【讨论】:

      【解决方案2】:

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

      • 禁用防火墙(微软分发的盒子配置有 默认启用防火墙);
      • 将网络位置类型更改为“工作 network”(微软分发的盒子配置为“Public 网络”默认);
      • 启用 WinRM。

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

      【讨论】:

      • 该盒子已经激活了 WinRM (check my answer),防火墙对 Vagrant 来说应该不是问题。所以这里唯一需要做的就是改变网络列表管理策略。我认为您的 Ruby 实现看起来做得很好,但对于这个问题来说有点过分,对我来说有点“定制”。在我最新的 Windows Docker Container 实验中,我需要一个比提供的 modernIE 盒子更新的版本,并使用 packer.io 为我提供了一个 Vagrant 盒子,我现在更喜欢它而不是现代 IE 盒子......
      • @jonashackt 感谢您的反馈。虽然这里没有必要禁用防火墙,但在某些情况下有必要这样做。例如,如果您要安装将连接到 selenium 网格的 selenium 节点,则需要禁用防火墙或更改防火墙规则。
      【解决方案3】:

      你使用的是从 MS 下载的 virtualBox 镜像吗??

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

      根据我的经验,只有第一次执行遇到这种情况。

      【讨论】:

      • 是的,我确定我使用的是正确的盒子形式 MS。至于提示,我在运行vagrant up 时启动了 GUI,它加载时没有任何问题,没有任何提示或消息。只是像正常一样启动良好的窗口
      【解决方案4】:

      developer.microsoft.com 提供的 vagrant 机器本身是通过 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 可以很快重新打包这些机器。支持this developer FEEDBACK 可能会有所帮助。

      【讨论】:

        【解决方案5】:

        如上述答案中所述,必须启用 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
        

        【讨论】:

          【解决方案6】:

          正如其他答案中提到的,从https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ 下载的盒子默认启用 SSH。但是,它们与 vagrant 期望的默认 SSH 配置不匹配。

          具体来说,config.ssh.insert_key = false 在上述任何答案中均未提及:

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

          完成后,运行vagrant reload使设置生效。

          如果您希望 Vagrant 学习如何在此操作系统上插入密钥,请 使用有关您的环境的详细信息打开问题。

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

          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$ 
          

          【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-06-03
          • 1970-01-01
          相关资源
          最近更新 更多