在Linux上通过Vagrant将文件上传到虚拟机Windows Server时出错

时间:2018-07-05 16:44:32

标签: vagrant virtual-machine virtualbox

我在Linux CentOS上使用vagrant构建Windows Server 2012虚拟机,现在我得到了这个Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

  config.vm.define "MACHINE" do |db|
    db.vm.box = "win2k12r2en"
    db.vm.network "public_network", bridge: "p1p1", ip: "130.103.97.40", netmask: "255.255.252.0"

    db.vm.provider "virtualbox" do |vb|
        vb.memory = 4096
        vb.cpus = 2
        vb.name = "MACHINE"
    end
    db.vm.provision :file, source: '/home/vagrant/ambientes/machine/shell/Install.ps1', destination: "/tmp/"
    db.vm.provision :file, source: '/home/vagrant/ambientes/machine/shell/Lib-General.ps1', destination: "/tmp"
    db.vm.provision :file, source: '/home/vagrant/ambientes/machine/shell/continue.bat', destination: "/tmp"
    db.vm.provision :file, source: '/home/vagrant/ambientes/machine/shell/PHP_ZEND.zip', destination: "/tmp"

  end

end

运行脚本后,出现此错误:

The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir / -force

Stdout from the command:



Stderr from the command:

#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">mkdir : The path is not of a legal form._x000D__x000A_</S><S S="Error">At line:1 char:40_x000D__x000A_</S><S S="Error">+ $ProgressPreference='SilentlyContinue';mkdir / -force_x000D__x000A_</S><S S="Error">+                                        ~~~~~~~~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : InvalidArgument: (C:\:String) [New-Item], Argume _x000D__x000A_</S><S S="Error">   ntException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : CreateDirectoryArgumentError,Microsoft.PowerShel _x000D__x000A_</S><S S="Error">   l.Commands.NewItemCommand_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>

¿我在做什么错?,我是新来的游民,我遵循了guide。感谢您的宝贵时间。

1 个答案:

答案 0 :(得分:0)

我遵循了vahdet的指导:我读了github.com/hashicorp/vagrant/issues/7435,并做了一些变通办法:

  1. 通过“ C:\ tmp”替换文件供应目标“ / tmp”
  2. 我将“ PHP_ZEND.zip”文件上传到NEXUS服务器,然后通过由流浪脚本提供的powershell脚本下载到VM。

我做了第二点,因为当脚本运行zip文件的配置时,VM被迫关闭并自动销毁。

那解决了这个问题。