kernel/v2: default all configs properly, remove config/default.rb
This commit is contained in:
parent
226dbccef8
commit
5030a16f84
|
@ -1,34 +0,0 @@
|
||||||
Vagrant.configure("2") do |config|
|
|
||||||
config.vagrant.host = :detect
|
|
||||||
|
|
||||||
config.ssh.forward_agent = false
|
|
||||||
config.ssh.forward_x11 = false
|
|
||||||
config.ssh.guest_port = 22
|
|
||||||
config.ssh.keep_alive = true
|
|
||||||
config.ssh.shell = "bash -l"
|
|
||||||
|
|
||||||
config.ssh.default.username = "vagrant"
|
|
||||||
|
|
||||||
config.vm.usable_port_range = (2200..2250)
|
|
||||||
config.vm.box_url = nil
|
|
||||||
config.vm.base_mac = nil
|
|
||||||
config.vm.boot_timeout = 300
|
|
||||||
config.vm.graceful_halt_timeout = 60
|
|
||||||
|
|
||||||
# Share SSH locally by default
|
|
||||||
config.vm.network :forwarded_port,
|
|
||||||
guest: 22,
|
|
||||||
host: 2222,
|
|
||||||
host_ip: "127.0.0.1",
|
|
||||||
id: "ssh",
|
|
||||||
auto_correct: true
|
|
||||||
|
|
||||||
# Share the root folder. This can then be overridden by
|
|
||||||
# other Vagrantfiles, if they wish.
|
|
||||||
config.vm.synced_folder ".", "/vagrant"
|
|
||||||
|
|
||||||
config.nfs.map_uid = :auto
|
|
||||||
config.nfs.map_gid = :auto
|
|
||||||
|
|
||||||
config.package.name = 'package.box'
|
|
||||||
end
|
|
|
@ -252,14 +252,13 @@ module Vagrant
|
||||||
# managing. Then, the actual individual configuration is loaded for
|
# managing. Then, the actual individual configuration is loaded for
|
||||||
# each {#machine} call.
|
# each {#machine} call.
|
||||||
@config_loader = Config::Loader.new(Config::VERSIONS, Config::VERSIONS_ORDER)
|
@config_loader = Config::Loader.new(Config::VERSIONS, Config::VERSIONS_ORDER)
|
||||||
@config_loader.set(:default, File.expand_path("config/default.rb", Vagrant.source_root))
|
|
||||||
@config_loader.set(:home, home_vagrantfile) if home_vagrantfile
|
@config_loader.set(:home, home_vagrantfile) if home_vagrantfile
|
||||||
@config_loader.set(:root, root_vagrantfile) if root_vagrantfile
|
@config_loader.set(:root, root_vagrantfile) if root_vagrantfile
|
||||||
|
|
||||||
# Make the initial call to get the "global" config. This is mostly
|
# Make the initial call to get the "global" config. This is mostly
|
||||||
# only useful to get the list of machines that we are managing.
|
# only useful to get the list of machines that we are managing.
|
||||||
# Because of this, we ignore any warnings or errors.
|
# Because of this, we ignore any warnings or errors.
|
||||||
@config_global, _ = @config_loader.load([:default, :home, :root])
|
@config_global, _ = @config_loader.load([:home, :root])
|
||||||
|
|
||||||
# Return the config
|
# Return the config
|
||||||
@config_global
|
@config_global
|
||||||
|
@ -329,7 +328,7 @@ module Vagrant
|
||||||
vm_config_key = "vm_#{name}".to_sym
|
vm_config_key = "vm_#{name}".to_sym
|
||||||
@config_loader.set(vm_config_key, sub_vm.config_procs)
|
@config_loader.set(vm_config_key, sub_vm.config_procs)
|
||||||
config, config_warnings, config_errors = \
|
config, config_warnings, config_errors = \
|
||||||
@config_loader.load([:default, :home, :root, vm_config_key])
|
@config_loader.load([:home, :root, vm_config_key])
|
||||||
|
|
||||||
# Determine the possible box formats for any boxes and find the box
|
# Determine the possible box formats for any boxes and find the box
|
||||||
box_formats = provider_options[:box_format] || provider
|
box_formats = provider_options[:box_format] || provider
|
||||||
|
@ -365,7 +364,7 @@ module Vagrant
|
||||||
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
|
box_config_key = "box_#{box.name}_#{box.provider}".to_sym
|
||||||
@config_loader.set(box_config_key, box_vagrantfile)
|
@config_loader.set(box_config_key, box_vagrantfile)
|
||||||
config, config_warnings, config_errors = \
|
config, config_warnings, config_errors = \
|
||||||
@config_loader.load([:default, box_config_key, :home, :root, vm_config_key])
|
@config_loader.load([box_config_key, :home, :root, vm_config_key])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -377,7 +376,7 @@ module Vagrant
|
||||||
provider_override_key = "vm_#{name}_#{config.vm.box}_#{provider}".to_sym
|
provider_override_key = "vm_#{name}_#{config.vm.box}_#{provider}".to_sym
|
||||||
@config_loader.set(provider_override_key, provider_overrides)
|
@config_loader.set(provider_override_key, provider_overrides)
|
||||||
config, config_warnings, config_errors = \
|
config, config_warnings, config_errors = \
|
||||||
@config_loader.load([:default, box_config_key, :home, :root, vm_config_key, provider_override_key])
|
@config_loader.load([box_config_key, :home, :root, vm_config_key, provider_override_key])
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.vm.box && original_box != config.vm.box
|
if config.vm.box && original_box != config.vm.box
|
||||||
|
|
|
@ -31,7 +31,8 @@ module VagrantPlugins
|
||||||
raise Vagrant::Errors::BoxNotFound, :name => box_name, :provider => box_provider if !box
|
raise Vagrant::Errors::BoxNotFound, :name => box_name, :provider => box_provider if !box
|
||||||
|
|
||||||
# Repackage the box
|
# Repackage the box
|
||||||
output_path = Pathname.new(File.expand_path(@env.config_global.package.name, FileUtils.pwd))
|
output_name = @env.config_global.package.name || "package.box"
|
||||||
|
output_path = Pathname.new(File.expand_path(output_name, FileUtils.pwd))
|
||||||
box.repackage(output_path)
|
box.repackage(output_path)
|
||||||
|
|
||||||
# Success, exit status 0
|
# Success, exit status 0
|
||||||
|
|
|
@ -5,6 +5,14 @@ module VagrantPlugins
|
||||||
class PackageConfig < Vagrant.plugin("2", :config)
|
class PackageConfig < Vagrant.plugin("2", :config)
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@name = UNSET_VALUE
|
||||||
|
end
|
||||||
|
|
||||||
|
def finalize!
|
||||||
|
@name = nil if @name == UNSET_VALUE
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"Package"
|
"Package"
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,12 +41,13 @@ module VagrantPlugins
|
||||||
|
|
||||||
@forward_agent = false if @forward_agent == UNSET_VALUE
|
@forward_agent = false if @forward_agent == UNSET_VALUE
|
||||||
@forward_x11 = false if @forward_x11 == UNSET_VALUE
|
@forward_x11 = false if @forward_x11 == UNSET_VALUE
|
||||||
@guest_port = nil if @guest_port == UNSET_VALUE
|
@guest_port = 22 if @guest_port == UNSET_VALUE
|
||||||
@keep_alive = false if @keep_alive == UNSET_VALUE
|
@keep_alive = true if @keep_alive == UNSET_VALUE
|
||||||
@proxy_command = nil if @proxy_command == UNSET_VALUE
|
@proxy_command = nil if @proxy_command == UNSET_VALUE
|
||||||
@pty = false if @pty == UNSET_VALUE
|
@pty = false if @pty == UNSET_VALUE
|
||||||
@shell = nil if @shell == UNSET_VALUE
|
@shell = "bash -l" if @shell == UNSET_VALUE
|
||||||
|
|
||||||
|
@default.username = "vagrant" if @default.username == UNSET_VALUE
|
||||||
@default.finalize!
|
@default.finalize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
@host = nil if @host == UNSET_VALUE
|
@host = :detect if @host == UNSET_VALUE
|
||||||
@host = @host.to_sym if @host
|
@host = @host.to_sym if @host
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ module VagrantPlugins
|
||||||
attr_reader :provisioners
|
attr_reader :provisioners
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@base_mac = UNSET_VALUE
|
||||||
@boot_timeout = UNSET_VALUE
|
@boot_timeout = UNSET_VALUE
|
||||||
@box_download_ca_cert = UNSET_VALUE
|
@box_download_ca_cert = UNSET_VALUE
|
||||||
@box_download_checksum = UNSET_VALUE
|
@box_download_checksum = UNSET_VALUE
|
||||||
|
@ -41,6 +42,7 @@ module VagrantPlugins
|
||||||
@guest = UNSET_VALUE
|
@guest = UNSET_VALUE
|
||||||
@hostname = UNSET_VALUE
|
@hostname = UNSET_VALUE
|
||||||
@provisioners = []
|
@provisioners = []
|
||||||
|
@usable_port_range = UNSET_VALUE
|
||||||
|
|
||||||
# Internal state
|
# Internal state
|
||||||
@__compiled_provider_configs = {}
|
@__compiled_provider_configs = {}
|
||||||
|
@ -299,6 +301,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
# Defaults
|
# Defaults
|
||||||
|
@base_mac = nil if @base_mac == UNSET_VALUE
|
||||||
@boot_timeout = 300 if @boot_timeout == UNSET_VALUE
|
@boot_timeout = 300 if @boot_timeout == UNSET_VALUE
|
||||||
@box_download_ca_cert = nil if @box_download_ca_cert == UNSET_VALUE
|
@box_download_ca_cert = nil if @box_download_ca_cert == UNSET_VALUE
|
||||||
@box_download_checksum = nil if @box_download_checksum == UNSET_VALUE
|
@box_download_checksum = nil if @box_download_checksum == UNSET_VALUE
|
||||||
|
@ -306,11 +309,15 @@ module VagrantPlugins
|
||||||
@box_download_client_cert = nil if @box_download_client_cert == UNSET_VALUE
|
@box_download_client_cert = nil if @box_download_client_cert == UNSET_VALUE
|
||||||
@box_download_insecure = false if @box_download_insecure == UNSET_VALUE
|
@box_download_insecure = false if @box_download_insecure == UNSET_VALUE
|
||||||
@box_url = nil if @box_url == UNSET_VALUE
|
@box_url = nil if @box_url == UNSET_VALUE
|
||||||
@graceful_halt_timeout = 300 if @graceful_halt_timeout == UNSET_VALUE
|
@graceful_halt_timeout = 60 if @graceful_halt_timeout == UNSET_VALUE
|
||||||
@guest = nil if @guest == UNSET_VALUE
|
@guest = nil if @guest == UNSET_VALUE
|
||||||
@hostname = nil if @hostname == UNSET_VALUE
|
@hostname = nil if @hostname == UNSET_VALUE
|
||||||
@hostname = @hostname.to_s if @hostname
|
@hostname = @hostname.to_s if @hostname
|
||||||
|
|
||||||
|
if @usable_port_range == UNSET_VALUE
|
||||||
|
@usable_port_range = (2200..2250)
|
||||||
|
end
|
||||||
|
|
||||||
# Make sure that the download checksum is a string and that
|
# Make sure that the download checksum is a string and that
|
||||||
# the type is a symbol
|
# the type is a symbol
|
||||||
@box_download_checksum = "" if !@box_download_checksum
|
@box_download_checksum = "" if !@box_download_checksum
|
||||||
|
@ -330,8 +337,18 @@ module VagrantPlugins
|
||||||
# default VM which just inherits the rest of the configuration.
|
# default VM which just inherits the rest of the configuration.
|
||||||
define(DEFAULT_VM_NAME) if defined_vm_keys.empty?
|
define(DEFAULT_VM_NAME) if defined_vm_keys.empty?
|
||||||
|
|
||||||
|
# Make sure the SSH forwarding is added if it doesn't exist
|
||||||
|
if !@__networks["ssh"]
|
||||||
|
network :forwarded_port,
|
||||||
|
guest: 22,
|
||||||
|
host: 2222,
|
||||||
|
host_ip: "127.0.0.1",
|
||||||
|
id: "ssh",
|
||||||
|
auto_correct: true
|
||||||
|
end
|
||||||
|
|
||||||
# Clean up some network configurations
|
# Clean up some network configurations
|
||||||
@__networks.each do |type, opts|
|
@__networks.values.each do |type, opts|
|
||||||
if type == :forwarded_port
|
if type == :forwarded_port
|
||||||
opts[:guest] = opts[:guest].to_i if opts[:guest]
|
opts[:guest] = opts[:guest].to_i if opts[:guest]
|
||||||
opts[:host] = opts[:host].to_i if opts[:host]
|
opts[:host] = opts[:host].to_i if opts[:host]
|
||||||
|
@ -360,11 +377,17 @@ module VagrantPlugins
|
||||||
@__compiled_provider_configs[name] = config
|
@__compiled_provider_configs[name] = config
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finaliez all the provisioners
|
# Finalize all the provisioners
|
||||||
@provisioners.each do |p|
|
@provisioners.each do |p|
|
||||||
p.config.finalize! if !p.invalid?
|
p.config.finalize! if !p.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# If we didn't share our current directory, then do it
|
||||||
|
# manually.
|
||||||
|
if !@__synced_folders["/vagrant"]
|
||||||
|
synced_folder(".", "/vagrant")
|
||||||
|
end
|
||||||
|
|
||||||
@__synced_folders.each do |id, options|
|
@__synced_folders.each do |id, options|
|
||||||
if options[:nfs]
|
if options[:nfs]
|
||||||
options[:type] = :nfs
|
options[:type] = :nfs
|
||||||
|
|
|
@ -14,8 +14,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
@map_uid = nil if @map_uid == UNSET_VALUE
|
@map_uid = :auto if @map_uid == UNSET_VALUE
|
||||||
@map_gid = nil if @map_gid == UNSET_VALUE
|
@map_gid = :auto if @map_gid == UNSET_VALUE
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
require File.expand_path("../../../../base", __FILE__)
|
||||||
|
|
||||||
|
require Vagrant.source_root.join("plugins/kernel_v2/config/package")
|
||||||
|
|
||||||
|
describe VagrantPlugins::Kernel_V2::PackageConfig do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
|
describe "#name" do
|
||||||
|
it "defaults to nil" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.name).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
require File.expand_path("../../../../base", __FILE__)
|
||||||
|
|
||||||
|
require Vagrant.source_root.join("plugins/kernel_v2/config/ssh")
|
||||||
|
|
||||||
|
describe VagrantPlugins::Kernel_V2::SSHConfig do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
|
describe "#default" do
|
||||||
|
it "defaults to vagrant username" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.default.username).to eq("vagrant")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,20 @@
|
||||||
|
require File.expand_path("../../../../base", __FILE__)
|
||||||
|
|
||||||
|
require Vagrant.source_root.join("plugins/kernel_v2/config/vagrant")
|
||||||
|
|
||||||
|
describe VagrantPlugins::Kernel_V2::VagrantConfig do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
|
describe "#host" do
|
||||||
|
it "defaults to :detect" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.host).to eq(:detect)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "symbolizes" do
|
||||||
|
subject.host = "foo"
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.host).to eq(:foo)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,6 +5,45 @@ require Vagrant.source_root.join("plugins/kernel_v2/config/vm")
|
||||||
describe VagrantPlugins::Kernel_V2::VMConfig do
|
describe VagrantPlugins::Kernel_V2::VMConfig do
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
||||||
|
describe "#base_mac" do
|
||||||
|
it "defaults properly" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.base_mac).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#box_url" do
|
||||||
|
it "defaults properly" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.box_url).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#network(s)" do
|
||||||
|
it "defaults to forwarding SSH" do
|
||||||
|
subject.finalize!
|
||||||
|
n = subject.networks
|
||||||
|
expect(n.length).to eq(1)
|
||||||
|
expect(n[0][0]).to eq(:forwarded_port)
|
||||||
|
expect(n[0][1][:guest]).to eq(22)
|
||||||
|
expect(n[0][1][:host]).to eq(2222)
|
||||||
|
expect(n[0][1][:host_ip]).to eq("127.0.0.1")
|
||||||
|
expect(n[0][1][:id]).to eq("ssh")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "turns all forwarded port ports to ints" do
|
||||||
|
subject.network "forwarded_port",
|
||||||
|
guest: "45", host: "4545", id: "test"
|
||||||
|
subject.finalize!
|
||||||
|
n = subject.networks.find do |type, data|
|
||||||
|
type == :forwarded_port && data[:id] == "test"
|
||||||
|
end
|
||||||
|
expect(n).to_not be_nil
|
||||||
|
expect(n[1][:guest]).to eq(45)
|
||||||
|
expect(n[1][:host]).to eq(4545)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#provision" do
|
describe "#provision" do
|
||||||
it "stores the provisioners" do
|
it "stores the provisioners" do
|
||||||
subject.provision("shell", inline: "foo")
|
subject.provision("shell", inline: "foo")
|
||||||
|
@ -100,4 +139,31 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#synced_folder(s)" do
|
||||||
|
it "defaults to sharing the current directory" do
|
||||||
|
subject.finalize!
|
||||||
|
sf = subject.synced_folders
|
||||||
|
expect(sf.length).to eq(1)
|
||||||
|
expect(sf).to have_key("/vagrant")
|
||||||
|
expect(sf["/vagrant"][:disabled]).to_not be
|
||||||
|
end
|
||||||
|
|
||||||
|
it "allows overriding settings on the /vagrant sf" do
|
||||||
|
subject.synced_folder(".", "/vagrant", disabled: true)
|
||||||
|
subject.finalize!
|
||||||
|
sf = subject.synced_folders
|
||||||
|
expect(sf.length).to eq(1)
|
||||||
|
expect(sf).to have_key("/vagrant")
|
||||||
|
expect(sf["/vagrant"][:disabled]).to be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#usable_port_range" do
|
||||||
|
it "defaults properly" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.usable_port_range).to eq(
|
||||||
|
Range.new(2200, 2250))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
require File.expand_path("../../../../base", __FILE__)
|
||||||
|
|
||||||
|
require Vagrant.source_root.join("plugins/synced_folders/nfs/config")
|
||||||
|
|
||||||
|
describe VagrantPlugins::SyncedFolderNFS::Config do
|
||||||
|
subject { described_class.new }
|
||||||
|
|
||||||
|
describe "#map_gid" do
|
||||||
|
it "defaults to :auto" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.map_gid).to eq(:auto)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#map_uid" do
|
||||||
|
it "defaults to nil" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.map_uid).to eq(:auto)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue