vagrantup 0.6.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +37 -0
- data/Gemfile +0 -8
- data/README.md +5 -0
- data/config/default.rb +1 -3
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/lib/vagrant/action/box/download.rb +0 -1
- data/lib/vagrant/action/box.rb +11 -0
- data/lib/vagrant/action/builtin.rb +1 -2
- data/lib/vagrant/action/env.rb +7 -0
- data/lib/vagrant/action/general.rb +8 -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/clean_machine_folder.rb +1 -1
- data/lib/vagrant/action/vm/destroy.rb +1 -1
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +7 -12
- 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/action/vm.rb +30 -0
- data/lib/vagrant/action.rb +12 -0
- data/lib/vagrant/command.rb +25 -0
- data/lib/vagrant/config/base.rb +17 -3
- data/lib/vagrant/config/ssh.rb +2 -2
- data/lib/vagrant/config/top.rb +61 -0
- data/lib/vagrant/config/vagrant.rb +1 -6
- data/lib/vagrant/config/vm/provisioner.rb +56 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/config/vm.rb +34 -20
- data/lib/vagrant/config.rb +78 -128
- data/lib/vagrant/downloaders/file.rb +1 -0
- data/lib/vagrant/downloaders/http.rb +9 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/environment.rb +26 -14
- data/lib/vagrant/errors.rb +5 -15
- data/lib/vagrant/hosts.rb +7 -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 +111 -60
- data/lib/vagrant/provisioners/puppet_server.rb +57 -0
- data/lib/vagrant/provisioners.rb +8 -0
- data/lib/vagrant/ssh/session.rb +81 -0
- data/lib/vagrant/ssh.rb +6 -76
- 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/config.rb +21 -0
- data/lib/vagrant/systems/linux/error.rb +9 -0
- data/lib/vagrant/systems/linux.rb +14 -56
- data/lib/vagrant/systems/redhat.rb +31 -0
- data/lib/vagrant/systems.rb +9 -0
- data/lib/vagrant/test_helpers.rb +1 -1
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +25 -5
- data/lib/vagrant.rb +14 -18
- data/templates/chef_solo_solo.erb +11 -3
- data/templates/commands/init/Vagrantfile.erb +13 -11
- data/templates/locales/en.yml +76 -26
- 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/templates/ssh_config.erb +1 -1
- data/test/vagrant/action/vm/check_box_test.rb +1 -0
- data/test/vagrant/action/vm/clean_machine_folder_test.rb +6 -4
- data/test/vagrant/action/vm/destroy_test.rb +1 -1
- data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +10 -7
- 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 +116 -69
- data/test/vagrant/{ssh_session_test.rb → ssh/session_test.rb} +0 -0
- data/test/vagrant/ssh_test.rb +20 -7
- 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 +38 -14
- data/lib/vagrant/action/vm/disable_networks.rb +0 -34
- data/lib/vagrant/util/glob_loader.rb +0 -24
- data/test/vagrant/action/vm/disable_networks_test.rb +0 -48
|
@@ -4,24 +4,22 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
|
4
4
|
setup do
|
|
5
5
|
@action_env = Vagrant::Action::Environment.new(vagrant_env.vms[:default].env)
|
|
6
6
|
|
|
7
|
-
@
|
|
7
|
+
@klass = Vagrant::Provisioners::Chef
|
|
8
|
+
@config = @klass::Config.new
|
|
9
|
+
@action = @klass.new(@action_env, @config)
|
|
8
10
|
@env = @action.env
|
|
9
11
|
@vm = @action.vm
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
context "preparing" do
|
|
13
15
|
should "error the environment" do
|
|
14
|
-
assert_raises(
|
|
16
|
+
assert_raises(@klass::ChefError) {
|
|
15
17
|
@action.prepare
|
|
16
18
|
}
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
context "config" do
|
|
21
|
-
setup do
|
|
22
|
-
@config = Vagrant::Provisioners::Chef::ChefConfig.new
|
|
23
|
-
end
|
|
24
|
-
|
|
25
23
|
should "not include the 'json' key in the config dump" do
|
|
26
24
|
result = @config.to_json
|
|
27
25
|
assert result !~ /"json":/
|
|
@@ -65,74 +63,6 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
|
65
63
|
@config.add_role("role[user]")
|
|
66
64
|
assert_equal "role[user]", @config.run_list[0]
|
|
67
65
|
end
|
|
68
|
-
|
|
69
|
-
context "validation" do
|
|
70
|
-
setup do
|
|
71
|
-
@errors = Vagrant::Config::ErrorRecorder.new
|
|
72
|
-
@top = @config.top = Vagrant::Config::Top.new(@env)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context "chef solo" do
|
|
76
|
-
setup do
|
|
77
|
-
@top.vm.provisioner = :chef_solo
|
|
78
|
-
|
|
79
|
-
@config.run_list = ["foo"]
|
|
80
|
-
@config.cookbooks_path = "cookbooks"
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
should "be valid if provisioner is not chef solo" do
|
|
84
|
-
@top.vm.provisioner = nil
|
|
85
|
-
@config.validate(@errors)
|
|
86
|
-
assert @errors.errors.empty?
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
should "be invalid if run list is empty" do
|
|
90
|
-
@config.run_list = []
|
|
91
|
-
@config.validate(@errors)
|
|
92
|
-
assert !@errors.errors.empty?
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
should "be invalid if cookbooks path is empty" do
|
|
96
|
-
@config.cookbooks_path = nil
|
|
97
|
-
@config.validate(@errors)
|
|
98
|
-
assert !@errors.errors.empty?
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
context "chef server" do
|
|
103
|
-
setup do
|
|
104
|
-
@top.vm.provisioner = :chef_server
|
|
105
|
-
|
|
106
|
-
@config.run_list = ["foo"]
|
|
107
|
-
@config.chef_server_url = "foo"
|
|
108
|
-
@config.validation_key_path = "foo"
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
should "be valid if provisioner is not chef solo" do
|
|
112
|
-
@top.vm.provisioner = nil
|
|
113
|
-
@config.validate(@errors)
|
|
114
|
-
assert @errors.errors.empty?
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
should "be invalid if run list is empty" do
|
|
118
|
-
@config.run_list = []
|
|
119
|
-
@config.validate(@errors)
|
|
120
|
-
assert !@errors.errors.empty?
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
should "be invalid if run list is empty" do
|
|
124
|
-
@config.chef_server_url = nil
|
|
125
|
-
@config.validate(@errors)
|
|
126
|
-
assert !@errors.errors.empty?
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
should "be invalid if run list is empty" do
|
|
130
|
-
@config.validation_key_path = nil
|
|
131
|
-
@config.validate(@errors)
|
|
132
|
-
assert !@errors.errors.empty?
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
66
|
end
|
|
137
67
|
|
|
138
68
|
context "verifying binary" do
|
|
@@ -143,7 +73,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
|
143
73
|
|
|
144
74
|
should "verify binary exists" do
|
|
145
75
|
binary = "foo"
|
|
146
|
-
@ssh.expects(:exec!).with("which #{binary}", anything)
|
|
76
|
+
@ssh.expects(:exec!).with("sudo -i which #{binary}", anything)
|
|
147
77
|
@action.verify_binary(binary)
|
|
148
78
|
end
|
|
149
79
|
end
|
|
@@ -152,8 +82,8 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
|
152
82
|
should "create and chown the folder to the ssh user" do
|
|
153
83
|
ssh_seq = sequence("ssh_seq")
|
|
154
84
|
ssh = mock("ssh")
|
|
155
|
-
ssh.expects(:exec!).with("sudo mkdir -p #{@
|
|
156
|
-
ssh.expects(:exec!).with("sudo chown #{@env.config.ssh.username} #{@
|
|
85
|
+
ssh.expects(:exec!).with("sudo mkdir -p #{@config.provisioning_path}").once.in_sequence(ssh_seq)
|
|
86
|
+
ssh.expects(:exec!).with("sudo chown #{@env.config.ssh.username} #{@config.provisioning_path}").once.in_sequence(ssh_seq)
|
|
157
87
|
@vm.ssh.expects(:execute).yields(ssh)
|
|
158
88
|
@action.chown_provisioning_folder
|
|
159
89
|
end
|
|
@@ -174,7 +104,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
|
174
104
|
string_io = mock("string_io")
|
|
175
105
|
Vagrant::Util::TemplateRenderer.expects(:render).with(@template, anything).returns(template_data)
|
|
176
106
|
StringIO.expects(:new).with(template_data).returns(string_io)
|
|
177
|
-
File.expects(:join).with(@
|
|
107
|
+
File.expects(:join).with(@config.provisioning_path, @filename).once.returns("bar")
|
|
178
108
|
@vm.ssh.expects(:upload!).with(string_io, "bar")
|
|
179
109
|
|
|
180
110
|
@action.setup_config(@template, @filename, {})
|
|
@@ -183,7 +113,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
|
183
113
|
should "provide log level by default" do
|
|
184
114
|
Vagrant::Util::TemplateRenderer.expects(:render).returns("foo").with() do |template, vars|
|
|
185
115
|
assert vars.has_key?(:log_level)
|
|
186
|
-
assert_equal @
|
|
116
|
+
assert_equal @config.log_level.to_sym, vars[:log_level]
|
|
187
117
|
true
|
|
188
118
|
end
|
|
189
119
|
|
|
@@ -221,7 +151,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
|
221
151
|
end
|
|
222
152
|
|
|
223
153
|
should "merge in the extra json specified in the config" do
|
|
224
|
-
@
|
|
154
|
+
@config.json = { :foo => "BAR" }
|
|
225
155
|
assert_json do |data|
|
|
226
156
|
assert_equal "BAR", data["foo"]
|
|
227
157
|
end
|
|
@@ -241,7 +171,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
|
|
|
241
171
|
|
|
242
172
|
should "upload a StringIO to dna.json" do
|
|
243
173
|
StringIO.expects(:new).with(anything).returns("bar")
|
|
244
|
-
File.expects(:join).with(@
|
|
174
|
+
File.expects(:join).with(@config.provisioning_path, "dna.json").once.returns("baz")
|
|
245
175
|
@vm.ssh.expects(:upload!).with("bar", "baz").once
|
|
246
176
|
@action.setup_json
|
|
247
177
|
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class PuppetServerProvisionerTest < Test::Unit::TestCase
|
|
4
|
+
setup do
|
|
5
|
+
@klass = Vagrant::Provisioners::PuppetServer
|
|
6
|
+
|
|
7
|
+
@action_env = Vagrant::Action::Environment.new(vagrant_env.vms[:default].env)
|
|
8
|
+
|
|
9
|
+
@config = @klass::Config.new
|
|
10
|
+
@action = @klass.new(@action_env, @config)
|
|
11
|
+
@env = @action.env
|
|
12
|
+
@vm = @action.vm
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "provisioning" do
|
|
16
|
+
should "run the proper sequence of methods in order" do
|
|
17
|
+
prov_seq = sequence("prov_seq")
|
|
18
|
+
@action.expects(:verify_binary).with("puppetd").once.in_sequence(prov_seq)
|
|
19
|
+
@action.expects(:run_puppetd_client).once.in_sequence(prov_seq)
|
|
20
|
+
@action.provision!
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "verifying binary" do
|
|
25
|
+
setup do
|
|
26
|
+
@ssh = mock("ssh")
|
|
27
|
+
@shell = mock("shell")
|
|
28
|
+
@ssh.stubs(:shell).yields(@shell)
|
|
29
|
+
@vm.ssh.stubs(:execute).yields(@ssh)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
should "verify binary exists" do
|
|
33
|
+
binary = "foo"
|
|
34
|
+
@shell.expects(:execute).with("sudo -i which #{binary}", anything)
|
|
35
|
+
@action.verify_binary(binary)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context "running puppetd client" do
|
|
40
|
+
setup do
|
|
41
|
+
@cn = "puppet_node"
|
|
42
|
+
@ssh = mock("ssh")
|
|
43
|
+
@vm.ssh.stubs(:execute).yields(@ssh)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
should "run the puppetd client" do
|
|
47
|
+
@ssh.expects(:exec!).with("sudo -i puppetd --server #{@config.puppet_server} --certname #{@cn}").once
|
|
48
|
+
@action.run_puppetd_client
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
should "run puppetd with given options when given as an array" do
|
|
52
|
+
@config.options = ["--modulepath", "modules", "--verbose"]
|
|
53
|
+
@ssh.expects(:exec!).with("sudo -i puppetd --modulepath modules --verbose --server #{@config.puppet_server} --certname #{@cn}").once
|
|
54
|
+
@action.run_puppetd_client
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
should "run puppetd with the options when given as a string" do
|
|
58
|
+
@config.options = "--modulepath modules --verbose"
|
|
59
|
+
@ssh.expects(:exec!).with("sudo -i puppetd --modulepath modules --verbose --server #{@config.puppet_server} --certname #{@cn}").once
|
|
60
|
+
@action.run_puppetd_client
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
should "check the exit status if that is given" do
|
|
64
|
+
@ssh.stubs(:exec!).yields(nil, :exit_status, :foo)
|
|
65
|
+
@ssh.expects(:check_exit_status).with(:foo, anything).once
|
|
66
|
+
@action.run_puppetd_client
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -2,17 +2,102 @@ require "test_helper"
|
|
|
2
2
|
|
|
3
3
|
class PuppetProvisionerTest < Test::Unit::TestCase
|
|
4
4
|
setup do
|
|
5
|
+
clean_paths
|
|
6
|
+
|
|
7
|
+
@klass = Vagrant::Provisioners::Puppet
|
|
8
|
+
|
|
5
9
|
@action_env = Vagrant::Action::Environment.new(vagrant_env.vms[:default].env)
|
|
6
10
|
|
|
7
|
-
@
|
|
11
|
+
@config = @klass::Config.new
|
|
12
|
+
@config.top = Vagrant::Config::Top.new(@action_env.env)
|
|
13
|
+
@config.top.vm.box = "foo"
|
|
14
|
+
@action = @klass.new(@action_env, @config)
|
|
8
15
|
@env = @action.env
|
|
9
16
|
@vm = @action.vm
|
|
10
17
|
end
|
|
11
18
|
|
|
19
|
+
context "config" do
|
|
20
|
+
setup do
|
|
21
|
+
@errors = Vagrant::Config::ErrorRecorder.new
|
|
22
|
+
|
|
23
|
+
# Set a box
|
|
24
|
+
@config.top.vm.box = "foo"
|
|
25
|
+
|
|
26
|
+
# Start in a valid state (verified by the first test)
|
|
27
|
+
@config.expanded_manifests_path.mkdir
|
|
28
|
+
File.open(@config.expanded_manifests_path.join(@config.computed_manifest_file), "w") { |f| f.puts "HELLO" }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
should "expand the manifest path relative to the root path" do
|
|
32
|
+
assert_equal File.expand_path(@config.manifests_path, @env.root_path), @config.expanded_manifests_path.to_s
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
should "default the manifest file to the box name" do
|
|
36
|
+
assert_equal "#{@config.top.vm.box}.pp", @config.computed_manifest_file
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
should "use the custom manifest file if set" do
|
|
40
|
+
@config.manifest_file = "woot.pp"
|
|
41
|
+
assert_equal "woot.pp", @config.computed_manifest_file
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
should "return an empty array if no module path is set" do
|
|
45
|
+
@config.module_path = nil
|
|
46
|
+
assert_equal [], @config.expanded_module_paths
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
should "return array of module paths expanded relative to root path" do
|
|
50
|
+
@config.module_path = "foo"
|
|
51
|
+
|
|
52
|
+
result = @config.expanded_module_paths
|
|
53
|
+
assert result.is_a?(Array)
|
|
54
|
+
assert_equal 1, result.length
|
|
55
|
+
assert_equal File.expand_path(@config.module_path, @env.root_path), result[0].to_s
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
should "be valid" do
|
|
59
|
+
@config.validate(@errors)
|
|
60
|
+
assert @errors.errors.empty?
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
should "be invalid if the manifests path doesn't exist" do
|
|
64
|
+
@config.expanded_manifests_path.rmtree
|
|
65
|
+
@config.validate(@errors)
|
|
66
|
+
assert !@errors.errors.empty?
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
should "be invalid if a custom manifests path doesn't exist" do
|
|
70
|
+
@config.manifests_path = "dont_exist"
|
|
71
|
+
@config.validate(@errors)
|
|
72
|
+
assert !@errors.errors.empty?
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
should "be invalid if the manifest file doesn't exist" do
|
|
76
|
+
@config.expanded_manifests_path.join(@config.computed_manifest_file).unlink
|
|
77
|
+
@config.validate(@errors)
|
|
78
|
+
assert !@errors.errors.empty?
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
should "be invalid if a specified module path doesn't exist" do
|
|
82
|
+
@config.module_path = "foo"
|
|
83
|
+
@config.validate(@errors)
|
|
84
|
+
assert !@errors.errors.empty?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
should "be valid if all module paths exist" do
|
|
88
|
+
@config.module_path = "foo"
|
|
89
|
+
@config.expanded_module_paths.first.mkdir
|
|
90
|
+
@config.validate(@errors)
|
|
91
|
+
assert @errors.errors.empty?
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
12
95
|
context "preparing" do
|
|
13
96
|
should "share manifests" do
|
|
14
|
-
|
|
15
|
-
@action.expects(:
|
|
97
|
+
pre_seq = sequence("prepare")
|
|
98
|
+
@action.expects(:set_module_paths).once.in_sequence(pre_seq)
|
|
99
|
+
@action.expects(:share_manifests).once.in_sequence(pre_seq)
|
|
100
|
+
@action.expects(:share_module_paths).once.in_sequence(pre_seq)
|
|
16
101
|
@action.prepare
|
|
17
102
|
end
|
|
18
103
|
end
|
|
@@ -21,41 +106,27 @@ class PuppetProvisionerTest < Test::Unit::TestCase
|
|
|
21
106
|
should "run the proper sequence of methods in order" do
|
|
22
107
|
prov_seq = sequence("prov_seq")
|
|
23
108
|
@action.expects(:verify_binary).with("puppet").once.in_sequence(prov_seq)
|
|
24
|
-
@action.expects(:create_pp_path).once.in_sequence(prov_seq)
|
|
25
|
-
@action.expects(:set_manifest).once.in_sequence(prov_seq)
|
|
26
109
|
@action.expects(:run_puppet_client).once.in_sequence(prov_seq)
|
|
27
110
|
@action.provision!
|
|
28
111
|
end
|
|
29
112
|
end
|
|
30
113
|
|
|
31
|
-
context "
|
|
32
|
-
|
|
33
|
-
@env.config.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
should "should not create the manifest directory if it exists" do
|
|
37
|
-
File.expects(:directory?).with(@env.config.puppet.manifests_path).returns(true)
|
|
38
|
-
@action.check_manifest_dir
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
should "create the manifest directory if it does not exist" do
|
|
42
|
-
File.stubs(:directory?).with(@env.config.puppet.manifests_path).returns(false)
|
|
43
|
-
Dir.expects(:mkdir).with(@env.config.puppet.manifests_path).once
|
|
44
|
-
@action.check_manifest_dir
|
|
114
|
+
context "share manifests folder" do
|
|
115
|
+
should "share manifest folder" do
|
|
116
|
+
@env.config.vm.expects(:share_folder).with("manifests", @action.manifests_guest_path, @config.expanded_manifests_path)
|
|
117
|
+
@action.share_manifests
|
|
45
118
|
end
|
|
46
119
|
end
|
|
47
120
|
|
|
48
|
-
context "
|
|
49
|
-
|
|
50
|
-
@
|
|
51
|
-
@
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
end
|
|
121
|
+
context "sharing module paths" do
|
|
122
|
+
should "share all the module paths" do
|
|
123
|
+
@config.module_path = ["foo", "bar"]
|
|
124
|
+
@config.expanded_module_paths.each_with_index do |path, i|
|
|
125
|
+
@env.config.vm.expects(:share_folder).with("v-pp-m#{i}", File.join(@config.pp_path, "modules-#{i}"), path)
|
|
126
|
+
end
|
|
55
127
|
|
|
56
|
-
|
|
57
|
-
@
|
|
58
|
-
@action.share_manifests
|
|
128
|
+
@action.set_module_paths
|
|
129
|
+
@action.share_module_paths
|
|
59
130
|
end
|
|
60
131
|
end
|
|
61
132
|
|
|
@@ -67,68 +138,44 @@ class PuppetProvisionerTest < Test::Unit::TestCase
|
|
|
67
138
|
|
|
68
139
|
should "verify binary exists" do
|
|
69
140
|
binary = "foo"
|
|
70
|
-
@ssh.expects(:exec!).with("which #{binary}", anything)
|
|
141
|
+
@ssh.expects(:exec!).with("sudo -i which #{binary}", anything)
|
|
71
142
|
@action.verify_binary(binary)
|
|
72
143
|
end
|
|
73
144
|
end
|
|
74
145
|
|
|
75
|
-
context "create pp path" do
|
|
76
|
-
should "create and chown the folder to the ssh user" do
|
|
77
|
-
ssh_seq = sequence("ssh_seq")
|
|
78
|
-
ssh = mock("ssh")
|
|
79
|
-
ssh.expects(:exec!).with("sudo mkdir -p #{@env.config.puppet.pp_path}").once.in_sequence(ssh_seq)
|
|
80
|
-
ssh.expects(:exec!).with("sudo chown #{@env.config.ssh.username} #{@env.config.puppet.pp_path}").once.in_sequence(ssh_seq)
|
|
81
|
-
@vm.ssh.expects(:execute).yields(ssh)
|
|
82
|
-
@action.create_pp_path
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context "setting the manifest" do
|
|
87
|
-
setup do
|
|
88
|
-
@env.config.puppet.stubs(:manifests_path).returns("manifests")
|
|
89
|
-
@env.config.puppet.stubs(:manifest_file).returns("foo.pp")
|
|
90
|
-
@env.config.vm.stubs(:box).returns("base")
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
should "set the manifest if it exists" do
|
|
94
|
-
File.stubs(:exists?).with("#{@env.config.puppet.manifests_path}/#{@env.config.puppet.manifest_file}").returns(true)
|
|
95
|
-
@action.set_manifest
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
should "raise an error if the manifest does not exist" do
|
|
99
|
-
File.stubs(:exists?).with("#{@env.config.puppet.manifests_path}/#{@env.config.puppet.manifest_file}").returns(false)
|
|
100
|
-
assert_raises(Vagrant::Provisioners::PuppetError) {
|
|
101
|
-
@action.set_manifest
|
|
102
|
-
}
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
146
|
context "running puppet client" do
|
|
107
147
|
setup do
|
|
108
148
|
@ssh = mock("ssh")
|
|
109
149
|
@vm.ssh.stubs(:execute).yields(@ssh)
|
|
150
|
+
@action.set_module_paths
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def expect_puppet_command(command)
|
|
154
|
+
@ssh.expects(:exec!).with("sudo -i 'cd #{@action.manifests_guest_path}; #{command}'")
|
|
110
155
|
end
|
|
111
156
|
|
|
112
157
|
should "cd into the pp_path directory and run puppet" do
|
|
113
|
-
|
|
158
|
+
expect_puppet_command("puppet #{@config.computed_manifest_file}")
|
|
114
159
|
@action.run_puppet_client
|
|
115
160
|
end
|
|
116
161
|
|
|
117
162
|
should "cd into the pp_path directory and run puppet with given options when given as an array" do
|
|
118
|
-
@
|
|
119
|
-
|
|
163
|
+
@config.options = ["--modulepath", "modules", "--verbose"]
|
|
164
|
+
expect_puppet_command("puppet --modulepath modules --verbose #{@config.computed_manifest_file}")
|
|
120
165
|
@action.run_puppet_client
|
|
121
166
|
end
|
|
122
167
|
|
|
123
168
|
should "cd into the pp_path directory and run puppet with the options when given as a string" do
|
|
124
|
-
@
|
|
125
|
-
|
|
169
|
+
@config.options = "--modulepath modules --verbose"
|
|
170
|
+
expect_puppet_command("puppet --modulepath modules --verbose #{@config.computed_manifest_file}")
|
|
126
171
|
@action.run_puppet_client
|
|
127
172
|
end
|
|
128
173
|
|
|
129
|
-
should "
|
|
130
|
-
@
|
|
131
|
-
|
|
174
|
+
should "cd into the pp_path and run puppet with module paths if set" do
|
|
175
|
+
@config.module_path = "foo"
|
|
176
|
+
expect_puppet_command("puppet --modulepath '#{File.join(@config.pp_path, 'modules-0')}' #{@config.computed_manifest_file}")
|
|
177
|
+
|
|
178
|
+
@action.set_module_paths
|
|
132
179
|
@action.run_puppet_client
|
|
133
180
|
end
|
|
134
181
|
end
|
|
File without changes
|
data/test/vagrant/ssh_test.rb
CHANGED
|
@@ -12,13 +12,14 @@ class SshTest < Test::Unit::TestCase
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
setup do
|
|
15
|
-
VirtualBox.stubs(:version).returns("
|
|
15
|
+
VirtualBox.stubs(:version).returns("4.0.0")
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
context "connecting to external SSH" do
|
|
19
19
|
setup do
|
|
20
20
|
mock_ssh
|
|
21
21
|
@ssh.stubs(:check_key_permissions)
|
|
22
|
+
@ssh.stubs(:port).returns(2222)
|
|
22
23
|
Kernel.stubs(:exec)
|
|
23
24
|
Kernel.stubs(:system).returns(true)
|
|
24
25
|
|
|
@@ -53,8 +54,8 @@ class SshTest < Test::Unit::TestCase
|
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
should "call exec with supplied params" do
|
|
56
|
-
args = {:username => 'bar', :private_key_path => 'baz', :host => 'bak'
|
|
57
|
-
ssh_exec_expect(
|
|
57
|
+
args = {:username => 'bar', :private_key_path => 'baz', :host => 'bak'}
|
|
58
|
+
ssh_exec_expect(@ssh.port, args[:private_key_path], args[:username], args[:host])
|
|
58
59
|
@ssh.connect(args)
|
|
59
60
|
end
|
|
60
61
|
|
|
@@ -69,6 +70,17 @@ class SshTest < Test::Unit::TestCase
|
|
|
69
70
|
@ssh.connect
|
|
70
71
|
end
|
|
71
72
|
|
|
73
|
+
should "add forward X11 option if enabled" do
|
|
74
|
+
@env.config.ssh.forward_x11 = true
|
|
75
|
+
ssh_exec_expect(@ssh.port,
|
|
76
|
+
@env.config.ssh.private_key_path,
|
|
77
|
+
@env.config.ssh.username,
|
|
78
|
+
@env.config.ssh.host) do |args|
|
|
79
|
+
assert args =~ /-o ForwardX11=yes/
|
|
80
|
+
end
|
|
81
|
+
@ssh.connect
|
|
82
|
+
end
|
|
83
|
+
|
|
72
84
|
context "on leopard" do
|
|
73
85
|
setup do
|
|
74
86
|
Vagrant::Util::Platform.stubs(:leopard?).returns(true)
|
|
@@ -105,10 +117,10 @@ class SshTest < Test::Unit::TestCase
|
|
|
105
117
|
|
|
106
118
|
def ssh_exec_expect(port, key_path, uname, host)
|
|
107
119
|
Kernel.expects(:exec).with() do |arg|
|
|
108
|
-
assert arg =~ /^ssh
|
|
109
|
-
assert arg =~ /-p #{port}
|
|
110
|
-
assert arg =~ /-i #{key_path}
|
|
111
|
-
assert arg =~ /#{uname}@#{host}
|
|
120
|
+
assert arg =~ /^ssh/, "ssh command expected"
|
|
121
|
+
assert arg =~ /-p #{port}/, "-p #{port} expected"
|
|
122
|
+
assert arg =~ /-i #{key_path}/, "-i #{key_path} expected"
|
|
123
|
+
assert arg =~ /#{uname}@#{host}/, "#{uname}@{host} expected"
|
|
112
124
|
yield arg if block_given?
|
|
113
125
|
true
|
|
114
126
|
end
|
|
@@ -187,6 +199,7 @@ class SshTest < Test::Unit::TestCase
|
|
|
187
199
|
setup do
|
|
188
200
|
mock_ssh
|
|
189
201
|
@ssh.stubs(:check_key_permissions)
|
|
202
|
+
@ssh.stubs(:port).returns(2222)
|
|
190
203
|
end
|
|
191
204
|
|
|
192
205
|
should "return true if SSH connection works" do
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class BaseSystemTest < Test::Unit::TestCase
|
|
4
|
+
setup do
|
|
5
|
+
@klass = Vagrant::Systems::Base
|
|
6
|
+
|
|
7
|
+
@vm = mock("vm")
|
|
8
|
+
@instance = @klass.new(@vm)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
should "provide access to the VM" do
|
|
12
|
+
assert_equal @vm, @instance.vm
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
should "error on preparing host only network" do
|
|
16
|
+
assert_raises(@klass::BaseError) { @instance.prepare_host_only_network }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -61,7 +61,7 @@ class LinuxSystemTest < Test::Unit::TestCase
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
should "execute the proper mount command" do
|
|
64
|
-
@ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid
|
|
64
|
+
@ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=`id -u #{@vm.env.config.ssh.username}`,gid=`id -g #{@vm.env.config.ssh.username}` #{@name} #{@guestpath}").returns(@success_return)
|
|
65
65
|
mount_folder
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -107,7 +107,7 @@ class LinuxSystemTest < Test::Unit::TestCase
|
|
|
107
107
|
|
|
108
108
|
@vm.stubs(:env).returns(env)
|
|
109
109
|
|
|
110
|
-
@ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid
|
|
110
|
+
@ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=`id -u #{uid}`,gid=`id -g #{gid}` #{@name} #{@guestpath}").returns(@success_return)
|
|
111
111
|
mount_folder
|
|
112
112
|
end
|
|
113
113
|
end
|
data/test/vagrant/vm_test.rb
CHANGED
|
@@ -25,6 +25,7 @@ class VMTest < Test::Unit::TestCase
|
|
|
25
25
|
setup do
|
|
26
26
|
@vm_name = "foo"
|
|
27
27
|
@mock_vm = mock("vm")
|
|
28
|
+
@mock_vm.stubs(:running?).returns(false)
|
|
28
29
|
@vm = Vagrant::VM.new(:env => @env, :vm => @mock_vm, :name => @vm_name)
|
|
29
30
|
@mock_vm.stubs(:uuid).returns("foo")
|
|
30
31
|
end
|
|
@@ -96,11 +97,14 @@ class VMTest < Test::Unit::TestCase
|
|
|
96
97
|
}
|
|
97
98
|
end
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def initialize(vm); end
|
|
102
|
-
end
|
|
100
|
+
should "load the given system if specified" do
|
|
101
|
+
fake_class = Class.new(Vagrant::Systems::Base)
|
|
103
102
|
|
|
103
|
+
assert_nothing_raised { @vm.load_system!(fake_class) }
|
|
104
|
+
assert @vm.system.is_a?(fake_class)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context "with a class" do
|
|
104
108
|
should "initialize class if given" do
|
|
105
109
|
@vm.env.config.vm.system = Vagrant::Systems::Linux
|
|
106
110
|
|
|
@@ -109,7 +113,7 @@ class VMTest < Test::Unit::TestCase
|
|
|
109
113
|
end
|
|
110
114
|
|
|
111
115
|
should "raise error if class has invalid parent" do
|
|
112
|
-
@vm.env.config.vm.system =
|
|
116
|
+
@vm.env.config.vm.system = Class.new
|
|
113
117
|
assert_raises(Vagrant::Errors::VMSystemError) {
|
|
114
118
|
@vm.load_system!
|
|
115
119
|
}
|
|
@@ -140,6 +144,30 @@ class VMTest < Test::Unit::TestCase
|
|
|
140
144
|
}
|
|
141
145
|
end
|
|
142
146
|
end
|
|
147
|
+
|
|
148
|
+
context "loading the distro" do
|
|
149
|
+
setup do
|
|
150
|
+
@vm.vm.stubs(:running?).returns(true)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
should "not replace the distro if it is nil" do
|
|
154
|
+
@vm.env.config.vm.system = Class.new(Vagrant::Systems::Base)
|
|
155
|
+
|
|
156
|
+
@vm.load_system!
|
|
157
|
+
assert @vm.system.is_a?(@vm.env.config.vm.system)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
should "replace the distro if it is not nil" do
|
|
161
|
+
@vm.env.config.vm.system = Class.new(Vagrant::Systems::Base) do
|
|
162
|
+
def distro_dispatch
|
|
163
|
+
:linux
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
@vm.load_system!
|
|
168
|
+
assert @vm.system.is_a?(Vagrant::Systems::Linux)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
143
171
|
end
|
|
144
172
|
|
|
145
173
|
context "uuid" do
|
data/vagrant.gemspec
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
|
2
|
+
require "vagrant/version"
|
|
2
3
|
|
|
3
4
|
Gem::Specification.new do |s|
|
|
4
5
|
s.name = "vagrantup"
|
|
@@ -18,10 +19,10 @@ Gem::Specification.new do |s|
|
|
|
18
19
|
s.add_dependency "json", "~> 1.4.6"
|
|
19
20
|
s.add_dependency "mario", "~> 0.0.6"
|
|
20
21
|
s.add_dependency "net-ssh", "~> 2.0.23"
|
|
21
|
-
s.add_dependency "net-scp", "~> 1.0.
|
|
22
|
-
s.add_dependency "i18n", "~> 0.
|
|
23
|
-
s.add_dependency "thor", "~> 0.14.
|
|
24
|
-
s.add_dependency "virtualbox", "~> 0.
|
|
22
|
+
s.add_dependency "net-scp", "~> 1.0.4"
|
|
23
|
+
s.add_dependency "i18n", "~> 0.5.0"
|
|
24
|
+
s.add_dependency "thor", "~> 0.14.6"
|
|
25
|
+
s.add_dependency "virtualbox", "~> 0.8.2"
|
|
25
26
|
|
|
26
27
|
s.add_development_dependency "rake"
|
|
27
28
|
s.add_development_dependency "contest", ">= 0.1.2"
|