vagrant 0.7.0.beta2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
- ## 0.7.0.beta2 (January 13, 2010)
1
+ ## 0.7.0 (January 19, 2011)
2
2
 
3
+ - VirtualBox 4.0 support. Support for VirtualBox 3.2 is _dropped_, since
4
+ the API is so different. Stay with the 0.6.x series if you have VirtualBox
5
+ 3.2.x.
3
6
  - Puppet server provisioner. [GH-262]
4
7
  - Use numeric uid/gid in mounting shared folders to increase portability. [GH-252]
5
8
  - HTTP downloading follows redirects. [GH-163]
@@ -23,17 +26,14 @@
23
26
  change is not backwards compatible. [GH-265]
24
27
  - Provisioners are now RVM-friendly, meaning if you installed chef or puppet
25
28
  with an RVM managed Ruby, Vagrant now finds then. [GH-254]
26
-
27
- ## 0.7.0.beta (December 24, 2010)
28
-
29
- - VirtualBox 4.0 support. Support for VirtualBox 3.2 is _dropped_, since
30
- the API is so different. Stay with the 0.6.x series if you have VirtualBox
31
- 3.2.x.
32
29
  - Changed the unused host only network destroy mechanism to check for
33
30
  uselessness after the VM is destroyed. This should result in more accurate
34
31
  checks.
35
32
  - Networks are no longer disabled upon halt/destroy. With the above
36
33
  change, its unnecessary.
34
+ - Puppet supports `module_path` configuration to mount local modules directory
35
+ as a shared folder and configure puppet with it. [GH-270]
36
+ - `ssh-config` now outputs `127.0.0.1` as the host instead of `localhost`.
37
37
 
38
38
  ## 0.6.9 (December 21, 2010)
39
39
 
data/config/default.rb CHANGED
@@ -5,7 +5,6 @@ Vagrant::Config.run do |config|
5
5
 
6
6
  config.ssh.username = "vagrant"
7
7
  config.ssh.host = "localhost"
8
- config.ssh.port = 22
9
8
  config.ssh.forwarded_port_key = "ssh"
10
9
  config.ssh.max_tries = 10
11
10
  config.ssh.timeout = 30
@@ -5,7 +5,6 @@ module Vagrant
5
5
 
6
6
  attr_accessor :username
7
7
  attr_accessor :host
8
- attr_accessor :port
9
8
  attr_accessor :forwarded_port_key
10
9
  attr_accessor :max_tries
11
10
  attr_accessor :timeout
@@ -18,7 +17,7 @@ module Vagrant
18
17
  end
19
18
 
20
19
  def validate(errors)
21
- [:username, :host, :port, :forwarded_port_key, :max_tries, :timeout, :private_key_path].each do |field|
20
+ [:username, :host, :forwarded_port_key, :max_tries, :timeout, :private_key_path].each do |field|
22
21
  errors.add(I18n.t("vagrant.config.common.error_empty", :field => field)) if !instance_variable_get("@#{field}".to_sym)
23
22
  end
24
23
 
@@ -245,6 +245,11 @@ module Vagrant
245
245
  error_key(:ssh_key_bad_permissions)
246
246
  end
247
247
 
248
+ class SSHPortNotDetected < VagrantError
249
+ status_code(50)
250
+ error_key(:ssh_port_not_detected)
251
+ end
252
+
248
253
  class SSHUnavailable < VagrantError
249
254
  status_code(45)
250
255
  error_key(:ssh_unavailable)
@@ -10,12 +10,14 @@ module Vagrant
10
10
  class Config < Vagrant::Config::Base
11
11
  attr_accessor :manifest_file
12
12
  attr_accessor :manifests_path
13
+ attr_accessor :module_path
13
14
  attr_accessor :pp_path
14
15
  attr_accessor :options
15
16
 
16
17
  def initialize
17
18
  @manifest_file = nil
18
19
  @manifests_path = "manifests"
20
+ @module_path = nil
19
21
  @pp_path = "/tmp/vagrant-puppet"
20
22
  @options = []
21
23
  end
@@ -32,51 +34,90 @@ module Vagrant
32
34
  manifest_file || "#{top.vm.box}.pp"
33
35
  end
34
36
 
37
+ # Returns the module paths as an array of paths expanded relative to the
38
+ # root path.
39
+ def expanded_module_paths
40
+ return [] if !module_path
41
+
42
+ # Get all the paths and expand them relative to the root path, returning
43
+ # the array of expanded paths
44
+ paths = module_path
45
+ paths = [paths] if !paths.is_a?(Array)
46
+ paths.map do |path|
47
+ Pathname.new(path).expand_path(env.root_path)
48
+ end
49
+ end
50
+
35
51
  def validate(errors)
36
52
  super
37
53
 
54
+ # Manifests path/file validation
38
55
  if !expanded_manifests_path.directory?
39
56
  errors.add(I18n.t("vagrant.provisioners.puppet.manifests_path_missing", :path => expanded_manifests_path))
40
- return
57
+ else
58
+ if !expanded_manifests_path.join(computed_manifest_file).file?
59
+ errors.add(I18n.t("vagrant.provisioners.puppet.manifest_missing", :manifest => computed_manifest_file))
60
+ end
41
61
  end
42
62
 
43
- errors.add(I18n.t("vagrant.provisioners.puppet.manifest_missing", :manifest => computed_manifest_file)) if !expanded_manifests_path.join(computed_manifest_file).file?
63
+ # Module paths validation
64
+ expanded_module_paths.each do |path|
65
+ if !path.directory?
66
+ errors.add(I18n.t("vagrant.provisioners.puppet.module_path_missing", :path => path))
67
+ end
68
+ end
44
69
  end
45
70
  end
46
71
 
47
72
  def prepare
73
+ set_module_paths
48
74
  share_manifests
75
+ share_module_paths
49
76
  end
50
77
 
51
78
  def provision!
52
79
  verify_binary("puppet")
53
- create_pp_path
54
80
  run_puppet_client
55
81
  end
56
82
 
57
83
  def share_manifests
58
- env.config.vm.share_folder("manifests", config.pp_path, config.manifests_path)
84
+ env.config.vm.share_folder("manifests", manifests_guest_path, config.expanded_manifests_path)
59
85
  end
60
86
 
