vagrantup 0.6.9 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/CHANGELOG.md +37 -0
  4. data/Gemfile +0 -8
  5. data/README.md +5 -0
  6. data/config/default.rb +1 -3
  7. data/contrib/README.md +12 -0
  8. data/contrib/emacs/vagrant.el +8 -0
  9. data/contrib/vim/vagrantfile.vim +9 -0
  10. data/lib/vagrant/action/box/download.rb +0 -1
  11. data/lib/vagrant/action/box.rb +11 -0
  12. data/lib/vagrant/action/builtin.rb +1 -2
  13. data/lib/vagrant/action/env.rb +7 -0
  14. data/lib/vagrant/action/general.rb +8 -0
  15. data/lib/vagrant/action/vm/boot.rb +3 -2
  16. data/lib/vagrant/action/vm/check_box.rb +1 -0
  17. data/lib/vagrant/action/vm/clean_machine_folder.rb +1 -1
  18. data/lib/vagrant/action/vm/destroy.rb +1 -1
  19. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +7 -12
  20. data/lib/vagrant/action/vm/network.rb +1 -1
  21. data/lib/vagrant/action/vm/nfs.rb +3 -1
  22. data/lib/vagrant/action/vm/provision.rb +14 -25
  23. data/lib/vagrant/action/vm/share_folders.rb +11 -4
  24. data/lib/vagrant/action/vm.rb +30 -0
  25. data/lib/vagrant/action.rb +12 -0
  26. data/lib/vagrant/command.rb +25 -0
  27. data/lib/vagrant/config/base.rb +17 -3
  28. data/lib/vagrant/config/ssh.rb +2 -2
  29. data/lib/vagrant/config/top.rb +61 -0
  30. data/lib/vagrant/config/vagrant.rb +1 -6
  31. data/lib/vagrant/config/vm/provisioner.rb +56 -0
  32. data/lib/vagrant/config/vm/sub_vm.rb +17 -0
  33. data/lib/vagrant/config/vm.rb +34 -20
  34. data/lib/vagrant/config.rb +78 -128
  35. data/lib/vagrant/downloaders/file.rb +1 -0
  36. data/lib/vagrant/downloaders/http.rb +9 -0
  37. data/lib/vagrant/downloaders.rb +7 -0
  38. data/lib/vagrant/environment.rb +26 -14
  39. data/lib/vagrant/errors.rb +5 -15
  40. data/lib/vagrant/hosts.rb +7 -0
  41. data/lib/vagrant/provisioners/base.rb +19 -1
  42. data/lib/vagrant/provisioners/chef.rb +31 -52
  43. data/lib/vagrant/provisioners/chef_server.rb +34 -10
  44. data/lib/vagrant/provisioners/chef_solo.rb +31 -9
  45. data/lib/vagrant/provisioners/puppet.rb +111 -60
  46. data/lib/vagrant/provisioners/puppet_server.rb +57 -0
  47. data/lib/vagrant/provisioners.rb +8 -0
  48. data/lib/vagrant/ssh/session.rb +81 -0
  49. data/lib/vagrant/ssh.rb +6 -76
  50. data/lib/vagrant/systems/base.rb +16 -1
  51. data/lib/vagrant/systems/debian.rb +26 -0
  52. data/lib/vagrant/systems/gentoo.rb +27 -0
  53. data/lib/vagrant/systems/linux/config.rb +21 -0
  54. data/lib/vagrant/systems/linux/error.rb +9 -0
  55. data/lib/vagrant/systems/linux.rb +14 -56
  56. data/lib/vagrant/systems/redhat.rb +31 -0
  57. data/lib/vagrant/systems.rb +9 -0
  58. data/lib/vagrant/test_helpers.rb +1 -1
  59. data/lib/vagrant/version.rb +1 -1
  60. data/lib/vagrant/vm.rb +25 -5
  61. data/lib/vagrant.rb +14 -18
  62. data/templates/chef_solo_solo.erb +11 -3
  63. data/templates/commands/init/Vagrantfile.erb +13 -11
  64. data/templates/locales/en.yml +76 -26
  65. data/templates/{network_entry.erb → network_entry_debian.erb} +0 -0
  66. data/templates/network_entry_gentoo.erb +7 -0
  67. data/templates/network_entry_redhat.erb +8 -0
  68. data/templates/ssh_config.erb +1 -1
  69. data/test/vagrant/action/vm/check_box_test.rb +1 -0
  70. data/test/vagrant/action/vm/clean_machine_folder_test.rb +6 -4
  71. data/test/vagrant/action/vm/destroy_test.rb +1 -1
  72. data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +10 -7
  73. data/test/vagrant/action/vm/nfs_test.rb +7 -1
  74. data/test/vagrant/action/vm/provision_test.rb +24 -79
  75. data/test/vagrant/action/vm/share_folders_test.rb +6 -1
  76. data/test/vagrant/command/helpers_test.rb +2 -2
  77. data/test/vagrant/config/base_test.rb +0 -6
  78. data/test/vagrant/config/vagrant_test.rb +0 -8
  79. data/test/vagrant/config/vm/provisioner_test.rb +92 -0
  80. data/test/vagrant/config/vm_test.rb +8 -0
  81. data/test/vagrant/config_test.rb +49 -89
  82. data/test/vagrant/downloaders/file_test.rb +18 -4
  83. data/test/vagrant/environment_test.rb +36 -12
  84. data/test/vagrant/provisioners/base_test.rb +28 -1
  85. data/test/vagrant/provisioners/chef_server_test.rb +50 -41
  86. data/test/vagrant/provisioners/chef_solo_test.rb +39 -16
  87. data/test/vagrant/provisioners/chef_test.rb +11 -81
  88. data/test/vagrant/provisioners/puppet_server_test.rb +69 -0
  89. data/test/vagrant/provisioners/puppet_test.rb +116 -69
  90. data/test/vagrant/{ssh_session_test.rb → ssh/session_test.rb} +0 -0
  91. data/test/vagrant/ssh_test.rb +20 -7
  92. data/test/vagrant/systems/base_test.rb +18 -0
  93. data/test/vagrant/systems/linux_test.rb +2 -2
  94. data/test/vagrant/vm_test.rb +33 -5
  95. data/vagrant.gemspec +6 -5
  96. metadata +38 -14
  97. data/lib/vagrant/action/vm/disable_networks.rb +0 -34
  98. data/lib/vagrant/util/glob_loader.rb +0 -24
  99. data/test/vagrant/action/vm/disable_networks_test.rb +0 -48
