I have a specific Vagrantfile for a lucid32 box that installs some pretty standard packages (PHP/MySQL/Apache), does some specific port forwarding and so on, I set it up, checko
This is actually all working as intended. Vagrant loads multiple Vagrantfiles (not just the one from vagrant init
) when loading up, and the Vagrantfile packaged with a box is one of those. For more information, read about the "Vagrantfile Load Order" here: https://www.vagrantup.com/docs/vagrantfile/#load-order-and-merging
In a nutshell: Vagrant loads multiple Vagrantfiles in a specific order, and merges their configurations. The box Vagrantfile is loaded as part of this process prior to the root Vagrantfile (the one from vagrant init
).
There is no way currently to make a skeleton Vagrantfile that is generated with vagrant init
.
The configuration you put in the packaged Vagrantfile, such as port forwards, should be loading in properly, since when merging configurations, it should just append all the port forwards.
If this isn't happening, you should report a bug! But for the sake of a SO answer, this is how things are supposed to behave.
This code worked for me
vagrant package --output vagrant_example.box