How do I package a Vagrant box with custom Vagrant file (public network, RAM settings, etc.)?

33 views
Skip to first unread message

starrychloe S.

unread,
Apr 7, 2017, 1:20:13 AM4/7/17
to Vagrant
https://superuser.com/questions/1196330/how-do-i-package-a-vagrant-box-with-custom-vagrant-file-public-network-ram-set

I can't seem to package a box with 'public_network'. It always reverts to NAT. The memory settings stuck. Why not network settings?

Alvaro Miranda Aguilera

unread,
Apr 7, 2017, 2:23:37 AM4/7/17
to vagra...@googlegroups.com
hello

All the values of the base box, except the network should remain.

Vagrant will delete the network and create one nat for the first network, this is the vagrant way.

If you include a Vagrantfile in the box, your network will be the 2nd and so on.

You can include options on the box in a Vagrantfile, ie:

 ~/.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/virtualbox/Vagrantfile 


you can edit this file add what you need, aadjust the path to your box, and to test you can do a vagrant reload.


Vagrant by default merge 3 Vagrantfiles.


The local one in the project, the one in the box as I did show, and one global for every box, in  ~/.vagrant.d/Vagrantfile if present.


If you want this Vagrantfile to read other files you can use


# Load include vagrant file if it exists after the auto-generated

# so it can override any of the settings

include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)

load include_vagrantfile if File.exist?(include_vagrantfile)


this will load a file like:


 ~/.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/include/_Vagrantfile


Thanks

Alvaro.


On Fri, Apr 7, 2017 at 7:20 AM, starrychloe S. <starr...@oliveyou.net> wrote:
https://superuser.com/questions/1196330/how-do-i-package-a-vagrant-box-with-custom-vagrant-file-public-network-ram-set

I can't seem to package a box with 'public_network'. It always reverts to NAT. The memory settings stuck. Why not network settings?

--
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/48b2457d-2ad3-4c9d-b602-083286008ba1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

starrychloe S.

unread,
Apr 9, 2017, 11:44:41 PM4/9/17
to Vagrant
Hi, you said

If you include a Vagrantfile in the box, your network will be the 2nd and so on.
You can include options on the box in a Vagrantfile, ie:
 ~/.vagrant.d/boxes/hashicorp-VAGRANTSLASH-precise64/1.1.0/virtualbox/Vagrantfile 
you can edit this file add what you need, aadjust the path to your box, and to test you can do a vagrant reload.


And I did that but it didn't work. I edited the C:\Users\Chloe\.vagrant.d\boxes\nycmesh-qmp-openwrt\0\virtualbox\Vagrantfile file and added the line

  config.vm.network "public_network"


I ran 'vagrant init' and it generated a Vagrantfile with the line commented out!
  # config.vm.network "public_network"

I ran 'vagrant up' anyways, and it gave me this warning:
Warnings:
* Unknown network type 'public_network' will be ignored.

It also didn't create a bridged network in VirtualBox.

So my question is still, how do I package a bridged network in Vagrant?

Reply all
Reply to author
Forward
0 new messages