data/lib/vagrant/ssh.rb CHANGED
@@ -3,6 +3,8 @@ require 'net/ssh'
3
3
  require 'net/scp'
4
4
  require 'mario'
5
5
 
6
+ require 'vagrant/ssh/session'
7
+
6
8
  module Vagrant
7
9
  # Manages SSH access to a specific environment. Allows an environment to
8
10
  # replace the process with SSH itself, run a specific set of commands,
@@ -42,6 +44,7 @@ module Vagrant
42
44
  "-o StrictHostKeyChecking=no", "-o IdentitiesOnly=yes",
43
45
  "-i #{options[:private_key_path]}"]
44
46
  command_options << "-o ForwardAgent=yes" if env.config.ssh.forward_agent
47
+ command_options << "-o ForwardX11=yes" if env.config.ssh.forward_x11
45
48
 
46
49
  # Some hackery going on here. On Mac OS X Leopard (10.5), exec fails
47
50
  # (GH-51). As a workaround, we fork and wait. On all other platforms,
@@ -139,8 +142,7 @@ module Vagrant
139
142
 
140
143
  # Returns the port which is either given in the options hash or taken from
141
144
  # the config by finding it in the forwarded ports hash based on the
142
- # `config.ssh.forwarded_port_key` or use the default port given by `config.ssh.port`
143
- # when port forwarding isn't used.
145
+ # `config.ssh.forwarded_port_key`.
144
146
  def port(opts={})
145
147
  # Check if port was specified in options hash
146
148
  pnum = opts[:port]
@@ -158,80 +160,8 @@ module Vagrant
158
160
 
159
161
  return pnum.hostport if pnum
160
162
 
161
- # Fall back to the default
162
- return env.config.ssh.port
163
- end
164
- end
165
-
166
- class SSH
167
- # A helper class which wraps around `Net::SSH::Connection::Session`
168
- # in order to provide basic command error checking while still
169
- # providing access to the actual session object.
170
- class Session
171
- include Util::Retryable
172
-
173
- attr_reader :session
174
-
175
- def initialize(session)
176
- @session = session
177
- end
178
-
179
- # Executes a given command on the SSH session and blocks until
180
- # the command completes. This is an almost line for line copy of
181
- # the actual `exec!` implementation, except that this
182
- # implementation also reports `:exit_status` to the block if given.
183
- def exec!(command, options=nil, &block)
184
- options = {
185
- :error_check => true
186
- }.merge(options || {})
187
-
188
- block ||= Proc.new do |ch, type, data|
189
- check_exit_status(data, command, options) if type == :exit_status && options[:error_check]
190
-
191
- ch[:result] ||= ""
192
- ch[:result] << data if [:stdout, :stderr].include?(type)
193
- end
194
-
195
- retryable(:tries => 5, :on => IOError, :sleep => 0.5) do
196
- metach = session.open_channel do |channel|
197
- channel.exec(command) do |ch, success|
198
- raise "could not execute command: #{command.inspect}" unless success
199
-
200
- # Output stdout data to the block
201
- channel.on_data do |ch2, data|
202
- block.call(ch2, :stdout, data)
203
- end
204
-
205
- # Output stderr data to the block
206
- channel.on_extended_data do |ch2, type, data|
207
- block.call(ch2, :stderr, data)
208
- end
209
-
210
- # Output exit status information to the block
211
- channel.on_request("exit-status") do |ch2, data|
212
- block.call(ch2, :exit_status, data.read_long)
213
- end
214
- end
215
- end
216
-
217
- metach.wait
218
- metach[:result]
219
- end
220
- end
221
-
222
- # Checks for an erroroneous exit status and raises an exception
223
- # if so.
224
- def check_exit_status(exit_status, command, options=nil)
225
- if exit_status != 0
226
- options = {
227
- :_error_class => Errors::VagrantError,
228
- :_key => :ssh_bad_exit_status,
229
- :command => command
230
- }.merge(options || {})
231
-
232
- raise options[:_error_class], options
233
- end
234
- end
163
+ # This should NEVER happen.
164
+ raise Errors::SSHPortNotDetected
235
165
  end
236
166
  end
237
167
  end
@@ -15,6 +15,10 @@ module Vagrant
15
15
  # required by systems can and will change at any time. Any
16
16
  # changes will be noted on release notes.**
17
17
  class Base
18
+ class BaseError < Errors::VagrantError
19
+ error_namespace("vagrant.systems.base")
20
+ end
21
+
18
22
  include Vagrant::Util
19
23
 
20
24
  # The VM which this system is tied to.
@@ -27,6 +31,15 @@ module Vagrant
27
31
  @vm = vm
28
32
  end
29
33
 
34
+ # This method is automatically called when the system is available (when
35
+ # Vagrant can successfully SSH into the machine) to give the system a chance
36
+ # to determine the distro and return a distro-specific system.
37
+ #
38
+ # **Warning:** If a return value which subclasses from {Base} is
39
+ # returned, Vagrant will use it as the new system instance for the
40
+ # class.
41
+ def distro_dispatch; end
42
+
30
43
  # Halt the machine. This method should gracefully shut down the
31
44
  # operating system. This method will cause `vagrant halt` and associated
32
45
  # commands to _block_, meaning that if the machine doesn't halt
@@ -55,7 +68,9 @@ module Vagrant
55
68
 
56
69
  # Prepares the system for host only networks. This is called
57
70
  # once prior to any `enable_host_only_network` calls.
58
- def prepare_host_only_network; end
71
+ def prepare_host_only_network(net_options=nil)
72
+ raise BaseError, :_key => :unsupported_host_only
73
+ end
59
74
 
60
75
  # Setup the system by adding a new host only network. This
61
76
  # method should configure and bring up the interface for the
