vagrant 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.gitignore +3 -1
  2. data/CHANGELOG.md +16 -1
  3. data/lib/vagrant/action.rb +1 -1
  4. data/lib/vagrant/action/box/download.rb +1 -1
  5. data/lib/vagrant/action/box/unpackage.rb +1 -1
  6. data/lib/vagrant/action/box/verify.rb +1 -1
  7. data/lib/vagrant/action/builder.rb +1 -1
  8. data/lib/vagrant/action/general/package.rb +10 -4
  9. data/lib/vagrant/action/vm/boot.rb +1 -1
  10. data/lib/vagrant/action/vm/check_box.rb +2 -2
  11. data/lib/vagrant/action/vm/export.rb +1 -1
  12. data/lib/vagrant/action/vm/forward_ports.rb +8 -8
  13. data/lib/vagrant/action/vm/import.rb +1 -1
  14. data/lib/vagrant/action/vm/network.rb +6 -2
  15. data/lib/vagrant/action/vm/nfs.rb +3 -3
  16. data/lib/vagrant/action/vm/provision.rb +4 -3
  17. data/lib/vagrant/action/warden.rb +5 -4
  18. data/lib/vagrant/box.rb +1 -1
  19. data/lib/vagrant/command/box.rb +2 -2
  20. data/lib/vagrant/command/helpers.rb +5 -5
  21. data/lib/vagrant/command/package.rb +3 -3
  22. data/lib/vagrant/command/ssh.rb +3 -3
  23. data/lib/vagrant/command/ssh_config.rb +2 -2
  24. data/lib/vagrant/config.rb +2 -2
  25. data/lib/vagrant/config/vm.rb +7 -0
  26. data/lib/vagrant/downloaders/file.rb +1 -1
  27. data/lib/vagrant/downloaders/http.rb +1 -1
  28. data/lib/vagrant/environment.rb +21 -5
  29. data/lib/vagrant/errors.rb +16 -0
  30. data/lib/vagrant/hosts/bsd.rb +1 -1
  31. data/lib/vagrant/provisioners/chef.rb +2 -2
  32. data/lib/vagrant/provisioners/chef_server.rb +3 -3
  33. data/lib/vagrant/provisioners/puppet.rb +85 -0
  34. data/lib/vagrant/ssh.rb +23 -21
  35. data/lib/vagrant/systems/linux.rb +1 -1
  36. data/lib/vagrant/systems/solaris.rb +7 -4
  37. data/lib/vagrant/util/hash_with_indifferent_access.rb +1 -1
  38. data/lib/vagrant/util/platform.rb +18 -1
  39. data/lib/vagrant/version.rb +1 -1
  40. data/lib/vagrant/vm.rb +4 -4
  41. data/templates/locales/en.yml +34 -4
  42. data/test/vagrant/action/general/package_test.rb +14 -0
  43. data/test/vagrant/action/vm/network_test.rb +18 -0
  44. data/test/vagrant/action/vm/provision_test.rb +4 -0
  45. data/test/vagrant/command/helpers_test.rb +2 -2
  46. data/test/vagrant/config/vm_test.rb +8 -0
  47. data/test/vagrant/provisioners/puppet_test.rb +135 -0
  48. data/test/vagrant/ssh_test.rb +18 -10
  49. data/test/vagrant/vm_test.rb +2 -1
  50. metadata +6 -5
  51. data/Gemfile.lock +0 -76
@@ -183,6 +183,13 @@ module Vagrant
183
183
  error_key(:not_found, "vagrant.actions.vm.network")
184
184
  end
185
185
 
186
+ # Note: This is a temporary error for Windows users while host-only
187
+ # networking doesn't quite work.
188
+ class NetworkNotImplemented < VagrantError
189
+ status_code(49)
190
+ error_key(:windows_not_implemented, "vagrant.actions.vm.network")
191
+ end
192
+
186
193
  class NFSHostRequired < VagrantError
187
194
  status_code(31)
188
195
  error_key(:host_required, "vagrant.actions.vm.nfs")
@@ -283,6 +290,15 @@ module Vagrant
283
290
  error_key(:virtualbox_not_detected)
284
291
  end
285
292
 
293
+ # Note that this is a subclass of VirtualBoxNotDetected, so developers
294
+ # who script Vagrant or use it as a library in any way can rescue from
295
+ # "VirtualBoxNotDetected" and catch both errors, which represent the
296
+ # same thing. This subclass simply has a specialized error message.
297
+ class VirtualBoxNotDetected_Win64 < VirtualBoxNotDetected
298
+ status_code(48)
299
+ error_key(:virtualbox_not_detected_win64)
300
+ end
301
+
286
302
  class VMBaseMacNotSpecified < VagrantError
287
303
  status_code(47)
288
304
  error_key(:no_base_mac, "vagrant.actions.vm.match_mac")
@@ -42,7 +42,7 @@ module Vagrant
42
42
  if $?.to_i == 0
43
43
  # Use sed to just strip out the block of code which was inserted
44
44
  # by Vagrant
45
- system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -i bak /etc/exports")
45
+ system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -ibak /etc/exports")
46
46
  end
47
47
  end
48
48
  end
@@ -1,11 +1,11 @@
1
1
  module Vagrant
2
2
  module Provisioners
3
- # This class is a base class where the common functinality shared between
3
+ # This class is a base class where the common functionality shared between
4
4
  # chef-solo and chef-client provisioning are stored. This is **not an actual
5
5
  # provisioner**. Instead, {ChefSolo} or {ChefServer} should be used.
6
6
  class Chef < Base
7
7
  def prepare
8
- raise ChefError.new(:invalid_provisioner)
8
+ raise ChefError, :invalid_provisioner
9
9
  end
10
10
 
11
11
  def verify_binary(binary)
@@ -6,9 +6,9 @@ module Vagrant
6
6
  # with a chef server.
7
7
  class ChefServer < Chef
8
8
  def prepare
9
- raise ChefError.new(:server_validation_key_required) if env.config.chef.validation_key_path.nil?
10
- raise ChefError.new(:server_validation_key_doesnt_exist) if !File.file?(validation_key_path)
11
- raise ChefError.new(:server_url_required) if env.config.chef.chef_server_url.nil?
9
+ raise ChefError, :server_validation_key_required if env.config.chef.validation_key_path.nil?
10
+ raise ChefError, :server_validation_key_doesnt_exist if !File.file?(validation_key_path)
11
+ raise ChefError, :server_url_required if env.config.chef.chef_server_url.nil?
12
12
  end
13
13
 
14
14
  def provision!
@@ -0,0 +1,85 @@
1
+ module Vagrant
2
+ module Provisioners
3
+
4
+ class PuppetError < Vagrant::Errors::VagrantError
5
+ error_namespace("vagrant.provisioners.puppet")
6
+ end
7
+
8
+ class PuppetConfig < Vagrant::Config::Base
9
+ configures :puppet
10
+
11
+ attr_accessor :manifest_file
12
+ attr_accessor :manifests_path
13
+ attr_accessor :pp_path
14
+ attr_accessor :options
15
+
16
+ def initialize
17
+ @manifest_file = ""
18
+ @manifests_path = "manifests"
19
+ @pp_path = "/tmp/vagrant-puppet"
20
+ @options = []
21
+ end
22
+ end
23
+
24
+ class Puppet < Base
25
+ def prepare
26
+ check_manifest_dir
27
+ share_manifests
28
+ end
29
+
30
+ def provision!
31
+ verify_binary("puppet")
32
+ create_pp_path
33
+ set_manifest
34
+ run_puppet_client
35
+ end
36
+
37
+ def check_manifest_dir
38
+ Dir.mkdir(env.config.puppet.manifests_path) unless File.directory?(env.config.puppet.manifests_path)
39
+ end
40
+
41
+ def share_manifests
42
+ env.config.vm.share_folder("manifests", env.config.puppet.pp_path, env.config.puppet.manifests_path)
43
+ end
44
+
45
+ def verify_binary(binary)
46
+ vm.ssh.execute do |ssh|
47
+ ssh.exec!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
48
+ end
49
+ end
50
+
51
+ def create_pp_path
52
+ vm.ssh.execute do |ssh|
53
+ ssh.exec!("sudo mkdir -p #{env.config.puppet.pp_path}")
54
+ ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.puppet.pp_path}")
55
+ end
56
+ end
57
+
58
+ def set_manifest
59
+ @manifest = !env.config.puppet.manifest_file.empty? ? env.config.puppet.manifest_file : "#{env.config.vm.box}.pp"
60
+
61
+ if File.exists?("#{env.config.puppet.manifests_path}/#{@manifest}")
62
+ env.ui.info I18n.t("vagrant.provisioners.puppet.manifest_to_run", :manifest => @manifest)
63
+ return @manifest
64
+ else
65
+ raise PuppetError, :_key => :manifest_missing, :manifest => @manifest
66
+ end
67
+ end
68
+
69
+ def run_puppet_client
70
+ options = env.config.puppet.options
71
+ options = options.join(" ") if options.is_a?(Array)
72
+ command = "cd #{env.config.puppet.pp_path} && sudo -E puppet #{options} #{@manifest}"
73
+
74
+ env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")
75
+
76
+ vm.ssh.execute do |ssh|
77
+ ssh.exec!(command) do |channel, type, data|
78
+ ssh.check_exit_status(data, command) if type == :exit_status
79
+ env.ui.info("#{data}: #{type}") if type != :exit_status
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,3 +1,4 @@
1
+ require 'timeout'
1
2
  require 'net/ssh'
2
3
  require 'net/scp'
3
4
  require 'mario'
@@ -22,11 +23,11 @@ module Vagrant
22
23
  # of options which override the configuration values.
23
24
  def connect(opts={})
24
25
  if Mario::Platform.windows?
25
- raise Errors::SSHUnavailableWindows.new(:key_path => env.config.ssh.private_key_path,
26
- :ssh_port => port(opts))
26
+ raise Errors::SSHUnavailableWindows, :key_path => env.config.ssh.private_key_path,
27
+ :ssh_port => port(opts)
27
28
  end
28
29
 
29
- raise Errors::SSHUnavailable.new if !Kernel.system("which ssh > /dev/null 2>&1")
30
+ raise Errors::SSHUnavailable if !Kernel.system("which ssh > /dev/null 2>&1")
30
31
 
31
32
  options = {}
32
33
  options[:port] = port(opts)
@@ -60,12 +61,12 @@ module Vagrant
60
61
  # Merge in any additional options
61
62
  opts = opts.dup
62
63
  opts[:forward_agent] = true if env.config.ssh.forward_agent
64
+ opts[:port] ||= port
63
65
 
64
66
  retryable(:tries => 5, :on => Errno::ECONNREFUSED) do
65
67
  Net::SSH.start(env.config.ssh.host,
66
68
  env.config.ssh.username,
67
- opts.merge( :port => port,
68
- :keys => [env.config.ssh.private_key_path],
69
+ opts.merge( :keys => [env.config.ssh.private_key_path],
69
70
  :user_known_hosts_file => [],
70
71
  :paranoid => false,
71
72
  :config => false)) do |ssh|
@@ -73,7 +74,7 @@ module Vagrant
73
74
  end
74
75
  end
75
76
  rescue Errno::ECONNREFUSED
76
- raise Errors::SSHConnectionRefused.new
77
+ raise Errors::SSHConnectionRefused
77
78
  end
78
79
 
79
80
  # Uploads a file from `from` to `to`. `from` is expected to be a filename
@@ -92,21 +93,22 @@ module Vagrant
92
93
  #
93
94
  # @return [Boolean]
94
95
  def up?
95
- check_thread = Thread.new do
96
- begin
97
- Thread.current[:result] = false
98
- execute(:timeout => env.config.ssh.timeout) do |ssh|
99
- Thread.current[:result] = true
100
- end
101
- rescue Errno::ECONNREFUSED, Net::SSH::Disconnect, Errors::SSHConnectionRefused
102
- # False, its defaulted above
103
- end
96
+ # We have to determine the port outside of the block since it uses
97
+ # API calls which can only be used from the main thread in JRuby on
98
+ # Windows
99
+ ssh_port = port
100
+
101
+ Timeout.timeout(env.config.ssh.timeout) do
102
+ execute(:timeout => env.config.ssh.timeout,
103
+ :port => ssh_port) { |ssh| }
104
104
  end
105
105
 
106
- check_thread.join(env.config.ssh.timeout)
107
- return check_thread[:result]
106
+ true
108
107
  rescue Net::SSH::AuthenticationFailed
109
- raise Errors::SSHAuthenticationFailed.new
108
+ raise Errors::SSHAuthenticationFailed
109
+ rescue Timeout::Error, Errno::ECONNREFUSED, Net::SSH::Disconnect,
110
+ Errors::SSHConnectionRefused, Net::SSH::AuthenticationFailed
111
+ return false
110
112
  end
111
113
 
112
114
  # Checks the file permissions for the private key, resetting them
@@ -120,12 +122,12 @@ module Vagrant
120
122
  if stat.owned? && file_perms(key_path) != "600"
121
123
  File.chmod(0600, key_path)
122
124
 
123
- raise Errors::SSHKeyBadPermissions.new(:key_path => key_path) if file_perms(key_path) != "600"
125
+ raise Errors::SSHKeyBadPermissions, :key_path => key_path if file_perms(key_path) != "600"
124
126
  end
125
127
  rescue Errno::EPERM
126
128
  # This shouldn't happen since we verify we own the file, but just
127
129
  # in case.
128
- raise Errors::SSHKeyBadPermissions.new(:key_path => key_path)
130
+ raise Errors::SSHKeyBadPermissions, :key_path => key_path
129
131
  end
130
132
 
131
133
  # Returns the file permissions of a given file. This is fairly unix specific
@@ -227,7 +229,7 @@ module Vagrant
227
229
  :command => command
228
230
  }.merge(options || {})
229
231
 
230
- raise options[:_error_class].new(options)
232
+ raise options[:_error_class], options
231
233
  end
232
234
  end
233
235
  end
@@ -106,7 +106,7 @@ module Vagrant
106
106
  break unless result
107
107
 
108
108
  attempts += 1
109
- raise LinuxError.new(:mount_fail) if attempts >= 10
109
+ raise LinuxError, :mount_fail if attempts >= 10
110
110
  sleep sleeptime
111
111
  end
112
112
  end
@@ -13,10 +13,13 @@ module Vagrant
13
13
 
14
14
  attr_accessor :halt_timeout
15
15
  attr_accessor :halt_check_interval
16
+ # This sets the command to use to execute items as a superuser. sudo is default
17
+ attr_accessor :suexec_cmd
16
18
 
17
19
  def initialize
18
20
  @halt_timeout = 30
19
21
  @halt_check_interval = 1
22
+ @suexec_cmd = 'sudo'
20
23
  end
21
24
  end
22
25
 
@@ -33,7 +36,7 @@ module Vagrant
33
36
  def halt
34
37
  vm.env.ui.info I18n.t("vagrant.systems.solaris.attempting_halt")
35
38
  vm.ssh.execute do |ssh|
36
- ssh.exec!("pfexec poweroff")
39
+ ssh.exec!("#{vm.env.config.solaris.suexec_cmd} /usr/sbin/poweroff")
37
40
  end
38
41
 
39
42
  # Wait until the VM's state is actually powered off. If this doesn't
@@ -49,10 +52,10 @@ module Vagrant
49
52
  end
50
53
 
51
54
  def mount_shared_folder(ssh, name, guestpath)
