VAGRANT_VAGRANTFILE env var to specify alternate filename for Vfile

This commit is contained in:
Mitchell Hashimoto 2013-02-23 12:07:23 -08:00
parent 1bda157188
commit 499d1ff8bf
3 changed files with 20 additions and 3 deletions

View File

@ -38,6 +38,8 @@ FEATURES:
VirtualBox provider config. [GH-1126]
- `vagrant ssh` will execute an `ssh` binary on Windows if it is on
your PATH. [GH-933]
- The environmental variable `VAGRANT_VAGRANTFILE` can be used to
specify an alternate Vagrantfile filename.
IMPROVEMENTS / BUG FIXES:

View File

@ -81,11 +81,11 @@ module Vagrant
# Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
# those continue to work as well, but anything custom will take precedence.
opts[:vagrantfile_name] ||= []
opts[:vagrantfile_name] ||= ENV["VAGRANT_VAGRANTFILE"] if \
ENV.has_key?("VAGRANT_VAGRANTFILE")
opts[:vagrantfile_name] ||= ["Vagrantfile", "vagrantfile"]
opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if \
!opts[:vagrantfile_name].is_a?(Array)
opts[:vagrantfile_name] = ["Vagrantfile", "vagrantfile"] if \
opts[:vagrantfile_name].empty?
# Set instance variables for all the configuration parameters.
@cwd = opts[:cwd]

View File

@ -284,6 +284,21 @@ VF
env.config_global.ssh.port.should == 200
end
it "should load from a custom Vagrantfile specified by env var" do
environment = isolated_environment do |env|
env.file("some_other_name", <<-VF)
Vagrant.configure("2") do |config|
config.ssh.port = 400
end
VF
end
env = with_temp_env("VAGRANT_VAGRANTFILE" => "some_other_name") do
environment.create_vagrant_env
end
env.config_global.ssh.port.should == 400
end
end
describe "ui" do