@@ -0,0 +1,26 @@
1
+ module Vagrant
2
+ module Systems
3
+ class Debian < Linux
4
+ def prepare_host_only_network(net_options=nil)
5
+ # Remove any previous host only network additions to the
6
+ # interface file.
7
+ vm.ssh.execute do |ssh|
8
+ # Clear out any previous entries
9
+ ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
10
+ ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
11
+ end
12
+ end
13
+
14
+ def enable_host_only_network(net_options)
15
+ entry = TemplateRenderer.render('network_entry_debian', :net_options => net_options)
16
+ vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
17
+
18
+ vm.ssh.execute do |ssh|
19
+ ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null")
20
+ ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/network/interfaces'")
21
+ ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ module Vagrant
2
+ module Systems
3
+ class Gentoo < Linux
4
+ def prepare_host_only_network(net_options=nil)
5
+ # Remove any previous host only network additions to the
6
+ # interface file.
7
+ vm.ssh.execute do |ssh|
8
+ # Clear out any previous entries
9
+ ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
10
+ ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/conf.d/net'")
11
+ end
12
+ end
13
+
14
+ def enable_host_only_network(net_options)
15
+ entry = TemplateRenderer.render('network_entry_gentoo', :net_options => net_options)
16
+ vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
17
+
18
+ vm.ssh.execute do |ssh|
19
+ ssh.exec!("sudo ln -s /etc/init.d/net.lo /etc/init.d/net.eth#{net_options[:adapter]}")
20
+ ssh.exec!("sudo /etc/init.d/net.eth#{net_options[:adapter]} stop 2> /dev/null")
21
+ ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/conf.d/net'")
22
+ ssh.exec!("sudo /etc/init.d/net.eth#{net_options[:adapter]} start")
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ module Vagrant
2
+ module Systems
3
+ class Linux < Vagrant::Systems::Base
4
+ # A custom config class which will be made accessible via `config.linux`
5
+ # This is not necessary for all system implementers, of course. However,
6
+ # generally, Vagrant tries to make almost every aspect of its execution
7
+ # configurable, and this assists that goal.
8
+ class LinuxConfig < Vagrant::Config::Base
9
+ configures :linux
10
+
11
+ attr_accessor :halt_timeout
12
+ attr_accessor :halt_check_interval
13
+
14
+ def initialize
15
+ @halt_timeout = 30
16
+ @halt_check_interval = 1
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module Vagrant
2
+ module Systems
3
+ class Linux < Vagrant::Systems::Base
4
+ class LinuxError < Errors::VagrantError
5
+ error_namespace("vagrant.systems.linux")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,32 +1,20 @@
1
+ require 'vagrant/systems/linux/error'
2
+ require 'vagrant/systems/linux/config'
3
+
1
4
  module Vagrant
2
5
  module Systems
3
- # A general Vagrant system implementation for "linux." In general,
4
- # any linux-based OS will work fine with this system, although its
5
- # not tested exhaustively. BSD or other based systems may work as
6
- # well, but that hasn't been tested at all.
7
- #
8
- # At any rate, this system implementation should server as an
9
- # example of how to implement any custom systems necessary.
10
6
  class Linux < Base
11
- # A custom config class which will be made accessible via `config.linux`
12
- # This is not necessary for all system implementers, of course. However,
13
- # generally, Vagrant tries to make almost every aspect of its execution
14
- # configurable, and this assists that goal.
15
- class LinuxConfig < Vagrant::Config::Base
16
- configures :linux
17
-
18
- attr_accessor :halt_timeout
19
- attr_accessor :halt_check_interval
20
-
21
- def initialize
22
- @halt_timeout = 30
23
- @halt_check_interval = 1
7
+ def distro_dispatch
8
+ vm.ssh.execute do |ssh|
9
+ return :debian if ssh.test?("cat /etc/debian_version")
10
+ return :gentoo if ssh.test?("cat /etc/gentoo-release")
11
+ return :redhat if ssh.test?("cat /etc/redhat-release")
24
12
  end
13
+
14
+ # Can't detect the distro, assume vanilla linux
15
+ nil
25
16
  end
26
17
 
27
- #-------------------------------------------------------------------
28
- # Overridden methods
29
- #-------------------------------------------------------------------
30
18
  def halt
31
19
  vm.env.ui.info I18n.t("vagrant.systems.linux.attempting_halt")
32
20
  vm.ssh.execute do |ssh|
@@ -57,43 +45,19 @@ module Vagrant
57
45
  folders.each do |name, opts|
58
46
  vm.ssh.execute do |ssh|
59
47
  ssh.exec!("sudo mkdir -p #{opts[:guestpath]}")
60
- ssh.exec!("sudo mount #{ip}:#{opts[:hostpath]} #{opts[:guestpath]}")
48
+ ssh.exec!("sudo mount #{ip}:#{opts[:hostpath]} #{opts[:guestpath]}", :error_class => LinuxError, :_key => :mount_nfs_fail)
61
49
  end
62
50
  end
63
51
  end
64
52
 
65
- def prepare_host_only_network
66
- # Remove any previous host only network additions to the
67
- # interface file.
68
- vm.ssh.execute do |ssh|
69
- # Verify debian/ubuntu
70
- ssh.exec!("cat /etc/debian_version", :error_class => LinuxError, :_key => :network_not_debian)
71
-
72
- # Clear out any previous entries
73
- ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
74
- ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
75
- end
76
- end
77
-
78
- def enable_host_only_network(net_options)
79
- entry = TemplateRenderer.render('network_entry', :net_options => net_options)
80
- vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
81
-
82
- vm.ssh.execute do |ssh|
83
- ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null")
84
- ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/network/interfaces'")
85
- ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
86
- end
87
- end
88
-
89
53
  #-------------------------------------------------------------------
90
54
  # "Private" methods which assist above methods
91
55
  #-------------------------------------------------------------------
92
56
  def mount_folder(ssh, name, guestpath, sleeptime=5)
93
57
  # Determine the permission string to attach to the mount command
94
58
  perms = []
95
- perms << "uid=#{vm.env.config.vm.shared_folder_uid}"
96
- perms << "gid=#{vm.env.config.vm.shared_folder_gid}"
59
+ perms << "uid=`id -u #{vm.env.config.vm.shared_folder_uid}`"
60
+ perms << "gid=`id -g #{vm.env.config.vm.shared_folder_gid}`"
97
61
  perms = " -o #{perms.join(",")}" if !perms.empty?
98
62
 
99
63
  attempts = 0
@@ -111,11 +75,5 @@ module Vagrant
111
75
  end
112
76
  end
113
77
  end
114
-
115
- class Linux < Base
116
- class LinuxError < Errors::VagrantError
117
- error_namespace("vagrant.systems.linux")
118
- end
119
- end
120
78
  end
121
79
  end
@@ -0,0 +1,31 @@
1
+ module Vagrant
2
+ module Systems
3
+ class Redhat < Linux
4
+ def prepare_host_only_network(net_options)
5
+ # Remove any previous host only network additions to the
6
+ # interface file.
7
+ vm.ssh.execute do |ssh|
8
+ # Clear out any previous entries
9
+ ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}")
10
+ ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{net_options[:adapter]} > /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
11
+ end
12
+ end
13
+
14
+ def enable_host_only_network(net_options)
15
+ entry = TemplateRenderer.render('network_entry_redhat', :net_options => net_options)
16
+
17
+ vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
18
+
19
+ vm.ssh.execute do |ssh|
20
+ interface_up = ssh.test?("/sbin/ifconfig eth#{net_options[:adapter]} | grep 'inet addr:'")
21
+ ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null") if interface_up
22
+ ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
23
+ ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+
31
+
@@ -0,0 +1,9 @@
1
+ # These can't be autoloaded because they have to register functionality
2
+ # with Vagrant core.
3
+ require 'vagrant/systems/base'
4
+ require 'vagrant/systems/linux'
5
+ require 'vagrant/systems/solaris'
6
+
7
+ require 'vagrant/systems/debian'
8
+ require 'vagrant/systems/gentoo'
9
+ require 'vagrant/systems/redhat'
@@ -31,8 +31,8 @@ module Vagrant
31
31
 
32
32
  str = args.shift || ""
33
33
  File.open(path.to_s, "w") do |f|
34
+ f.puts "ENV['VAGRANT_HOME'] = '#{home_path}'"
34
35
  f.puts "Vagrant::Config.run do |config|"
35
- f.puts "config.vagrant.home = '#{home_path}'"
36
36
  f.puts "config.vm.base_mac = 'foo' if !config.vm.base_mac"
37
37
  f.puts "config.vm.box = 'base'"
38
38
  f.puts str
@@ -2,5 +2,5 @@ module Vagrant
2
2
  # This will always be up to date with the current version of Vagrant,
3
3
  # since it is used to generate the gemspec and is also the source of
4
4
  # the version for `vagrant -v`
5
- VERSION = "0.6.9"
5
+ VERSION = "0.7.0"
6
6
  end
data/lib/vagrant/vm.rb CHANGED
@@ -3,7 +3,6 @@ module Vagrant
3
3
  include Vagrant::Util
4
4
 
5
5
  attr_reader :env
