vagrantfile in boxes

13 views
Skip to first unread message

andr...@gmail.com

unread,
Nov 16, 2017, 12:26:58 AM11/16/17
to Vagrant
This page on vagrant file format tells us:

Today, there are three different components:

  • Box File - This is a compressed (tartar.gzzip) file that is specific to a single provider and can contain anything. Vagrant core does not ever use the contents of this file. Instead, they are passed to the provider. Therefore, a VirtualBox box file has different contents from a VMware box file and so on.

  • Box Catalog Metadata - This is a JSON document (typically exchanged during interactions with HashiCorp's Vagrant Cloud) that specifies the name of the box, a description, available versions, available providers, and URLs to the actual box files (next component) for each provider and version. If this catalog metadata does not exist, a box file can still be added directly, but it will not support versioning and updating.

  • Box Information - This is a JSON document that can provide additional information about the box that displays when a user runs vagrant box list -i. More information is provided here.

Note, how vargrantfile is not mentioned anywhere in this description or elsewhere on the page.

Yet, if we read this page from packer documentation we can read:

vagrantfile_template (string) - Path to a template to use for the Vagrantfile that is packaged with the box. 

This implies that a vagrantfile can indeed be packaged with the box.

How does this work? Why one includes vagrantfile with a box and how this vagrantfile is used and how it interact with the normal vagrantfile which we are using with `vagrant up`?

Alvaro Miranda Aguilera

unread,
Nov 16, 2017, 6:14:03 AM11/16/17
to vagra...@googlegroups.com
Hello

lets say your user is home is /home/user

and you have a project like this

/home/user/myproject

Vagrant home directory will be

/home/user/.vagrant.d

The box or your setup can include multiples Vagrantfiles that are all read and joined in memory

/home/user/myproject/Vagrantfile  # this is your local project Vagrantfile, things here are used only is this local project

/home/user/.vagrant.d/boxes/<box>/<version/provider>/Vagrantfile  # this is your box Vagrantfile , will be used in all the projects that use this box.

/home/user/.vagrant.d/Vagrantfile  # this is your global Vagrantfile , will be used in all the projects




Seems you are right that the box one is not in the documentation.
Will check and came back with something.



When a box includes a Vagrantfile, its to set something at box level, say you don't want to use Virtualbox shared folder and want to use/force rsync.


Thats the one that packer can include.

ie:

$ find ~/.vagrant.d/boxes/ -name Vagrantfile
/c/Users/kikitux/.vagrant.d/boxes/bento-VAGRANTSLASH-ubuntu-16.04/201708.22.0/virtualbox/Vagrantfile
/c/Users/kikitux/.vagrant.d/boxes/centos-VAGRANTSLASH-7/1611.01/virtualbox/Vagrantfile
/c/Users/kikitux/.vagrant.d/boxes/ferventcoder-VAGRANTSLASH-win2012r2-x64-nocm/1.0.0/virtualbox/Vagrantfile
/c/Users/kikitux/.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/virtualbox/Vagrantfile
/c/Users/kikitux/.vagrant.d/boxes/iseo_tech-VAGRANTSLASH-CentOS-7-x86_64-DVD-1503-01/7.1.1/virtualbox/Vagrantfile
/c/Users/kikitux/.vagrant.d/boxes/oraclelinux7/0/virtualbox/Vagrantfile
/c/Users/kikitux/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-trusty64/20171026.0.0/virtualbox/Vagrantfile



example of utilization:

$ cat /c/Users/kikitux/.vagrant.d/boxes/centos-VAGRANTSLASH-7/1611.01/virtualbox/Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.base_mac = "525400225b53"
  config.vm.synced_folder ".", "/vagrant", type: "rsync"
end






Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/0248837a-7d7d-484d-8786-e8664b3e8eff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

andr...@gmail.com

unread,
Nov 16, 2017, 1:06:18 PM11/16/17
to Vagrant
Thank you, that makes sense!
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages