2014-09-25 47 views
2

主持人:Windows 7的流浪配置脚本没有被复制到主机位置

游客:Windows 8的

我有一个运行PowerShell脚本,以提供客人一个简单的Vagrantfile。当我打包的箱子,我看到添加的文件,但是当我运行vagrant up我得到的错误shell provisioner:* `path` for shell provisioner does not exist on the host system: D:/VirtualMachines/test/provision.ps1

我核实,provision.ps1存在于include目录下的流浪汉框的位置。

那么为什么当我运行vagrant up时,provision.ps1复制到它所需的位置?

流浪文件:

VAGRANTFILE_API_VERSION = "2" 
modified_name = ENV["COMPUTERNAME"][0..12] 
comp_name = modified_name + "TA" 

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 
    config.vm.box = "base" 
    config.vm.hostname = comp_name 
    config.vm.communicator = "winrm" 
    config.vm.network "forwarded_port", host: 3389, guest: 3389, auto_correct: true 
    config.vm.provision "shell", path: "provision.ps1" 
end 
+0

[Vagrant文​​档](http://docs.vagrantup.com/v2/provisioning/shell.html)表示'path'与'Vagrantfile'的位置有关。我还没有创建自己的盒子,因此可能会关闭,但是您可以直接在'Vagrantfile'的相同位置直接删除该文件,以查看它是否被拾取。 – BrianC 2014-09-29 04:52:11

+0

当我手动添加文件时,它确实会被拾取,但这会破坏目的。 当我做'''vagrant box添加[我的盒子]'''它打包我的盒子,并将powershell脚本添加到位置下的盒子:'''D:\ VirtualMachines \ vagrant \ boxes \ TestAgent \ 0 \ virtualbox \ include''' 我的假设是,当我在另一个目录('''D:\ VirtualMachines \ test“)中运行'vagrant up''时,它应该将配置文件复制到这个新的所以它可以运行。这个假设我错了吗? – 2014-09-29 14:36:18

+1

想通了,看我下面的答案。 – 2014-09-29 16:04:58

回答

6

How to package files with a Vagrant box?答案帮助了我。

这是我如何得到它的工作:

config.vm.provision "shell" do |s| 
    p = File.expand_path("../", __FILE__) 
    s.path = p + "\\provision.ps1" 
    end 
1

我在主机上有同样的问题与流浪1.8.1的Windows 8.读https://github.com/fideloper/Vaprobash/issues/30我只是改名bootstrap.shbootstrp后。嘘,再次尝试,它的工作。重命名后bootstrp.shbootstrap.sh它仍然有效。

我想在我的情况下,文件名中有一些奇怪的不可见字符。