6
- attr_reader :system
7
6
  attr_reader :name
8
7
  attr_reader :vm
9
8
 
@@ -41,6 +40,8 @@ module Vagrant
41
40
  # Load the associated system.
42
41
  load_system!
43
42
  end
43
+
44
+ @loaded_system_distro = false
44
45
  end
45
46
 
46
47
  # Loads the system associated with the VM. The system class is
@@ -48,15 +49,21 @@ module Vagrant
48
49
  # can be found by reading the documentation on {Vagrant::Systems::Base}.
49
50
  #
50
51
  # **This method should never be called manually.**
51
- def load_system!
52
- system = env.config.vm.system
52
+ def load_system!(system=nil)
53
+ system ||= env.config.vm.system
53
54
 
54
55
  if system.is_a?(Class)
56
+ raise Errors::VMSystemError, :_key => :invalid_class, :system => system.to_s if !(system <= Systems::Base)
55
57
  @system = system.new(self)
56
- raise Errors::VMSystemError, :_key => :invalid_class, :system => system.to_s if !@system.is_a?(Systems::Base)
57
58
  elsif system.is_a?(Symbol)
58
59
  # Hard-coded internal systems
59
- mapping = { :linux => Systems::Linux, :solaris => Systems::Solaris }
60
+ mapping = {
61
+ :debian => Systems::Debian,
62
+ :gentoo => Systems::Gentoo,
63
+ :redhat => Systems::Redhat,
64
+ :linux => Systems::Linux,
65
+ :solaris => Systems::Solaris
66
+ }
60
67
 
61
68
  raise Errors::VMSystemError, :_key => :unknown_type, :system => system.to_s if !mapping.has_key?(system)
62
69
  @system = mapping[system].new(self)
@@ -65,6 +72,19 @@ module Vagrant
65
72
  end
66
73
  end
67
74
 
75
+ # Returns the system for this VM, loading the distro of the system if
76
+ # we can.
77
+ def system
78
+ if !@loaded_system_distro && created? && vm.running?
79
+ # Load the system distro for the first time
80
+ result = @system.distro_dispatch
81
+ load_system!(result)
82
+ @loaded_system_distro = true
83
+ end
84
+
85
+ @system
86
+ end
87
+
68
88
  # Access the {Vagrant::SSH} object associated with this VM.
69
89
  # On the initial call, this will initialize the object. On
70
90
  # subsequent calls it will reuse the existing object.
data/lib/vagrant.rb CHANGED
@@ -4,25 +4,21 @@ require 'i18n'
4
4
  require 'virtualbox'
5
5
 
6
6
  module Vagrant
7
- # TODO: Move more classes over to the autoload model. We'll
8
- # start small, but slowly move everything over.
9
-
7
+ autoload :Action, 'vagrant/action'
10
8
  autoload :Box, 'vagrant/box'
11
9
  autoload :BoxCollection, 'vagrant/box_collection'
12
10
  autoload :CLI, 'vagrant/cli'
13
11
  autoload :Config, 'vagrant/config'
14
12
  autoload :DataStore, 'vagrant/data_store'
13
+ autoload :Downloaders, 'vagrant/downloaders'
14
+ autoload :Environment, 'vagrant/environment'
15
15
  autoload :Errors, 'vagrant/errors'
16
+ autoload :Hosts, 'vagrant/hosts'
16
17
  autoload :Plugin, 'vagrant/plugin'
17
18
  autoload :TestHelpers, 'vagrant/test_helpers'
19
+ autoload :UI, 'vagrant/ui'
18
20
  autoload :Util, 'vagrant/util'
19
-
20
- module Command
21
- autoload :Base, 'vagrant/command/base'
22
- autoload :GroupBase, 'vagrant/command/group_base'
23
- autoload :Helpers, 'vagrant/command/helpers'
24
- autoload :NamedBase, 'vagrant/command/named_base'
25
- end
21
+ autoload :VM, 'vagrant/vm'
26
22
 
27
23
  # The source root is the path to the root directory of
28
24
  # the Vagrant gem.
@@ -34,13 +30,13 @@ end
34
30
  # Default I18n to load the en locale
35
31
  I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_root)
36
32
 
