Closed GermanDZ closed 10 years ago
I was just about to work on something like this. My solution was, instead of concatenating the extra config on install, have the Vagrantfile require
an extra ruby module. Something like:
Vagrant.configure("2") do |config|
# ...
end
vagrantfile_extra = "#{ENV['VAGRANT_CWD']}/Vagrantfile_extra.rb"
if File.exists?(vagrantfile_extra) then
require vagrantfile_extra
end
The Vagrantfile_extra.rb file needs to be a valid Vagrantfile with a Vagrant.configure
block.
Sounds pretty good, I am not a Vagrant expert. Is the order of config sentences important? we could need something like "pre-config", "config" and "post-config"?
We could add a second extra configuration file for easy port forwarding: a YAML file. We could use the same rules as @zaim propose for checking if the file exist and use it only if it's present.
The structure could be somethings like:
ports:
railsApp1:
guest: 3000
host: 3000
railsApp2:
guest: 5000
host: 8080
The yaml module in ruby could use it and makes an easy configuration for a dev environnement.
I prefer @zaim's solution, then we don't necessarily have to generate Vagrantfile on every run.
Squashed and merged in 392e5e56df492d4c662ba2155859b43cb67453e1 . Thanks!
Adding a file name
Vagrantfile_extra.rb
into the~/.docker-osx
directory will allow to keep some additional config for Vagrant without messing up too much the installation.I used it for port forwarding some extra ports.
My
Vagrantfile_extra.rb
looks like:This dirty patch doesn't want to be a final solution, just an idea to open the discussion about extend and customisation methods.