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.
- data/.gitignore +2 -0
- data/CHANGELOG.md +26 -0
- data/Gemfile +0 -8
- data/config/default.rb +1 -2
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/lib/vagrant.rb +14 -18
- data/lib/vagrant/action.rb +12 -0
- data/lib/vagrant/action/box.rb +11 -0
- data/lib/vagrant/action/box/download.rb +0 -1
- data/lib/vagrant/action/env.rb +7 -0
- data/lib/vagrant/action/general.rb +8 -0
- data/lib/vagrant/action/vm.rb +30 -0
- data/lib/vagrant/action/vm/boot.rb +3 -2
- data/lib/vagrant/action/vm/check_box.rb +1 -0
- data/lib/vagrant/action/vm/network.rb +1 -1
- data/lib/vagrant/action/vm/nfs.rb +3 -1
- data/lib/vagrant/action/vm/provision.rb +14 -25
- data/lib/vagrant/action/vm/share_folders.rb +11 -4
- data/lib/vagrant/command.rb +25 -0
- data/lib/vagrant/config.rb +78 -128
- data/lib/vagrant/config/base.rb +17 -3
- data/lib/vagrant/config/ssh.rb +1 -0
- data/lib/vagrant/config/top.rb +61 -0
- data/lib/vagrant/config/vagrant.rb +1 -6
- data/lib/vagrant/config/vm.rb +34 -20
- data/lib/vagrant/config/vm/provisioner.rb +56 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/downloaders/file.rb +1 -0
- data/lib/vagrant/downloaders/http.rb +9 -0
- data/lib/vagrant/environment.rb +25 -13
- data/lib/vagrant/errors.rb +0 -15
- data/lib/vagrant/hosts.rb +7 -0
- data/lib/vagrant/provisioners.rb +8 -0
- data/lib/vagrant/provisioners/base.rb +19 -1
- data/lib/vagrant/provisioners/chef.rb +31 -52
- data/lib/vagrant/provisioners/chef_server.rb +34 -10
- data/lib/vagrant/provisioners/chef_solo.rb +31 -9
- data/lib/vagrant/provisioners/puppet.rb +70 -60
- data/lib/vagrant/provisioners/puppet_server.rb +57 -0
- data/lib/vagrant/ssh.rb +3 -72
- data/lib/vagrant/ssh/session.rb +81 -0
- data/lib/vagrant/systems.rb +9 -0
- data/lib/vagrant/systems/base.rb +16 -1
- data/lib/vagrant/systems/debian.rb +26 -0
- data/lib/vagrant/systems/gentoo.rb +27 -0
- data/lib/vagrant/systems/linux.rb +14 -56
- data/lib/vagrant/systems/linux/config.rb +21 -0
- data/lib/vagrant/systems/linux/error.rb +9 -0
- data/lib/vagrant/systems/redhat.rb +31 -0
- data/lib/vagrant/test_helpers.rb +1 -1
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +25 -5
- data/templates/chef_solo_solo.erb +11 -3
- data/templates/locales/en.yml +65 -25
- data/templates/{network_entry.erb → network_entry_debian.erb} +0 -0
- data/templates/network_entry_gentoo.erb +7 -0
- data/templates/network_entry_redhat.erb +8 -0
- data/test/vagrant/action/vm/check_box_test.rb +1 -0
- data/test/vagrant/action/vm/nfs_test.rb +7 -1
- data/test/vagrant/action/vm/provision_test.rb +24 -79
- data/test/vagrant/action/vm/share_folders_test.rb +6 -1
- data/test/vagrant/command/helpers_test.rb +2 -2
- data/test/vagrant/config/base_test.rb +0 -6
- data/test/vagrant/config/vagrant_test.rb +0 -8
- data/test/vagrant/config/vm/provisioner_test.rb +92 -0
- data/test/vagrant/config/vm_test.rb +8 -0
- data/test/vagrant/config_test.rb +49 -89
- data/test/vagrant/downloaders/file_test.rb +18 -4
- data/test/vagrant/environment_test.rb +36 -12
- data/test/vagrant/provisioners/base_test.rb +28 -1
- data/test/vagrant/provisioners/chef_server_test.rb +50 -41
- data/test/vagrant/provisioners/chef_solo_test.rb +39 -16
- data/test/vagrant/provisioners/chef_test.rb +11 -81
- data/test/vagrant/provisioners/puppet_server_test.rb +69 -0
- data/test/vagrant/provisioners/puppet_test.rb +69 -54
- data/test/vagrant/{ssh_session_test.rb → ssh/session_test.rb} +0 -0
- data/test/vagrant/ssh_test.rb +12 -1
- data/test/vagrant/systems/base_test.rb +18 -0
- data/test/vagrant/systems/linux_test.rb +2 -2
- data/test/vagrant/vm_test.rb +33 -5
- data/vagrant.gemspec +6 -5
- metadata +42 -16
- data/lib/vagrant/util/glob_loader.rb +0 -24
@@ -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
|
+
|
data/lib/vagrant/test_helpers.rb
CHANGED
@@ -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
|
data/lib/vagrant/version.rb
CHANGED
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
|
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 = {
|
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
|
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 %>
|
data/templates/locales/en.yml
CHANGED
@@ -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: "
|
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
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
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..."
|
File without changes
|
@@ -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(
|
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(:
|
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.
|
25
|
-
@klass.any_instance.expects(:
|
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
|
-
@
|
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(:
|
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.
|
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
|
-
|
51
|
-
|
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
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
95
|
-
|
96
|
-
}
|
97
|
-
end
|
58
|
+
assert_equal 2, @instance.provisioners.length
|
59
|
+
end
|
98
60
|
|
99
|
-
|
100
|
-
|
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
|
-
|
104
|
-
provisioner_expectation(:chef_server, Vagrant::Provisioners::ChefServer)
|
105
|
-
end
|
66
|
+
@instance.load_provisioners
|
106
67
|
|
107
|
-
|
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.
|
117
|
-
@
|
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
|
-
@
|
124
|
-
|
125
|
-
|
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
|