vagrant 0.7.0.beta → 0.7.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.md +26 -0
  3. data/Gemfile +0 -8
  4. data/config/default.rb +1 -2
  5. data/contrib/README.md +12 -0
  6. data/contrib/emacs/vagrant.el +8 -0
  7. data/contrib/vim/vagrantfile.vim +9 -0
  8. data/lib/vagrant.rb +14 -18
  9. data/lib/vagrant/action.rb +12 -0
  10. data/lib/vagrant/action/box.rb +11 -0
  11. data/lib/vagrant/action/box/download.rb +0 -1
  12. data/lib/vagrant/action/env.rb +7 -0
  13. data/lib/vagrant/action/general.rb +8 -0
  14. data/lib/vagrant/action/vm.rb +30 -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/network.rb +1 -1
  18. data/lib/vagrant/action/vm/nfs.rb +3 -1
  19. data/lib/vagrant/action/vm/provision.rb +14 -25
  20. data/lib/vagrant/action/vm/share_folders.rb +11 -4
  21. data/lib/vagrant/command.rb +25 -0
  22. data/lib/vagrant/config.rb +78 -128
  23. data/lib/vagrant/config/base.rb +17 -3
  24. data/lib/vagrant/config/ssh.rb +1 -0
  25. data/lib/vagrant/config/top.rb +61 -0
  26. data/lib/vagrant/config/vagrant.rb +1 -6
  27. data/lib/vagrant/config/vm.rb +34 -20
  28. data/lib/vagrant/config/vm/provisioner.rb +56 -0
  29. data/lib/vagrant/config/vm/sub_vm.rb +17 -0
  30. data/lib/vagrant/downloaders.rb +7 -0
  31. data/lib/vagrant/downloaders/file.rb +1 -0
  32. data/lib/vagrant/downloaders/http.rb +9 -0
  33. data/lib/vagrant/environment.rb +25 -13
  34. data/lib/vagrant/errors.rb +0 -15
  35. data/lib/vagrant/hosts.rb +7 -0
  36. data/lib/vagrant/provisioners.rb +8 -0
  37. data/lib/vagrant/provisioners/base.rb +19 -1
  38. data/lib/vagrant/provisioners/chef.rb +31 -52
  39. data/lib/vagrant/provisioners/chef_server.rb +34 -10
  40. data/lib/vagrant/provisioners/chef_solo.rb +31 -9
  41. data/lib/vagrant/provisioners/puppet.rb +70 -60
  42. data/lib/vagrant/provisioners/puppet_server.rb +57 -0
  43. data/lib/vagrant/ssh.rb +3 -72
  44. data/lib/vagrant/ssh/session.rb +81 -0
  45. data/lib/vagrant/systems.rb +9 -0
  46. data/lib/vagrant/systems/base.rb +16 -1
  47. data/lib/vagrant/systems/debian.rb +26 -0
  48. data/lib/vagrant/systems/gentoo.rb +27 -0
  49. data/lib/vagrant/systems/linux.rb +14 -56
  50. data/lib/vagrant/systems/linux/config.rb +21 -0
  51. data/lib/vagrant/systems/linux/error.rb +9 -0
  52. data/lib/vagrant/systems/redhat.rb +31 -0
  53. data/lib/vagrant/test_helpers.rb +1 -1
  54. data/lib/vagrant/version.rb +1 -1
  55. data/lib/vagrant/vm.rb +25 -5
  56. data/templates/chef_solo_solo.erb +11 -3
  57. data/templates/locales/en.yml +65 -25
  58. data/templates/{network_entry.erb → network_entry_debian.erb} +0 -0
  59. data/templates/network_entry_gentoo.erb +7 -0
  60. data/templates/network_entry_redhat.erb +8 -0
  61. data/test/vagrant/action/vm/check_box_test.rb +1 -0
  62. data/test/vagrant/action/vm/nfs_test.rb +7 -1
  63. data/test/vagrant/action/vm/provision_test.rb +24 -79
  64. data/test/vagrant/action/vm/share_folders_test.rb +6 -1
  65. data/test/vagrant/command/helpers_test.rb +2 -2
  66. data/test/vagrant/config/base_test.rb +0 -6
  67. data/test/vagrant/config/vagrant_test.rb +0 -8
  68. data/test/vagrant/config/vm/provisioner_test.rb +92 -0
  69. data/test/vagrant/config/vm_test.rb +8 -0
  70. data/test/vagrant/config_test.rb +49 -89
  71. data/test/vagrant/downloaders/file_test.rb +18 -4
  72. data/test/vagrant/environment_test.rb +36 -12
  73. data/test/vagrant/provisioners/base_test.rb +28 -1
  74. data/test/vagrant/provisioners/chef_server_test.rb +50 -41
  75. data/test/vagrant/provisioners/chef_solo_test.rb +39 -16
  76. data/test/vagrant/provisioners/chef_test.rb +11 -81
  77. data/test/vagrant/provisioners/puppet_server_test.rb +69 -0
  78. data/test/vagrant/provisioners/puppet_test.rb +69 -54
  79. data/test/vagrant/{ssh_session_test.rb → ssh/session_test.rb} +0 -0
  80. data/test/vagrant/ssh_test.rb +12 -1
  81. data/test/vagrant/systems/base_test.rb +18 -0
  82. data/test/vagrant/systems/linux_test.rb +2 -2
  83. data/test/vagrant/vm_test.rb +33 -5
  84. data/vagrant.gemspec +6 -5
  85. metadata +42 -16
  86. data/lib/vagrant/util/glob_loader.rb +0 -24