52
- ssh.exec!("pfexec mkdir -p #{guestpath}")
55
+ ssh.exec!("#{vm.env.config.solaris.suexec_cmd} mkdir -p #{guestpath}")
53
56
  # Using a custom mount method here; could use improvement.
54
- ssh.exec!("pfexec mount -F vboxfs v-root #{guestpath}")
55
- ssh.exec!("pfexec chown #{vm.env.config.ssh.username} #{guestpath}")
57
+ ssh.exec!("#{vm.env.config.solaris.suexec_cmd} /sbin/mount -F vboxfs #{name} #{guestpath}")
58
+ ssh.exec!("#{vm.env.config.solaris.suexec_cmd} chown #{vm.env.config.ssh.username} #{guestpath}")
56
59
  end
57
60
  end
58
61
  end
@@ -1,7 +1,7 @@
1
1
  module Vagrant
2
2
  module Util
3
3
  # A hash with indifferent access. Mostly taken from Thor/Rails (thanks).
4
- # Normally I'm not a fan of using an indifferent access hash sine Symbols
4
+ # Normally I'm not a fan of using an indifferent access hash since Symbols
5
5
  # are basically memory leaks in Ruby, but since Vagrant is typically a quick
6
6
  # one-off binary run and it doesn't use too many hash keys where this is
7
7
  # used, the effect should be minimal.
@@ -1,3 +1,4 @@
1
+ require 'rbconfig'
1
2
  require 'mario'
2
3
 
3
4
  module Vagrant
@@ -27,13 +28,29 @@ module Vagrant
27
28
  false
28
29
  end
29
30
 
31
+ # Returns boolean noting whether this is a 64-bit CPU. This
32
+ # is not 100% accurate and there could easily be false negatives.
33
+ #
34
+ # @return [Boolean]
35
+ def bit64?
36
+ ["x86_64", "amd64"].include?(RbConfig::CONFIG["host_cpu"])
37
+ end
38
+
39
+ # Returns boolean noting whether this is a 32-bit CPU. This
40
+ # can easily throw false positives since it relies on {#bit64?}.
41
+ #
42
+ # @return [Boolean]
43
+ def bit32?
44
+ !bit64?
45
+ end
46
+
30
47
  def tar_file_options
31
48
  # create, write only, fail if the file exists, binary if windows
32
49
  File::WRONLY|File::EXCL|File::CREAT|(Mario::Platform.windows? ? File::BINARY : 0)
33
50
  end
34
51
 
35
52
  def platform
36
- RUBY_PLATFORM.to_s.downcase
53
+ RbConfig::CONFIG["host_os"].downcase
37
54
  end
38
55
  end
39
56
  end
@@ -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.8"
5
+ VERSION = "0.6.9"
6
6
  end
@@ -53,15 +53,15 @@ module Vagrant
53
53
 
54
54
  if system.is_a?(Class)
55
55
  @system = system.new(self)
56
- raise Errors::VMSystemError.new(:_key => :invalid_class, :system => system.to_s) if !@system.is_a?(Systems::Base)
56
+ raise Errors::VMSystemError, :_key => :invalid_class, :system => system.to_s if !@system.is_a?(Systems::Base)
57
57
  elsif system.is_a?(Symbol)
58
58
  # Hard-coded internal systems
59
- mapping = { :linux => Systems::Linux }
59
+ mapping = { :linux => Systems::Linux, :solaris => Systems::Solaris }
60
60
 
61
- raise Errors::VMSystemError.new(:_key => :unknown_type, :system => system.to_s) if !mapping.has_key?(system)
61
+ raise Errors::VMSystemError, :_key => :unknown_type, :system => system.to_s if !mapping.has_key?(system)
62
62
  @system = mapping[system].new(self)
63
63
  else
64
- raise Errors::VMSystemError.new(:unspecified)
64
+ raise Errors::VMSystemError, :unspecified
65
65
  end
66
66
  end
67
67
 
