2014-09-25 102 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它仍然有效。

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