@@ -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
@@ -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
+
@@ -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.7.0.beta"
5
+ VERSION = "0.7.0.beta2"
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.
@@ -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 %>
@@ -16,6 +16,9 @@ en:
16
16
  puppet_not_detected: |-
17
17
  The `puppet` binary was not found on the VM and is required for Puppet provisioning.
18
18
  Please verify that Puppet is installed and that the binary is available on the PATH.
19
+ puppetd_not_detected: |-
20
+ The `puppetd` binary was not found on the VM is required for Puppet Server provisioning.
21
+ Please verify that Puppet is installed and that the binary is available on the PATH.
19
22
  cli_missing_env: This command requires that a Vagrant environment be properly passed in as the last parameter.
20
23
  config_validation: |-
21
24
  There was a problem with the configuration of Vagrant. The error message(s)
@@ -28,10 +31,35 @@ en:
28
31
  this command in another directory. If you aren't in a home directory,
29
32
  then please rename ".vagrant" to something else, or configure Vagrant
30
33
  to use another filename by modifying `config.vagrant.dotfile_name`.
31
- interrupted: Vagrant exited after cleanup due to external interrupt.
32
- multi_vm_required: A multi-vm environment is required for name specification to this command.
33
- multi_vm_target_required: `vagrant %{command}` requires a specific VM name to target in a multi-VM environment.
34
- no_env: No Vagrant environment detected. Run `vagrant init` to set one up.
34
+ interrupted: "Vagrant exited after cleanup due to external interrupt."
35
+ multi_vm_required: "A multi-vm environment is required for name specification to this command."
36
+ multi_vm_target_required: "`vagrant %{command}` requires a specific VM name to target in a multi-VM environment."
37
+ no_env: "No Vagrant environment detected. Run `vagrant init` to set one up."
38
+ provisioner_equals_not_supported: |-
39
+ The `config.vm.provisioner =` syntax has been removed in Vagrant 0.7.0.
40
+ Please change your provisioners to use the new syntax described below.
41
+ All of these changes are reflected on the Vagrant website as well.
42
+
43
+ Before:
44
+
45
+ config.vm.provisioner = :chef_solo
46
+ config.chef.cookbooks_path = "my_cookbooks"
47
+ config.chef.add_recipe "apache"
48
+
49
+ After:
50
+
51
+ config.vm.provision :chef_solo, :cookbooks_path => "my_cookbooks",
52
+ :run_list => ["recipe[apache]"]
53
+
54
+ Instead of just a hash, you may use a block as well to get access to the
55
+ configuration object:
56
+
57
+ config.vm.provision :chef_solo do |chef|
58
+ chef.cookbooks_path = "my_cookbooks"
59
+ chef.add_recipe "apache"
60
+ end
61
+
62
+ This error message will be removed in later versions of Vagrant.
35
63
  ssh_authentication_failed: |-
36
64
  SSH authentication failed! This is typically caused by the public/private
37
65
  keypair for the SSH user not being properly set on the guest VM. Please
@@ -89,11 +117,6 @@ en:
89
117
  message is reproduced below for convenience:
90
118
 
91
119
  %{file}
92
- virtualbox_invalid_ose: |-
93
- Vagrant has detected you're using an OSE ("Open Source Edition") of VirtualBox.
94
- Vagrant currently doesn't support any of the OSE editions due to slight API
95
- differences. Please download the regular package from virtualbox.org and install
96
- to continue.
97
120
  virtualbox_invalid_version: |-
98
121
  Vagrant has detected that you have VirtualBox version %{version} installed!