61
- def verify_binary(binary)
62
- vm.ssh.execute do |ssh|
63
- ssh.exec!("sudo -i which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
87
+ def share_module_paths
88
+ count = 0
89
+ @module_paths.each do |from, to|
90
+ # Sorry for the cryptic key here, but VirtualBox has a strange limit on
91
+ # maximum size for it and its something small (around 10)
92
+ env.config.vm.share_folder("v-pp-m#{count}", to, from)
93
+ count += 1
94
+ end
95
+ end
96
+
97
+ def set_module_paths
98
+ @module_paths = {}
99
+ config.expanded_module_paths.each_with_index do |path, i|
100
+ @module_paths[path] = File.join(config.pp_path, "modules-#{i}")
64
101
  end
65
102
  end
66
103
 
67
- def create_pp_path
104
+ def manifests_guest_path
105
+ File.join(config.pp_path, "manifests")
106
+ end
107
+
108
+ def verify_binary(binary)
68
109
  vm.ssh.execute do |ssh|
69
- ssh.exec!("sudo mkdir -p #{config.pp_path}")
70
- ssh.exec!("sudo chown #{env.config.ssh.username} #{config.pp_path}")
110
+ ssh.exec!("sudo -i which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
71
111
  end
72
112
  end
73
113
 
74
114
  def run_puppet_client
75
115
  options = [config.options].flatten
116
+ options << "--modulepath '#{@module_paths.values.join(':')}'" if !@module_paths.empty?
76
117
  options << config.computed_manifest_file
77
118
  options = options.join(" ")
78
119
 
79
- command = "sudo -i 'cd #{config.pp_path}; puppet #{options}'"
120
+ command = "sudo -i 'cd #{manifests_guest_path}; puppet #{options}'"
80
121
 
81
122
  env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet", :manifest => config.computed_manifest_file)
82
123
 
data/lib/vagrant/ssh.rb CHANGED
@@ -142,8 +142,7 @@ module Vagrant
142
142
 
143
143
  # Returns the port which is either given in the options hash or taken from
144
144
  # the config by finding it in the forwarded ports hash based on the
145
- # `config.ssh.forwarded_port_key` or use the default port given by `config.ssh.port`
146
- # when port forwarding isn't used.
145
+ # `config.ssh.forwarded_port_key`.
147
146
  def port(opts={})
148
147
  # Check if port was specified in options hash
149
148
  pnum = opts[:port]
@@ -161,8 +160,8 @@ module Vagrant
161
160
 
162
161
  return pnum.hostport if pnum
163
162
 
164
- # Fall back to the default
165
- return env.config.ssh.port
163
+ # This should NEVER happen.
164
+ raise Errors::SSHPortNotDetected
166
165
  end
167
166
  end
168
167
  end
@@ -2,5 +2,5 @@ module Vagrant
2
2
  # This will always be up to date with the current version of Vagrant,
3
3
  # since it is used to generate the gemspec and is also the source of
4
4
  # the version for `vagrant -v`
5
- VERSION = "0.7.0.beta2"
5
+ VERSION = "0.7.0"
6
6
  end
@@ -24,18 +24,19 @@ Vagrant::Config.run do |config|
24
24
  # Share an additional folder to the guest VM. The first argument is
25
25
  # an identifier, the second is the path on the guest to mount the
26
26
  # folder, and the third is the path on the host to the actual folder.
27
- # config.vm.share_folder("v-data", "/vagrant_data", "../data")
27
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
28
28
 
29
29
  # Enable provisioning with chef solo, specifying a cookbooks path (relative
30
30
  # to this Vagrantfile), and adding some recipes and/or roles.
31
31
  #
32
- # config.vm.provisioner = :chef_solo
33
- # config.chef.cookbooks_path = "cookbooks"
34
- # config.chef.add_recipe "mysql"
35
- # config.chef.add_role "web"
32
+ # config.vm.provision :chef_solo do |chef|
33
+ # chef.cookbooks_path = "cookbooks"
34
+ # chef.add_recipe "mysql"
35
+ # chef.add_role "web"
36
36
  #
37
- # You may also specify custom JSON attributes:
38
- # config.chef.json = { :mysql_password => "foo" }
37
+ # # You may also specify custom JSON attributes:
38
+ # chef.json = { :mysql_password => "foo" }
39
+ # end
39
40
 
40
41
  # Enable provisioning with chef server, specifying the chef server URL,
41
42
  # and the path to the validation key (relative to this Vagrantfile).
@@ -47,9 +48,10 @@ Vagrant::Config.run do |config|
47
48
  # HTTP instead of HTTPS depending on your configuration. Also change the
48
49
  # validation key to validation.pem.
49
50
  #
50
- # config.vm.provisioner = :chef_server
51
- # config.chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
52
- # config.chef.validation_key_path = "ORGNAME-validator.pem"
51
+ # config.vm.provision :chef_server do |chef|
52
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
53
+ # chef.validation_key_path = "ORGNAME-validator.pem"
54
+ # end
53
55
  #
54
56
  # If you're using the Opscode platform, your validator client is
55
57
  # ORGNAME-validator, replacing ORGNAME with your organization name.
@@ -57,5 +59,5 @@ Vagrant::Config.run do |config|
57
59
  # IF you have your own Chef Server, the default validation client name is
58
60
  # chef-validator, unless you changed the configuration.
59
61
  #
60
- # config.chef.validation_client_name = "ORGNAME-validator"
62
+ # chef.validation_client_name = "ORGNAME-validator"
61
63
  end
@@ -84,6 +84,10 @@ en:
84
84
  permissions on the following file to 0600 and then try running this command again:
85
85
 
86
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!
87
91
  ssh_unavailable: "`ssh` binary could not be found. Is an SSH client installed?"
88
92
  ssh_unavailable_windows: |-
89
93
  `vagrant ssh` isn't available on the Windows platform. The
@@ -475,6 +479,7 @@ en:
475
479
  running_puppet: "Running Puppet with %{manifest}..."
476
480
  manifest_missing: "The Puppet %{manifest} manifest is missing. You cannot configure this box."
477
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}"
478
483
 
479
484
  puppet_server:
480
485
  not_detected: |-
@@ -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
@@ -41,6 +41,20 @@ class PuppetProvisionerTest < Test::Unit::TestCase
41
41
  assert_equal "woot.pp", @config.computed_manifest_file
42
42
  end
43
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
+
44
58
  should "be valid" do
45
59
  @config.validate(@errors)
46
60
  assert @errors.errors.empty?
@@ -63,11 +77,27 @@ class PuppetProvisionerTest < Test::Unit::TestCase
63
77
  @config.validate(@errors)
64
78
  assert !@errors.errors.empty?
65
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
66
93
  end
67
94
 
68
95
  context "preparing" do
69
96
  should "share manifests" do
70
- @action.expects(:share_manifests).once
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)
71
101
  @action.prepare
72
102
  end
73
103
  end
@@ -76,26 +106,30 @@ class PuppetProvisionerTest < Test::Unit::TestCase
76
106
  should "run the proper sequence of methods in order" do
77
107
  prov_seq = sequence("prov_seq")
78
108
  @action.expects(:verify_binary).with("puppet").once.in_sequence(prov_seq)
79
- @action.expects(:create_pp_path).once.in_sequence(prov_seq)
80
109
  @action.expects(:run_puppet_client).once.in_sequence(prov_seq)
81
110
  @action.provision!
82
111
  end
83
112
  end
84
113
 
85
114
  context "share manifests folder" do
86
- setup do
87
- @manifests_path = "manifests"
88
- @pp_path = "/tmp/vagrant-puppet"
89
- @action.stubs(:manifests_path).returns(@manifests_path)
90
- @action.stubs(:pp_path).returns(@pp_path)
91
- end
92
-
93
115
  should "share manifest folder" do
94
- @env.config.vm.expects(:share_folder).with("manifests", @pp_path, @manifests_path)
116
+ @env.config.vm.expects(:share_folder).with("manifests", @action.manifests_guest_path, @config.expanded_manifests_path)
95
117
  @action.share_manifests
96
118
  end
97
119
  end
98
120
 
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
127
+
128
+ @action.set_module_paths
129
+ @action.share_module_paths
130
+ end
131
+ end
132
+
99
133
  context "verifying binary" do
100
134
  setup do
101
135
  @ssh = mock("ssh")
@@ -109,25 +143,15 @@ class PuppetProvisionerTest < Test::Unit::TestCase
109
143
  end
110
144
  end
111
145
 
112
- context "create pp path" do
113
- should "create and chown the folder to the ssh user" do
114
- ssh_seq = sequence("ssh_seq")
115
- ssh = mock("ssh")
116
- ssh.expects(:exec!).with("sudo mkdir -p #{@config.pp_path}").once.in_sequence(ssh_seq)
117
- ssh.expects(:exec!).with("sudo chown #{@env.config.ssh.username} #{@config.pp_path}").once.in_sequence(ssh_seq)
118
- @vm.ssh.expects(:execute).yields(ssh)
119
- @action.create_pp_path
120
- end
121
- end
122
-
123
146
  context "running puppet client" do
124
147
  setup do
125
148
  @ssh = mock("ssh")
126
149
  @vm.ssh.stubs(:execute).yields(@ssh)
150
+ @action.set_module_paths
127
151
  end
128
152
 
129
153
  def expect_puppet_command(command)
130
- @ssh.expects(:exec!).with("sudo -i 'cd #{@config.pp_path}; #{command}'")
154
+ @ssh.expects(:exec!).with("sudo -i 'cd #{@action.manifests_guest_path}; #{command}'")
131
155
  end
132
156
 
133
157
  should "cd into the pp_path directory and run puppet" do
@@ -146,5 +170,13 @@ class PuppetProvisionerTest < Test::Unit::TestCase
146
170
  expect_puppet_command("puppet --modulepath modules --verbose #{@config.computed_manifest_file}")
147
171
  @action.run_puppet_client
148
172
  end
173
+
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
179
+ @action.run_puppet_client
180
+ end
149
181
  end
150
182
  end
@@ -19,6 +19,7 @@ class SshTest < Test::Unit::TestCase
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', :port => 'bag'}
57
- ssh_exec_expect(args[:port], args[:private_key_path], args[:username], args[:host])
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
 
@@ -116,10 +117,10 @@ class SshTest < Test::Unit::TestCase
116
117
 
117
118
  def ssh_exec_expect(port, key_path, uname, host)
118
119
  Kernel.expects(:exec).with() do |arg|
119
- assert arg =~ /^ssh/
120
- assert arg =~ /-p #{port}/
121
- assert arg =~ /-i #{key_path}/
122
- 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"
123
124
  yield arg if block_given?
124
125
  true
125
126
  end
@@ -198,6 +199,7 @@ class SshTest < Test::Unit::TestCase
198
199
  setup do
199
200
  mock_ssh
200
201
  @ssh.stubs(:check_key_permissions)
202
+ @ssh.stubs(:port).returns(2222)
201
203
  end
202
204
 
203
205
  should "return true if SSH connection works" do
data/vagrant.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency "net-scp", "~> 1.0.4"
23
23
  s.add_dependency "i18n", "~> 0.5.0"
24
24
  s.add_dependency "thor", "~> 0.14.6"
25
- s.add_dependency "virtualbox", "~> 0.8.1"
25
+ s.add_dependency "virtualbox", "~> 0.8.2"
26
26
 
27
27
  s.add_development_dependency "rake"
28
28
  s.add_development_dependency "contest", ">= 0.1.2"
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ prerelease: false
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
8
  - 0
9
- - beta2
10
- version: 0.7.0.beta2
9
+ version: 0.7.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Mitchell Hashimoto
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2011-01-13 00:00:00 -08:00
18
+ date: 2011-01-19 00:00:00 -08:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -149,8 +148,8 @@ dependencies:
149
148
  segments:
150
149
  - 0
151
150
  - 8
152
- - 1
153
- version: 0.8.1
151
+ - 2
152
+ version: 0.8.2
154
153
  type: :runtime
155
154
  prerelease: false
156
155
  version_requirements: *id009
@@ -467,7 +466,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
467
466
  requirements:
468
467
  - - ">="
469
468
  - !ruby/object:Gem::Version
470
- hash: 4588961819893742536
469
+ hash: -3286949326636393746
471
470
  segments:
472
471
  - 0
473
472
  version: "0"