37
- # Load them up. One day we'll convert this to autoloads. Today
38
- # is not that day. Low hanging fruit for anyone wishing to do it.
39
- libdir = File.expand_path("lib/vagrant", Vagrant.source_root)
40
- Vagrant::Util::GlobLoader.glob_require(libdir, %w{
41
- downloaders/base provisioners/base provisioners/chef systems/base
42
- hosts/base})
43
-
44
- # Initialize the built-in actions and load the plugins.
33
+ # Load the things which must be loaded before anything else. Note that
34
+ # I'm not sure why 'vagrant/ssh' must be loaded. But if I don't, I get
35
+ # a very scary "unsupported cipher" error from net-ssh for no apparent reason.
36
+ require 'vagrant/command'
37
+ require 'vagrant/provisioners'
38
+ require 'vagrant/systems'
39
+ require 'vagrant/ssh'
40
+ require 'vagrant/version'
45
41
  Vagrant::Action.builtin!
46
42
  Vagrant::Plugin.load!
@@ -4,8 +4,16 @@ node_name "<%= node_name %>"
4
4
  file_cache_path "<%= provisioning_path %>"
5
5
  cookbook_path <%= cookbooks_path %>
6
6
  role_path <%= roles_path %>
7
- log_level <%= log_level.inspect %>
7
+ log_level <%= log_level.inspect %>
8
8
 
9
- <% if recipe_url %>
9
+ <% if recipe_url -%>
10
10
  recipe_url "<%= recipe_url %>"
11
- <% end %>
11
+ <% end -%>
12
+
13
+ http_proxy <%= http_proxy.inspect %>
14
+ http_proxy_user <%= http_proxy_user.inspect %>
15
+ http_proxy_pass <%= http_proxy_pass.inspect %>
16
+ https_proxy <%= https_proxy.inspect %>
17
+ https_proxy_user <%= https_proxy_user.inspect %>
18
+ https_proxy_pass <%= https_proxy_pass.inspect %>
19
+ no_proxy <%= no_proxy.inspect %>
@@ -24,18 +24,19 @@ Vagrant::Config.run do |config|
24
24
  # Share an additional folder to the guest VM. The first argument is
25
25
  # an identifier, the second is the path on the guest to mount the
26
26
  # folder, and the third is the path on the host to the actual folder.
27
- # config.vm.share_folder("v-data", "/vagrant_data", "../data")
27
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
28
28
 
29
29
  # Enable provisioning with chef solo, specifying a cookbooks path (relative
30
30
  # to this Vagrantfile), and adding some recipes and/or roles.
31
31
  #
32
- # config.vm.provisioner = :chef_solo
33
- # config.chef.cookbooks_path = "cookbooks"
34
- # config.chef.add_recipe "mysql"
35
- # config.chef.add_role "web"
32
+ # config.vm.provision :chef_solo do |chef|
33
+ # chef.cookbooks_path = "cookbooks"
34
+ # chef.add_recipe "mysql"
35
+ # chef.add_role "web"
36
36
  #
37
- # You may also specify custom JSON attributes:
38
- # config.chef.json = { :mysql_password => "foo" }
37
+ # # You may also specify custom JSON attributes:
38
+ # chef.json = { :mysql_password => "foo" }
39
+ # end
39
40
 
40
41
  # Enable provisioning with chef server, specifying the chef server URL,
41
42
  # and the path to the validation key (relative to this Vagrantfile).
@@ -47,9 +48,10 @@ Vagrant::Config.run do |config|
47
48
  # HTTP instead of HTTPS depending on your configuration. Also change the
48
49
  # validation key to validation.pem.
49
50
  #
50
- # config.vm.provisioner = :chef_server
51
- # config.chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
52
- # config.chef.validation_key_path = "ORGNAME-validator.pem"
51
+ # config.vm.provision :chef_server do |chef|
52
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
53
+ # chef.validation_key_path = "ORGNAME-validator.pem"
54
+ # end
53
55
  #
54
56
  # If you're using the Opscode platform, your validator client is
55
57
  # ORGNAME-validator, replacing ORGNAME with your organization name.
@@ -57,5 +59,5 @@ Vagrant::Config.run do |config|
57
59
  # IF you have your own Chef Server, the default validation client name is
58
60
  # chef-validator, unless you changed the configuration.
59
61
  #
60
- # config.chef.validation_client_name = "ORGNAME-validator"
62
+ # chef.validation_client_name = "ORGNAME-validator"
61
63
  end