99
122
  Vagrant requires that you use at least VirtualBox version 4.0. Please install
@@ -142,6 +165,8 @@ en:
142
165
  box_missing: "A box must be specified."
143
166
  box_not_found: "The box '%{name}' could not be found."
144
167
  shared_folder_hostpath_missing: "Shared folder host path for '%{name}' doesn't exist: %{path}"
168
+ provisioner_not_found: "The provisioner '%{shortcut}' doesn't exist."
169
+ provisioner_invalid_class: "The provisioner '%{shortcut}' must inherit from `Vagrant::Provisioners::Base`."
145
170
 
146
171
  #-------------------------------------------------------------------------------
147
172
  # Translations for commands. e.g. `vagrant x`
@@ -351,16 +376,15 @@ en:
351
376
  key.
352
377
  persisting: "Persisting the VM UUID (%{uuid})..."
353
378
  provision:
354
- beginning: "Beginning provisioning process..."
379
+ beginning: "Running provisioner: %{provisioner}..."
355
380
  enabled: "Provisioning enabled with %{provisioner}..."
356
- invalid_class: "Provisioners must be an instance of Vagrant::Provisioners::Base"
357
- unknown_type: "Unknown provisioner type: %{provisioner}"
358
381
  resume:
359
382
  resuming: Resuming suspended VM...
360
383
  share_folders:
361
384
  creating: Creating shared folders metadata...
362
385
  mounting: Mounting shared folders...
363
386
  mounting_entry: "-- %{name}: %{guest_path}"
387
+ nomount_entry: "-- %{name}: Automounting disabled."
364
388
  suspend:
365
389
  suspending: Saving VM state and suspending execution...
366
390
 
@@ -370,7 +394,6 @@ en:
370
394
  download:
371
395
  with: "Downloading with %{class}..."
372
396
  cleaning: "Cleaning up downloaded box..."
373
- copying: "Copying box to temporary location..."
374
397
  unknown_type: "Unknown or unsupported URI type given for box download."
375
398
  unpackage:
376
399
  extracting: "Extracting box..."
@@ -401,8 +424,10 @@ en:
401
424
 
402
425
  downloaders:
403
426
  file:
427
+ download: "Copying box to temporary location..."
404
428
  file_missing: "The specified path to a file doesn't exist."
405
429
  http:
430
+ download: "Downloading box: %{url}"
406
431
  socket_error: |-
407
432
  An error occurred while trying to download the specified box. This most
408
433
  often happens if there is no internet connection or the address is
@@ -447,23 +472,38 @@ en:
447
472
  could be because the PATH is not properly setup or perhaps Puppet is not
448
473
  installed on this guest. Puppet provisioning can not continue without
449
474
  Puppet properly installed.
450
- running_puppet: "Running Puppet..."
451
- manifest_to_run: "Puppet will use the %{manifest} manifest to configure your box."
475
+ running_puppet: "Running Puppet with %{manifest}..."
452
476
  manifest_missing: "The Puppet %{manifest} manifest is missing. You cannot configure this box."
477
+ manifests_path_missing: "The manifests path specified for Puppet does not exist: %{path}"
478
+
479
+ puppet_server:
480
+ not_detected: |-
481
+ The `%{binary}` binary appears to not be in the PATH of the guest. This
482
+ could be because the PATH is not properly setup or perhaps Puppet is not
483
+ installed on this guest. Puppet provisioning can not continue without
484
+ Puppet properly installed.
485
+ running_puppetd: "Running Puppet agent..."
453
486
 
454
487
  systems:
488
+ base:
489
+ unsupported_host_only: |-
490
+ Host only networking is very distro-specific. Vagrant has support for many
491
+ distros built-in: Debian, Ubuntu, Gentoo, and RedHat. The distro of your VM
492
+ couldn't be detected, or isn't supported for host only networking.
493
+
494
+ Most of the time this is simply due to the fact that no one has contributed
495
+ back the SSH commands necessary to set this up. Please report a bug and this
496
+ will be fixed for your distro.
497
+
455
498
  linux:
456
499
  attempting_halt: "Attempting graceful shutdown of linux..."
457
500
  mount_fail: "Failed to mount shared folders. `vboxsf` was not available."
458
- network_not_debian: |-
459
- Host only networking is only supported for Debian/Ubuntu by the built-in
460
- "Linux" system. If you're using some other distro and want to implement
461
- host only networking, please subclass the `Vagrant::Systems::Linux` class
462
- and implement the `prepare_host_only_network` and `enable_host_only_network`
463
- methods.
464
-
465
- Otherwise, please report your distro and how to modify network interfaces
466
- to the Vagrant mailing list or IRC and we'll probably be glad to add it
467
- to the internal systems.
501
+ mount_nfs_fail: |-
502
+ Mounting NFS shared folders failed. This is most often caused by the NFS
503
+ client software not being installed on the guest machine. Please verify
504
+ that the NFS client software is properly installed, and consult any resources
505
+ specific to the linux distro you're using for more information on how to
506
+ do this.
507
+
468
508
  solaris:
469
509
  attempting_halt: "Attempting graceful shutdown of solaris..."
@@ -0,0 +1,7 @@
1
+ #VAGRANT-BEGIN
2
+ # The contents below are automatically generated by Vagrant.
3
+ # Please do not modify any of these contents.
4
+ config_eth<%= net_options[:adapter] %>=("<%= net_options[:ip] %> netmask <%= net_options[:netmask] %>")
5
+ #VAGRANT-END
6
+ ~
7
+
@@ -0,0 +1,8 @@
1
+ #VAGRANT-BEGIN
2
+ # The contents below are automatically generated by Vagrant.
3
+ # Please do not modify any of these contents.
4
+ BOOTPROTO=static
5
+ DHCPCLASS=
6
+ IPADDR=<%= net_options[:ip] %>
7
+ NETMASK=<%= net_options[:netmask] %>
8
+ #VAGRANT-END
@@ -45,6 +45,7 @@ class CheckBoxVMActionTest < Test::Unit::TestCase
45
45
  env.env.boxes.expects(:find).returns(nil)
46
46
  Vagrant::Box.expects(:add).with(env.env, env["config"].vm.box, env["config"].vm.box_url).in_sequence(seq)
47
47
  env.env.boxes.expects(:reload!).in_sequence(seq)
48
+ env.env.expects(:reload_config!).in_sequence(seq)
48
49
  app.expects(:call).with(env).once.in_sequence(seq)
49
50
 
50
51
  assert_nothing_raised {
@@ -160,13 +160,19 @@ class NFSVMActionTest < Test::Unit::TestCase
160
160
  context "mounting folders" do
161
161
  setup do
162
162
  @instance.stubs(:host_ip).returns("foo")
163
- @instance.stubs(:folders).returns(["bar"])
163
+ @instance.stubs(:folders).returns({ "v-data" => {:guestpath => "foo"}})
164
164
  end
165
165
 
166
166
  should "mount the folders on the system" do
167
167
  @vm.system.expects(:mount_nfs).with(@instance.host_ip, @instance.folders)
168
168
  @instance.mount_folders
169
169
  end
170
+
171
+ should "not mount folders which have no guest path" do
172
+ @instance.stubs(:folders).returns({ "v-data" => {}})
173
+ @vm.system.expects(:mount_nfs).with(@instance.host_ip, {})
174
+ @instance.mount_folders
175
+ end
170
176
  end
171
177
 
172
178
  context "getting the host IP" do
@@ -17,24 +17,23 @@ class ProvisionVMActionTest < Test::Unit::TestCase
17
17
 
18
18
  context "initializing" do
19
19
  setup do
20
- @klass.any_instance.stubs(:load_provisioner)
20
+ @klass.any_instance.stubs(:load_provisioners)
21
21
  end
22
22
 
23
23
  should "load provisioner if provisioning enabled" do
24
- @env["config"].vm.provisioner = :chef_solo
25
- @klass.any_instance.expects(:load_provisioner).once
24
+ @env["config"].vm.provision :chef_solo
25
+ @klass.any_instance.expects(:load_provisioners).once
26
26
  @klass.new(@app, @env)
27
27
  end
28
28
 
29
29
  should "not load provisioner if disabled" do
30
- @env["config"].vm.provisioner = nil
31
- @klass.any_instance.expects(:load_provisioner).never
30
+ @klass.any_instance.expects(:load_provisioners).never
32
31
  @klass.new(@app, @env)
33
32
  end
34
33
 
35
34
  should "not load provisioner if disabled through env hash" do
36
35
  @env["provision.enabled"] = false
37
- @klass.any_instance.expects(:load_provisioner).never
36
+ @klass.any_instance.expects(:load_provisioners).never
38
37
  @klass.new(@app, @env)
39
38
  end
40
39
  end
@@ -42,101 +41,47 @@ class ProvisionVMActionTest < Test::Unit::TestCase
42
41
  context "with an instance" do
43
42
  setup do
44
43
  # Set provisioner to nil so the provisioner isn't loaded on init
45
- @env["config"].vm.provisioner = nil
44
+ @env["config"].vm.provisioners.clear
46
45
  @instance = @klass.new(@app, @env)
47
46
  end
48
47
 
49
48
  context "loading a provisioner" do
50
- context "with a Class provisioner" do
51
- setup do
52
- @prov = mock("instance")
53
- @prov.stubs(:is_a?).with(Vagrant::Provisioners::Base).returns(true)
54
- @prov.stubs(:prepare)
55
- @klass = mock("klass")
56
- @klass.stubs(:is_a?).with(Class).returns(true)
57
- @klass.stubs(:new).with(@env).returns(@prov)
58
-
59
- @env["config"].vm.provisioner = @klass
60
- end
61
-
62
- should "set the provisioner to an instantiation of the class" do
63
- @klass.expects(:new).with(@env).once.returns(@prov)
64
- assert_equal @prov, @instance.load_provisioner
65
- end
66
-
67
- should "call prepare on the instance" do
68
- @prov.expects(:prepare).once
69
- @instance.load_provisioner
70
- end
71
-
72
- should "error environment if the class is not a subclass of the provisioner base" do
73
- @prov.expects(:is_a?).with(Vagrant::Provisioners::Base).returns(false)
74
-
75
- assert_raises(Vagrant::Errors::ProvisionInvalidClass) {
76
- @instance.load_provisioner
77
- }
78
- end
49
+ setup do
50
+ Vagrant::Provisioners::ChefSolo.any_instance.expects(:prepare).at_least(0)
79
51
  end
80
52
 
81
- context "with a Symbol provisioner" do
82
- def provisioner_expectation(symbol, provisioner)
83
- @env[:config].vm.provisioner = symbol
84
-
85
- instance = mock("instance")
86
- instance.expects(:prepare).once
87
- provisioner.expects(:new).with(@env).returns(instance)
88
- assert_equal instance, @instance.load_provisioner
89
- end
90
-
91
- should "raise an error if its an unknown symbol" do
92
- @env["config"].vm.provisioner = :this_will_never_exist
53
+ should "instantiate and prepare each provisioner" do
54
+ @env["config"].vm.provision :chef_solo
55
+ @env["config"].vm.provision :chef_solo
56
+ @instance.load_provisioners
93
57
 
94
- assert_raises(Vagrant::Errors::ProvisionUnknownType) {
95
- @instance.load_provisioner
96
- }
97
- end
58
+ assert_equal 2, @instance.provisioners.length
59
+ end
98
60
 
99
- should "set :chef_solo to the ChefSolo provisioner" do
100
- provisioner_expectation(:chef_solo, Vagrant::Provisioners::ChefSolo)
61
+ should "set the config for each provisioner" do
62
+ @env["config"].vm.provision :chef_solo do |chef|
63
+ chef.cookbooks_path = "foo"
101
64
  end
102
65
 
103
- should "set :chef_server to the ChefServer provisioner" do
104
- provisioner_expectation(:chef_server, Vagrant::Provisioners::ChefServer)
105
- end
66
+ @instance.load_provisioners
106
67
 
107
- should "set :puppet to the Puppet provisioner" do
108
- provisioner_expectation(:puppet, Vagrant::Provisioners::Puppet)
109
- end
68
+ assert_equal "foo", @instance.provisioners.first.config.cookbooks_path
110
69
  end
111
70
  end
112
71
 
113
72
  context "calling" do
114
73
  setup do
115
74
  Vagrant::Provisioners::ChefSolo.any_instance.stubs(:prepare)
116
- @env["config"].vm.provisioner = :chef_solo
117
- @prov = @instance.load_provisioner
75
+ @env["config"].vm.provision :chef_solo
76
+ @instance.load_provisioners
118
77
  end
119
78
 
120
79
  should "provision and continue chain" do
121
80
  seq = sequence("seq")
122
81
  @app.expects(:call).with(@env).in_sequence(seq)
123
- @prov.expects(:provision!).in_sequence(seq)
124
-
125
- @instance.call(@env)
126
- end
127
-
128
- should "continue chain and not provision if not enabled" do
129
- @env["config"].vm.provisioner = nil
130
- @prov.expects(:provision!).never
131
- @app.expects(:call).with(@env).once
132
-
133
- @instance.call(@env)
134
- end
135
-
136
- should "continue chain and not provision if not enabled through env hash" do
137
- @env["provision.enabled"] = false
138
- @prov.expects(:provision!).never
139
- @app.expects(:call).with(@env).once
82
+ @instance.provisioners.each do |prov|
83
+ prov.expects(:provision!).in_sequence(seq)
84
+ end
140
85
 
141
86
  @instance.call(@env)
142
87
  end