2

Host: Windows 7

Guest: Windows 8

I have a simple Vagrantfile that runs a powershell script to provision the guest. When I packaged the box, I saw that the file was added, but when I run vagrant up I get the error shell provisioner:* `path` for shell provisioner does not exist on the host system: D:/VirtualMachines/test/provision.ps1

I verified that provision.ps1 exists in the vagrant box location under the include directory.

So why isn't provision.ps1 getting copied to the location it needs to when i run vagrant up?

Vagrant file:

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
my_overflowed_stack
  • 564
  • 1
  • 10
  • 22
  • The [Vagrant docs](http://docs.vagrantup.com/v2/provisioning/shell.html) say that `path` is relative to the location of `Vagrantfile`. I have not created my own boxes yet, so may be off, but you might try dropping that file directly in the same location as `Vagrantfile` to see if it's picked up. – BrianC Sep 29 '14 at 04:52
  • It does get picked up when I manually add the file but that defeats the purpose. When I do ```vagrant box add [my box]``` it packages up my box and adds the powershell script to the box under the location: ```D:\VirtualMachines\vagrant\boxes\TestAgent\0\virtualbox\include``` My assumption is that when I run ```vagrant up``` in another directory (```D:\VirtualMachines\test\```) it should copy the provisioning file to this new location so it can be run. Am I wrong in that assumption? – my_overflowed_stack Sep 29 '14 at 14:36
  • 1
    Figured it out, see my answer below. – my_overflowed_stack Sep 29 '14 at 16:04

2 Answers2

6

The answer at How to package files with a Vagrant box? helped me.

Here is how I got it to work:

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

I had the same problem with Vagrant 1.8.1 on host Windows 8. After reading https://github.com/fideloper/Vaprobash/issues/30 I just renamed bootstrap.sh to bootstrp.sh, tried again and it worked. After renaming bootstrp.sh to bootstrap.sh it still worked.

I suppose in my case there was some strange invisible character in the filename.

Juri Sinitson
  • 1,445
  • 1
  • 14
  • 18