I’ve recently been using a lot of Vagrant machines at work, and needed to come up with a way to permit people to customise settings such as the developer’s own DNS zone, the amount of RAM and number of vCPUs assigned to each machine, etc.
In the Vagrantfile reference I noticed that Vagrant will merge several Vagrantfiles together on launch.
- First, the Vagrantfile packaged in the box
- The Vagrantfile in
- The Vagrantfile in the project directory
I knew that each Vagrantfile is just a Ruby script, so I decided to try adding a global variable in
~/.vagrant.d/Vagrantfile to see if it was inherited.
Then, in the project’s Vagrantfile I added:
That worked fine. I’m pretty sure it’s not the cleanest way, but it certainly is simple.