6

I can't figure out how to get included files from a packaged vagrant box.

The package is created with:

$ vagrant package --include mydirectory/ --output mypackage.box

Then the box is added

$ vagrant box add mypackage.box --name myPackageWithFiles

Then init and vagrant up

$ vagrant init myPackageWithFiles
$ vagrant up

But when I ssh into the newly created vagrant box, there is no "mydirectory/"

I do see it on my local machine though:

$ ls ~/.vagrant.d/boxes/myPackageWithFiles/0/virtualbox/include/
mydirectory/

How do I get this directory into my vagrant box? Do I have to add something to the Vagrantfile?

trotha01
  • 103
  • 1
  • 6

2 Answers2

0

Try adding the following to your Vagrant file, just before the end-line:

config.vm.synced_folder "~/.vagrant.d/boxes/myPackageWithFiles/0/virtualbox/include/mydirectory/", "~/mydirectory"

The first parameter is the local and the second is the remote path of the folder.


Also there are a lot of other parameters, which you can read about here.

balintant
  • 2,774
  • 1
  • 19
  • 33
  • 1
    If I were to go this route, I would probably use NFS instead. But this seems like a hack. I would rather find out why the files weren't included when I do vagrant init/up in the first place. – trotha01 Oct 14 '14 at 17:19
0

You need to pass the --base option to vagrant package. Otherwise it ignores your include options. If you are using VirtualBox, the argument to --base is the name of the virtual machine according to VirtualBox, which will be something like mybox_default_1470762777375_10784. Easiest way to find this name is to open the VirtualBox Manager GUI.

I am new to creating Vagrant boxes and found this behavior quite strange.

foobarbecue
  • 6,780
  • 4
  • 28
  • 54