Providing strollers using files included in the .box from the packer

I am creating a .box stroller file using a package. I have something like this in my .json config package:

"post-processors": [
//SNIP
  "include": [
    "./choco.ps1",
    "./vagrantUp.ps1",
    ]
]

It creates a .box, and if I manually unzip the file, I see that they are included in it. When I finish launching the "stray box", add Mybox http: // whatever "I even see them in my ~ / .vagrant.d / boxes / MyBox / 0 / virtualbox.

 ~ $ ls ~/.vagrant.d/boxes/MyBox/0/virtualbox/
Vagrantfile                 metadata.json
box.ovf                     packer-virtualbox-iso-1424829938-disk1.vmdk
choco.ps1                   vagrantUp.ps1

Also, in my firewall template, I have a line:

config.vm.provision  "shell", path: "vagrantUp.ps1"

Next, I want to initialize this machine. I have done the following:

~ $ cd ~/Vagrant
Vagrant $ Vagrant mkdir MyBox; cd MyBox
MyBox $ vagrant init MyBox
MyBox $ ls
VagrantFile

This file looks like the main stray by default, but at the top it mentions config.vm.box = "MyBox".

But if I vagrant up, I get the following error:

* `path` for shell provisioner does not exist on the host system: /Users/me/Vagrant/MyBox/vagrantUp.ps1

, VagrantFile in/Vagrant/MyBox VagrantFile ~/.vagrant.d/, , . /Vagrant/MyBox, ~/.vagrant.d/

, , ? ?

+4
2

Vagrantfile, . path : http://docs.vagrantup.com/v2/provisioning/shell.html

:

, , Vagrantfile .

, vagrant init vagrant init , , Vagrantfile. , - Packer Vagrant include:

, Vagrant. Vagrant ( ). Vagrantfile.

+2

Vagrantfile , __FILE__, Vagrantfile, path inline shell, script :

Vagrant.configure("2") do |config|
  # ... other configuration

  box_root = File.expand_path(File.dirname(__FILE__))
  config.vm.provision "shell",
    path: File.join(box_root, "vagrantUp.ps1")
end
+1

All Articles