How to install a box with a packaged Vagrantfile?

570 views
Skip to first unread message

Richard Wellum

unread,
Feb 2, 2016, 2:09:37 PM2/2/16
to Vagrant
I used vagrant package to create the following:

$ tar xfv *.box

x ./box-disk1.vmdk

x ./box.ovf

x ./include/

x ./include/_Vagrantfile

x ./Vagrantfile


The ./Vagrantfile correctly loads the included Vagrantfile:


cat Vagrantfile 

Vagrant::Config.run do |config|

  # This Vagrantfile is auto-generated by `vagrant package` to contain

  # the MAC address of the box. Custom configuration should be placed in

  # the actual `Vagrantfile` in this box.

  config.vm.base_mac = "080027111C84"

end


# 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)


How do I install this box so that it runs ./Vagrantfile and then finds the embedded Vagrant file. I've tried:


 vagrant init .mybox.box

 vagrant up


And:

 cd to box location

 vagrant init boxname

 vagrant box add --name boxname mybox.box

 vagrant up


And:

 vagrant box add --name boxname mybox.box

 vagrant init boxname

 vagrant up


The embedded Vagrantfile is never ran. I think of these all, the first should work as it doesn't create a default Vagrant init file.


vagrant version 1.8.1


Thanks!

Alvaro Miranda Aguilera

unread,
Feb 3, 2016, 5:41:49 AM2/3/16
to vagra...@googlegroups.com
Hello,

Can you try using vagrant package?

z2-3:~ kikitux$ vagrant package -h

Usage: vagrant package [options] [name]


Options:


        --base NAME                  Name of a VM in virtualbox to package as a base box

        --output NAME                Name of the file to output

        --include FILE...            Additional files to package with the box

        --vagrantfile FILE           Vagrantfile to package with the box

    -h, --help                       Print this help

z2-3:~ kikitux$ 


Thanks

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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/84fe5ffc-61c8-43fb-9523-3849d658f002%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Wellum

unread,
Feb 3, 2016, 8:32:01 AM2/3/16
to Vagrant
Hi,

I did use vagrant package to create the box.

And the vagrant file got packaged correctly (./include/Vagrantfile and ./Vagrantfile (which points to the former)) as the above files show.

But when I use the box, the embedded vagrant file is not getting run - that's my issue.

If I do a 'vagrant init <name>' it creates a ./Vagrantfile that does not point to my embedded Vagrant file in the box.

So my question is how do I run my box, but use the .Vagrantfile included in the box that points to ./include/Vagrantfile (essentially ignoring or not doing 'vagrant init')?

I know it must be possible because why else have the --vagrantfile option.

Thanks,

||Rich

Richard Wellum

unread,
Feb 3, 2016, 9:18:33 PM2/3/16
to Vagrant
Figured it out. There was an error in my Vagrantfile. It was being run, but the section of config I used to configure my ssh settings was not getting reached.

Thanks,

||Rich
Reply all
Reply to author
Forward
0 new messages