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
@@ -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
@@ -56,6 +84,10 @@ en:
56
84
  permissions on the following file to 0600 and then try running this command again:
57
85
 
58
86
  %{key_path}
87
+ ssh_port_not_detected: |-
88
+ Vagrant couldn't determine the SSH port for your VM! This is a rare,
89
+ exceptional event, and a bug should be filed. Please try recreating your
90
+ VM (vagrant destroy, then vagrant up). Sorry!
59
91
  ssh_unavailable: "`ssh` binary could not be found. Is an SSH client installed?"
60
92
  ssh_unavailable_windows: |-
61
93
  `vagrant ssh` isn't available on the Windows platform. The
@@ -89,15 +121,15 @@ en:
89
121
  message is reproduced below for convenience:
90
122
 
91
123
  %{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
124
  virtualbox_invalid_version: |-
98
125
  Vagrant has detected that you have VirtualBox version %{version} installed!
99
- Vagrant requires that you use at least VirtualBox version 3.2. Please install
126
+ Vagrant requires that you use at least VirtualBox version 4.0. Please install
100
127
  a more recent version of VirtualBox to continue.
128
+
129
+ The Vagrant 0.6.x series supports VirtualBox 3.2, so if you're stuck with that
130
+ version, then please use the 0.6.x series of Vagrant.
131
+
132
+ Any earlier versions of VirtualBox are completely unsupported. Please upgrade.
101
133
  virtualbox_not_detected: |-
102
134
  Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
103
135
  If VirtualBox is installed, it may be an incorrect version. Vagrant currently
@@ -137,6 +169,8 @@ en:
137
169
  box_missing: "A box must be specified."
138
170
  box_not_found: "The box '%{name}' could not be found."
139
171
  shared_folder_hostpath_missing: "Shared folder host path for '%{name}' doesn't exist: %{path}"
172
+ provisioner_not_found: "The provisioner '%{shortcut}' doesn't exist."
173
+ provisioner_invalid_class: "The provisioner '%{shortcut}' must inherit from `Vagrant::Provisioners::Base`."
140
174
 
141
175
  #-------------------------------------------------------------------------------
142
176
  # Translations for commands. e.g. `vagrant x`
@@ -346,16 +380,15 @@ en:
346
380
  key.
347
381
  persisting: "Persisting the VM UUID (%{uuid})..."
348
382
  provision:
349
- beginning: "Beginning provisioning process..."
383
+ beginning: "Running provisioner: %{provisioner}..."
350
384
  enabled: "Provisioning enabled with %{provisioner}..."
351
- invalid_class: "Provisioners must be an instance of Vagrant::Provisioners::Base"
352
- unknown_type: "Unknown provisioner type: %{provisioner}"
353
385
  resume:
354
386
  resuming: Resuming suspended VM...
355
387
  share_folders:
356
388
  creating: Creating shared folders metadata...
357
389
  mounting: Mounting shared folders...
358
390
  mounting_entry: "-- %{name}: %{guest_path}"
391
+ nomount_entry: "-- %{name}: Automounting disabled."
359
392
  suspend:
360
393
  suspending: Saving VM state and suspending execution...
361
394
 
@@ -365,7 +398,6 @@ en:
365
398
  download:
366
399
  with: "Downloading with %{class}..."
367
400
  cleaning: "Cleaning up downloaded box..."
368
- copying: "Copying box to temporary location..."
369
401
  unknown_type: "Unknown or unsupported URI type given for box download."
370
402
  unpackage:
371
403
  extracting: "Extracting box..."
@@ -396,8 +428,10 @@ en:
396
428
 
397
429
  downloaders:
398
430
  file:
431
+ download: "Copying box to temporary location..."
399
432
  file_missing: "The specified path to a file doesn't exist."
400
433
  http:
434
+ download: "Downloading box: %{url}"
401
435
  socket_error: |-
402
436
  An error occurred while trying to download the specified box. This most
403
437
  often happens if there is no internet connection or the address is
@@ -442,23 +476,39 @@ en:
442
476
  could be because the PATH is not properly setup or perhaps Puppet is not
443
477
  installed on this guest. Puppet provisioning can not continue without
444
478
  Puppet properly installed.
445
- running_puppet: "Running Puppet..."
446
- manifest_to_run: "Puppet will use the %{manifest} manifest to configure your box."
479
+ running_puppet: "Running Puppet with %{manifest}..."
447
480
  manifest_missing: "The Puppet %{manifest} manifest is missing. You cannot configure this box."
481
+ manifests_path_missing: "The manifests path specified for Puppet does not exist: %{path}"
482
+ module_path_missing: "The configured module path doesn't exist: %{path}"
483
+
484
+ puppet_server:
485
+ not_detected: |-
486
+ The `%{binary}` binary appears to not be in the PATH of the guest. This
487
+ could be because the PATH is not properly setup or perhaps Puppet is not
488
+ installed on this guest. Puppet provisioning can not continue without
489
+ Puppet properly installed.
490
+ running_puppetd: "Running Puppet agent..."
448
491
 
449
492
  systems:
493
+ base:
494
+ unsupported_host_only: |-
495
+ Host only networking is very distro-specific. Vagrant has support for many
496
+ distros built-in: Debian, Ubuntu, Gentoo, and RedHat. The distro of your VM
497
+ couldn't be detected, or isn't supported for host only networking.
498
+
499
+ Most of the time this is simply due to the fact that no one has contributed
500
+ back the SSH commands necessary to set this up. Please report a bug and this
501
+ will be fixed for your distro.
502
+
450
503
  linux:
451
504
  attempting_halt: "Attempting graceful shutdown of linux..."
452
505
  mount_fail: "Failed to mount shared folders. `vboxsf` was not available."
453
- network_not_debian: |-
454
- Host only networking is only supported for Debian/Ubuntu by the built-in
455
- "Linux" system. If you're using some other distro and want to implement
456
- host only networking, please subclass the `Vagrant::Systems::Linux` class
457
- and implement the `prepare_host_only_network` and `enable_host_only_network`
458
- methods.
459
-
460
- Otherwise, please report your distro and how to modify network interfaces
461
- to the Vagrant mailing list or IRC and we'll probably be glad to add it
462
- to the internal systems.
506
+ mount_nfs_fail: |-
507
+ Mounting NFS shared folders failed. This is most often caused by the NFS
508
+ client software not being installed on the guest machine. Please verify
509
+ that the NFS client software is properly installed, and consult any resources
510
+ specific to the linux distro you're using for more information on how to
511
+ do this.
512
+
463
513
  solaris:
464
514
  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
@@ -1,5 +1,5 @@
1
1
  Host <%= host_key %>
2
- HostName localhost
2
+ HostName 127.0.0.1
3
3
  User <%= ssh_user %>
4
4
  Port <%= ssh_port %>
5
5
  UserKnownHostsFile /dev/null
@@ -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 {
@@ -37,10 +37,10 @@ class CleanMachineFolderVMActionTest < Test::Unit::TestCase
37
37
  @instance.clean_machine_folder
38
38
  end
39
39
 
40
- should "delete directories with only .xml-prev files" do
40
+ should "delete directories with only .vbox-prev files" do
41
41
  folders = {
42
- "sfoo" => %W[foo bar baz.xml-prev],
43
- "sbar" => %W[foo.xml-prev]
42
+ "sfoo" => %W[foo bar baz.vbox-prev],
43
+ "sbar" => %W[foo.vbox-prev]
44
44
  }
45
45
 
46
46
  Dir.expects(:[]).with(@folder).returns(folders.keys)
@@ -57,7 +57,7 @@ class CleanMachineFolderVMActionTest < Test::Unit::TestCase
57
57
  should "delete directories with only subdirectories" do
58
58
  folders = {
59
59
  "sfoo" => %W[foo bar],
60
- "sbar" => %W[foo.xml-prev]
60
+ "sbar" => %W[foo.vbox-prev]
61
61
  }
62
62
 
63
63
  File.stubs(:file?).returns(false)
@@ -77,6 +77,8 @@ class CleanMachineFolderVMActionTest < Test::Unit::TestCase
77
77
  should "do nothing if folder is < 10 characters" do
78
78
  VirtualBox::Global.global.system_properties.stubs(:default_machine_folder).returns("foo")
79
79
  Dir.expects(:[]).never
80
+
81
+ @instance.clean_machine_folder
80
82
  end
81
83
  end
82
84
  end
@@ -16,7 +16,7 @@ class DestroyVMActionTest < Test::Unit::TestCase
16
16
 
17
17
  context "destroying the VM" do
18
18
  should "destroy VM and attached images" do
19
- @internal_vm.expects(:destroy).with(:destroy_medium => :delete).once
19
+ @internal_vm.expects(:destroy).once
20
20
  @env["vm"].expects(:vm=).with(nil).once
21
21
  @app.expects(:call).with(@env).once
22
22
  @instance.call(@env)
@@ -16,24 +16,27 @@ class DestroyUnusedNetworkInterfacesVMActionTest < Test::Unit::TestCase
16
16
 
17
17
  context "calling" do
18
18
  setup do
19
- @network_adapters = []
20
- @internal_vm.stubs(:network_adapters).returns(@network_adapters)
19
+ @interfaces = []
20
+ global = mock("global")
21
+ host = mock("host")
22
+ VirtualBox::Global.stubs(:global).returns(global)
23
+ global.stubs(:host).returns(host)
24
+ host.stubs(:network_interfaces).returns(@interfaces)
21
25
  end
22
26
 
23
- def stub_interface(length=5)
27
+ def stub_interface(length=5, type=:host_only)
24
28
  interface = mock("interface")
25
- adapter = mock("adapter")
26
- adapter.stubs(:host_interface_object).returns(interface)
29
+ interface.stubs(:interface_type).returns(type)
27
30
  interface.stubs(:attached_vms).returns(Array.new(length))
28
31
 
29
- @network_adapters << adapter
32
+ @interfaces << interface
30
33
  interface
31
34
  end
32
35
 
33
36
  should "destroy only the unused network interfaces" do
34
37
  stub_interface(5)
35
38
  stub_interface(7)
36
- results = [stub_interface(1), stub_interface(1)]
39
+ results = [stub_interface(0), stub_interface(0)]
37
40
 
38
41
  results.each do |result|
39
42
  result.expects(:destroy).once
@@ -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
@@ -116,6 +116,7 @@ class ShareFoldersVMActionTest < Test::Unit::TestCase
116
116
  @folders = stub_shared_folders(<<-sf)
117
117
  config.vm.share_folder("foo", "fooguest", "foohost")
118
118
  config.vm.share_folder("bar", "barguest", "barhost")
119
+ config.vm.share_folder("foo_no_mount", nil, "foohost2")
119
120
  sf
120
121
  @ssh = mock("ssh")
121
122
  @vm.ssh.stubs(:execute).yields(@ssh)
@@ -125,7 +126,11 @@ class ShareFoldersVMActionTest < Test::Unit::TestCase
125
126
  should "mount all shared folders to the VM" do
126
127
  mount_seq = sequence("mount_seq")
127
128
  @folders.each do |name, data|
128
- @vm.system.expects(:mount_shared_folder).with(@ssh, name, data[:guestpath]).in_sequence(mount_seq)
129
+ if data[:guestpath]
130
+ @vm.system.expects(:mount_shared_folder).with(@ssh, name, data[:guestpath]).in_sequence(mount_seq)
131
+ else
132
+ @vm.system.expects(:mount_shared_folder).with(@ssh, name, anything).never
133
+ end
129
134
  end
130
135
 
131
136
  @instance.mount_shared_folders
@@ -52,7 +52,7 @@ class CommandHelpersTest < Test::Unit::TestCase
52
52
  should "return the VM if no name is specified" do
53
53
  instance = command([], @env)
54
54
  assert_nothing_raised {
55
- assert_equal @env.vms.values, instance.target_vms
55
+ assert_equal @env.vms.values.sort, instance.target_vms.sort
56
56
  }
57
57
  end
58
58
  end
@@ -64,7 +64,7 @@ class CommandHelpersTest < Test::Unit::TestCase
64
64
 
65
65
  should "return all the VMs if no name is specified" do
66
66
  instance = command([], @env)
67
- assert_equal @env.vms.values, instance.target_vms
67
+ assert_equal @env.vms.values.sort, instance.target_vms.sort
68
68
  end
69
69
 
70
70
  should "return only the specified VM if a name is given" do
@@ -42,12 +42,6 @@ class ConfigBaseTest < Test::Unit::TestCase
42
42
  assert_equal @json, @base.to_json
43
43
  end
44
44
 
45
- should "not include env in the JSON hash" do
46
- @base.env = "FOO"
47
- hash = @base.instance_variables_hash
48
- assert !hash.has_key?(:env)
49
- end
50
-
51
45
  should "not include top in the JSON hash" do
52
46
  @base.top = "FOO"
53
47
  hash = @base.instance_variables_hash
@@ -8,7 +8,6 @@ class ConfigVagrantTest < Test::Unit::TestCase
8
8
  context "validation" do
9
9
  setup do
10
10
  @config.dotfile_name = "foo"
11
- @config.home = "foo"
12
11
  @config.host = "foo"
13
12
 
14
13
  @errors = Vagrant::Config::ErrorRecorder.new
@@ -26,13 +25,6 @@ class ConfigVagrantTest < Test::Unit::TestCase
26
25
  assert !@errors.errors.empty?
27
26
  end
28
27
 
29
- should "be invalid with no home" do
30
- @config.home = nil
31
-
32
- @config.validate(@errors)
33
- assert !@errors.errors.empty?
34
- end
35
-
36
28
  should "be invalid with no host" do
37
29
  @config.host = nil
38
30
 
@@ -0,0 +1,92 @@
1
+ require "test_helper"
2
+
3
+ class ConfigVMProvisionerTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Vagrant::Config::VMConfig::Provisioner
6
+ @top = Vagrant::Config::Top.new(nil)
7
+ end
8
+
9
+ context "initializing" do
10
+ should "expose the top instance that the provisioner belongs to" do
11
+ instance = @klass.new(@top, :chef_solo)
12
+ assert_equal @top, instance.top
13
+ end
14
+
15
+ should "expose the shortcut used" do
16
+ instance = @klass.new(@top, :chef_solo)
17
+ assert_equal :chef_solo, instance.shortcut
18
+ end
19
+
20
+ should "expose the provisioner class if its a valid shortcut" do
21
+ instance = @klass.new(@top, :chef_solo)
22
+ assert_equal Vagrant::Provisioners::ChefSolo, instance.provisioner
23
+ end
24
+
25
+ should "expose the provisioner class if its a valid class" do
26
+ instance = @klass.new(@top, Vagrant::Provisioners::ChefSolo)
27
+ assert_equal Vagrant::Provisioners::ChefSolo, instance.provisioner
28
+ end
29
+
30
+ should "have a nil provisioner class if invalid" do
31
+ instance = @klass.new(@top, :i_shall_never_exist)
32
+ assert_nil instance.provisioner
33
+ end
34
+
35
+ should "have a nil config instance if invalid" do
36
+ instance = @klass.new(@top, :i_shall_never_exist)
37
+ assert_nil instance.config
38
+ end
39
+
40
+ should "set the top of the config object to the given top" do
41
+ instance = @klass.new(@top, :chef_solo)
42
+ assert_equal @top, instance.config.top
43
+ end
44
+
45
+ should "configure the provisioner if valid" do
46
+ instance = @klass.new(@top, :chef_solo) do |chef|
47
+ chef.cookbooks_path = "foo"
48
+ end
49
+
50
+ assert_equal "foo", instance.config.cookbooks_path
51
+ end
52
+
53
+ should "configure the provisioner with a hash if valid" do
54
+ instance = @klass.new(@top, :chef_solo, :cookbooks_path => "foo")
55
+ assert_equal "foo", instance.config.cookbooks_path
56
+ end
57
+ end
58
+
59
+ context "validation" do
60
+ setup do
61
+ @errors = Vagrant::Config::ErrorRecorder.new
62
+ end
63
+
64
+ should "be invalid if provisioner is valid" do
65
+ instance = @klass.new(@top, :i_shall_never_exist)
66
+ instance.validate(@errors)
67
+ assert !@errors.errors.empty?
68
+ end
69
+
70
+ should "be invalid if provisioner doesn't inherit from provisioners base" do
71
+ klass = Class.new
72
+ instance = @klass.new(@top, klass)
73
+ instance.validate(@errors)
74
+ assert !@errors.errors.empty?
75
+ end
76
+
77
+ should "be valid with a valid provisioner" do
78
+ instance = @klass.new(@top, :chef_solo) do |chef|
79
+ chef.add_recipe "foo"
80
+ end
81
+
82
+ instance.validate(@errors)
83
+ assert @errors.errors.empty?
84
+ end
85
+
86
+ should "be invalid if a provisioner's config is invalid" do
87
+ instance = @klass.new(@top, :chef_solo)
88
+ instance.validate(@errors)
89
+ assert !@errors.errors.empty?
90
+ end
91
+ end
92
+ end
@@ -75,4 +75,12 @@ class ConfigVMTest < Test::Unit::TestCase
75
75
  assert_equal @username, @config.shared_folder_gid
76
76
  end
77
77
  end
78
+
79
+ context "deprecated config" do
80
+ should "raise an error for provisioner=" do
81
+ assert_raises(Vagrant::Errors::VagrantError) {
82
+ @config.provisioner = :chef_solo
83
+ }
84
+ end
85
+ end
78
86
  end