@@ -13,6 +13,9 @@ en:
13
13
  The chef (either `chef-solo` or `chef-client`) binary was not found on
14
14
  the VM and is required for chef provisioning. Please verify that chef
15
15
  is installed and that the binary is available on the PATH.
16
+ puppet_not_detected: |-
17
+ The `puppet` binary was not found on the VM and is required for Puppet provisioning.
18
+ Please verify that Puppet is installed and that the binary is available on the PATH.
16
19
  cli_missing_env: This command requires that a Vagrant environment be properly passed in as the last parameter.
17
20
  config_validation: |-
18
21
  There was a problem with the configuration of Vagrant. The error message(s)
@@ -67,7 +70,7 @@ en:
67
70
 
68
71
  For a more detailed guide please consult:
69
72
 
70
- http://vagrantup.com/docs/getting-started/windows.
73
+ http://vagrantup.com/docs/getting-started/windows
71
74
 
72
75
  system:
73
76
  invalid_class: |-
@@ -99,6 +102,18 @@ en:
99
102
  Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
100
103
  If VirtualBox is installed, it may be an incorrect version. Vagrant currently
101
104
  requires VirtualBox 3.2.x. Please install the proper version to continue.
105
+ virtualbox_not_detected_win64: |-
106
+ Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed
107
+ with version 3.2.0 or higher.
108
+
109
+ Additionally, it appears you're on 64-bit Windows. If this is the case, and
110
+ VirtualBox is properly installed with the correct version, then please make
111
+ sure you're running Vagrant via JRuby on a 64-bit Java runtime. For more
112
+ information on how to set this up and how to verify it is properly setup,
113
+ please view the guide online at:
114
+
115
+ http://vagrantup.com/docs/getting-started/setup/windows_x64.html
116
+
102
117
  vm_creation_required: "VM must be created before running this command. Run `vagrant up` first."
103
118
  vm_not_found: "A VM by the name of %{name} was not found."
104
119
  vm_not_running: "VM must be running to open SSH connection."
@@ -289,14 +304,19 @@ en:
289
304
  This will cause your specified IP to be inaccessible. Please change
290
305
  the IP or name of your host only network to not match that of
291
306
  a bridged or non-hostonly network.
292
- creating: Creating new host only network for environment...
293
- enabling: Enabling host only network...
307
+ creating: "Creating new host only network for environment..."
308
+ enabling: "Enabling host only network..."
294
309
  not_found: |-
295
310
  The specified host network could not be found: '%{name}.'
296
311
  If the name specification is removed, Vagrant will create a new
297
312
  host only network for you. Alternatively, please create the
298
313
  specified network manually.
299
- preparing: Preparing host only network...
314
+ preparing: "Preparing host only network..."
315
+ windows_not_implemented: |-
316
+ Host only networking is currently broken on Windows due to a bug
317
+ in jruby-win32ole. When the bug is fixed, a patch release for Vagrant
318
+ will be released to remove this error. Until then, please just use
319
+ forwarded ports.
300
320
  nfs:
301
321
  host_required: |-
302
322
  A host class is required for NFS shared folders. By default, these
@@ -416,6 +436,16 @@ en:
416
436
  The validation key set for `config.chef.validation_key_path` does not exist! This
417
437
  file needs to exist so it can be uploaded to the virtual machine.
418
438
 
439
+ puppet:
440
+ not_detected: |-
441
+ The `%{binary}` binary appears to not be in the PATH of the guest. This
442
+ could be because the PATH is not properly setup or perhaps Puppet is not
443
+ installed on this guest. Puppet provisioning can not continue without
444
+ Puppet properly installed.
445
+ running_puppet: "Running Puppet..."
446
+ manifest_to_run: "Puppet will use the %{manifest} manifest to configure your box."
447
+ manifest_missing: "The Puppet %{manifest} manifest is missing. You cannot configure this box."
448
+
419
449
  systems:
420
450
  linux:
421
451
  attempting_halt: "Attempting graceful shutdown of linux..."