kitchen-vagrant 0.11.3 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +44 -31
- data/kitchen-vagrant.gemspec +1 -1
- data/lib/kitchen/driver/vagrant.rb +55 -6
- data/lib/kitchen/driver/vagrant_version.rb +1 -1
- data/templates/Vagrantfile.erb +48 -0
- metadata +5 -5
- data/lib/kitchen/vagrant/vagrantfile_creator.rb +0 -173
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be1f6aa281e6d30bac21b1d0d2ea90d8aceeb97d
|
4
|
+
data.tar.gz: 164abbd12a39dda7d94d80473e3e0b5f525ff3d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d54365a1ed0862fecbbb34f4a3185cf6ef98dff6f6a92525767fc0dc87b53c33c523eda2e9a40b4e9c225b00a12df849c6b0db3da4e9d9f6adf32603471b3f8
|
7
|
+
data.tar.gz: 38001ca6c09018623d6209f480258f36983dd6203b2e7eecbcaded4eb4a1867813b46fd6a44e70a70f506b7eb50a0d706cbcaa0b4f93cac40dca059796d2916d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 0.12.0 / 2013-11-29
|
2
|
+
|
3
|
+
### Breaking changes
|
4
|
+
|
5
|
+
* Remove `use_vagrant_provision` configuration option.
|
6
|
+
|
7
|
+
### New features
|
8
|
+
|
9
|
+
* Major refactor of Vagrantfile generation, to use an ERB template. For more details please consult the `vagrantfile_erb` section of the README. (@fnicho)
|
10
|
+
* Add `pre_create_command` option to run optional setup such as Bindler. (@fnichol)
|
11
|
+
|
12
|
+
### Improvments
|
13
|
+
|
14
|
+
* Pull request #56: Enabled passing options to the synced folders. (@antonio-osorio)
|
15
|
+
* Pull request #55: Fix README badges. (@arangamani)
|
16
|
+
|
17
|
+
|
1
18
|
## 0.11.3 / 2013-11-09
|
2
19
|
|
3
20
|
### Bug fixes
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# <a name="title"></a> Kitchen::Vagrant
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
4
|
-
[![Code Climate](https://codeclimate.com/github/
|
3
|
+
[![Build Status](https://travis-ci.org/test-kitchen/kitchen-vagrant.png)](https://travis-ci.org/test-kitchen/kitchen-vagrant)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/test-kitchen/kitchen-vagrant.png)](https://codeclimate.com/github/test-kitchen/kitchen-vagrant)
|
5
5
|
|
6
6
|
A Test Kitchen Driver for Vagrant.
|
7
7
|
|
8
8
|
This driver works by generating a single Vagrantfile for each instance in a
|
9
9
|
sandboxed directory. Since the Vagrantfile is written out on disk, Vagrant
|
10
|
-
needs absolutely no knowledge of Test Kitchen. So no Vagrant
|
10
|
+
needs absolutely no knowledge of Test Kitchen. So no Vagrant plugins are
|
11
11
|
required.
|
12
12
|
|
13
13
|
## <a name="requirements"></a> Requirements
|
@@ -51,7 +51,8 @@ Please read the [Driver usage][driver_usage] page for more details.
|
|
51
51
|
## <a name="default-config"></a> Default Configuration
|
52
52
|
|
53
53
|
This driver can predict the Vagrant box name and download URL for a select
|
54
|
-
number of platforms that have been published by
|
54
|
+
number of platforms (VirtualBox provider only) that have been published by
|
55
|
+
Opscode, such as:
|
55
56
|
|
56
57
|
```ruby
|
57
58
|
---
|
@@ -93,7 +94,9 @@ platforms:
|
|
93
94
|
details, please read the Vagrant [machine settings][vagrant_machine_settings]
|
94
95
|
page.
|
95
96
|
|
96
|
-
|
97
|
+
The default will be computed from the platform name of the instance. For
|
98
|
+
example, a platform called "fuzzypants-9.000" will produce a default `box`
|
99
|
+
value of `"opscode-fuzzypants-9.000"`.
|
97
100
|
|
98
101
|
### <a name="config-box-url"></a> box\_url
|
99
102
|
|
@@ -101,7 +104,7 @@ The URL that the configured box can be found at. If the box is not installed on
|
|
101
104
|
the system, it will be retrieved from this URL when the virtual machine is
|
102
105
|
started.
|
103
106
|
|
104
|
-
|
107
|
+
The default will be computed from the platform name of the instance.
|
105
108
|
|
106
109
|
### <a name="config-provider"></a> provider
|
107
110
|
|
@@ -179,15 +182,25 @@ end
|
|
179
182
|
Please read the Vagrant [networking basic usage][vagrant_networking] page for
|
180
183
|
more details.
|
181
184
|
|
182
|
-
|
185
|
+
The default is an empty Array, `[]`.
|
183
186
|
|
184
|
-
### <a name="config-
|
187
|
+
### <a name="config-pre-create-command"></a> pre\_create\_command
|
185
188
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
be
|
189
|
+
An optional hoook to run a command immediately prior to the
|
190
|
+
`vagrant up --no-provisioner` command being executed.
|
191
|
+
|
192
|
+
There is an optional token, `{{vagrant_root}}` that can be used in the
|
193
|
+
`pre_create_command` string which will be expanded by the driver to be the full
|
194
|
+
path to the sandboxed Vagrant root directory containing the Vagrantfile. This
|
195
|
+
command will be executed from the directory containing the .kitchen.yml file,
|
196
|
+
or the `kitchen_root`.
|
197
|
+
|
198
|
+
For example, if your project requires
|
199
|
+
[Bindler](https://github.com/fgrehm/bindler), this command could be:
|
200
|
+
|
201
|
+
```
|
202
|
+
pre_create_command: cp .vagrant_plugins.json {{vagrant_root}}/ && vagrant plugin bundle
|
203
|
+
```
|
191
204
|
|
192
205
|
The default is unset, or `nil`.
|
193
206
|
|
@@ -200,7 +213,8 @@ The default is an empty Array, or `[]`. The example:
|
|
200
213
|
|
201
214
|
```ruby
|
202
215
|
driver_config:
|
203
|
-
synced_folders: [["/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef"]
|
216
|
+
synced_folders: [["/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef"],
|
217
|
+
["/host_path", "/vm_path", "create: true, disabled: false"]]
|
204
218
|
```
|
205
219
|
|
206
220
|
will generate a Vagrantfile configuration similar to:
|
@@ -210,25 +224,10 @@ Vagrant.configure("2") do |config|
|
|
210
224
|
# ...
|
211
225
|
|
212
226
|
c.vm.synced_folder "/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef"
|
227
|
+
c.vm.synced_folder "/host_path", "/vm_path", create: true, disabled: false
|
213
228
|
end
|
214
229
|
```
|
215
230
|
|
216
|
-
### <a name="config-require-chef-omnibus"></a> require\_chef\_omnibus
|
217
|
-
|
218
|
-
Determines whether or not a Chef [Omnibus package][chef_omnibus_dl] will be
|
219
|
-
installed. There are several different behaviors available:
|
220
|
-
|
221
|
-
* `true` - the latest release will be installed. Subsequent converges
|
222
|
-
will skip re-installing if chef is present.
|
223
|
-
* `latest` - the latest release will be installed. Subsequent converges
|
224
|
-
will always re-install even if chef is present.
|
225
|
-
* `<VERSION_STRING>` (ex: `10.24.0`) - the desired version string will
|
226
|
-
be passed the the install.sh script. Subsequent converges will skip if
|
227
|
-
the installed version and the desired version match.
|
228
|
-
* `false` or `nil` - no chef is installed.
|
229
|
-
|
230
|
-
The default value is unset, or `nil`.
|
231
|
-
|
232
231
|
### <a name="config-username"></a> username
|
233
232
|
|
234
233
|
This is the username used for SSH authentication if you
|
@@ -237,6 +236,21 @@ would like to connect with a different account than Vagrant default user.
|
|
237
236
|
If this value is nil, then Vagrant parameter `config.ssh.default.username`
|
238
237
|
will be used (which is usually set to 'vagrant').
|
239
238
|
|
239
|
+
### <a name="config-vagrantfile-erb"></a> vagrantfile\_erb
|
240
|
+
|
241
|
+
An alternamte Vagrantfile ERB template that will be rendered for use by this
|
242
|
+
driver. The binding context for the ERB processing is that of the Driver
|
243
|
+
object, which means that methods like `config[:kitchen_root]`, `instance.name`,
|
244
|
+
and `instance.provisioner[:run_list]` can be used to compose a custom
|
245
|
+
Vagrantfile if necessary.
|
246
|
+
|
247
|
+
**Warning:** Be cautious when going down this road as your setup may cease to
|
248
|
+
be portable or applicable to other Test Kitchen Drivers such as Ec2 or Docker.
|
249
|
+
Using the alternative Vagrantfile template strategy may be a dangerous
|
250
|
+
road--be aware.
|
251
|
+
|
252
|
+
The default is to use a template which ships with this gem.
|
253
|
+
|
240
254
|
### <a name="config-ssh-key"></a> ssh\_key
|
241
255
|
|
242
256
|
This is the path to the private key file used for SSH authentication if you
|
@@ -278,7 +292,6 @@ Apache 2.0 (see [LICENSE][license])
|
|
278
292
|
[license]: https://github.com/opscode/kitchen-vagrant/blob/master/LICENSE
|
279
293
|
[repo]: https://github.com/opscode/kitchen-vagrant
|
280
294
|
[driver_usage]: http://docs.kitchen-ci.org/drivers/usage
|
281
|
-
[chef_omnibus_dl]: http://www.opscode.com/chef/install/
|
282
295
|
|
283
296
|
[vagrant_dl]: http://downloads.vagrantup.com/
|
284
297
|
[vagrant_machine_settings]: http://docs.vagrantup.com/v2/vagrantfile/machine_settings.html
|
data/kitchen-vagrant.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_dependency 'test-kitchen', '~> 1.0.0.
|
21
|
+
gem.add_dependency 'test-kitchen', '~> 1.0.0.rc'
|
22
22
|
|
23
23
|
gem.add_development_dependency 'cane'
|
24
24
|
gem.add_development_dependency 'tailor'
|
@@ -20,7 +20,6 @@ require 'fileutils'
|
|
20
20
|
require 'rubygems/version'
|
21
21
|
|
22
22
|
require 'kitchen'
|
23
|
-
require 'kitchen/vagrant/vagrantfile_creator'
|
24
23
|
|
25
24
|
module Kitchen
|
26
25
|
|
@@ -35,10 +34,20 @@ module Kitchen
|
|
35
34
|
class Vagrant < Kitchen::Driver::SSHBase
|
36
35
|
|
37
36
|
default_config :customize, { :memory => '256' }
|
38
|
-
default_config :
|
37
|
+
default_config :network, []
|
38
|
+
default_config :synced_folders, []
|
39
|
+
default_config :pre_create_command, nil
|
40
|
+
|
41
|
+
default_config :vagrantfile_erb,
|
42
|
+
File.join(File.dirname(__FILE__), "../../../templates/Vagrantfile.erb")
|
43
|
+
|
44
|
+
default_config :provider,
|
45
|
+
ENV.fetch('VAGRANT_DEFAULT_PROVIDER', "virtualbox")
|
46
|
+
|
39
47
|
default_config :box do |driver|
|
40
48
|
"opscode-#{driver.instance.platform.name}"
|
41
49
|
end
|
50
|
+
|
42
51
|
default_config :box_url do |driver|
|
43
52
|
"https://opscode-vm-bento.s3.amazonaws.com/vagrant/" \
|
44
53
|
"opscode_#{driver.instance.platform.name}_provisionerless.box"
|
@@ -50,8 +59,9 @@ module Kitchen
|
|
50
59
|
|
51
60
|
def create(state)
|
52
61
|
create_vagrantfile
|
62
|
+
run_pre_create_command
|
53
63
|
cmd = "vagrant up --no-provision"
|
54
|
-
cmd += " --provider=#{
|
64
|
+
cmd += " --provider=#{config[:provider]}" if config[:provider]
|
55
65
|
run cmd
|
56
66
|
set_ssh_state(state)
|
57
67
|
info("Vagrant instance #{instance.to_str} created.")
|
@@ -87,6 +97,11 @@ module Kitchen
|
|
87
97
|
check_vagrant_version
|
88
98
|
end
|
89
99
|
|
100
|
+
def instance=(instance)
|
101
|
+
@instance = instance
|
102
|
+
resolve_config!
|
103
|
+
end
|
104
|
+
|
90
105
|
protected
|
91
106
|
|
92
107
|
WEBSITE = "http://downloads.vagrantup.com/"
|
@@ -102,6 +117,12 @@ module Kitchen
|
|
102
117
|
:live_stream => nil, :quiet => logger.debug? ? false : true)
|
103
118
|
end
|
104
119
|
|
120
|
+
def run_pre_create_command
|
121
|
+
if config[:pre_create_command]
|
122
|
+
run(config[:pre_create_command], :cwd => config[:kitchen_root])
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
105
126
|
def vagrant_root
|
106
127
|
@vagrant_root ||= File.join(
|
107
128
|
config[:kitchen_root], %w{.kitchen kitchen-vagrant}, instance.name
|
@@ -114,12 +135,21 @@ module Kitchen
|
|
114
135
|
vagrantfile = File.join(vagrant_root, "Vagrantfile")
|
115
136
|
debug("Creating Vagrantfile for #{instance.to_str} (#{vagrantfile})")
|
116
137
|
FileUtils.mkdir_p(vagrant_root)
|
117
|
-
File.open(vagrantfile, "wb") { |f| f.write(
|
138
|
+
File.open(vagrantfile, "wb") { |f| f.write(render_template) }
|
139
|
+
debug_vagrantfile(vagrantfile)
|
118
140
|
@vagrantfile_created = true
|
119
141
|
end
|
120
142
|
|
121
|
-
def
|
122
|
-
|
143
|
+
def render_template
|
144
|
+
if File.exists?(template)
|
145
|
+
ERB.new(IO.read(template)).result(binding).gsub(%r{^\s*$\n}, '')
|
146
|
+
else
|
147
|
+
raise ActionFailed, "Could not find Vagrantfile template #{template}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def template
|
152
|
+
File.expand_path(config[:vagrantfile_erb], config[:kitchen_root])
|
123
153
|
end
|
124
154
|
|
125
155
|
def set_ssh_state(state)
|
@@ -140,6 +170,25 @@ module Kitchen
|
|
140
170
|
Hash[lines]
|
141
171
|
end
|
142
172
|
|
173
|
+
def debug_vagrantfile(vagrantfile)
|
174
|
+
if logger.debug?
|
175
|
+
debug("------------")
|
176
|
+
IO.read(vagrantfile).each_line { |l| debug("#{l.chomp}") }
|
177
|
+
debug("------------")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def resolve_config!
|
182
|
+
unless config[:vagrantfile_erb].nil?
|
183
|
+
config[:vagrantfile_erb] =
|
184
|
+
File.expand_path(config[:vagrantfile_erb], config[:kitchen_root])
|
185
|
+
end
|
186
|
+
unless config[:pre_create_command].nil?
|
187
|
+
config[:pre_create_command] =
|
188
|
+
config[:pre_create_command].gsub("{{vagrant_root}}", vagrant_root)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
143
192
|
def vagrant_version
|
144
193
|
version_string = silently_run("vagrant --version")
|
145
194
|
version_string = version_string.chomp.split(" ").last
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Vagrant.configure("2") do |c|
|
2
|
+
c.vm.box = "<%= config[:box] %>"
|
3
|
+
c.vm.box_url = "<%= config[:box_url] %>"
|
4
|
+
c.vm.hostname = "<%= instance.name %>.vagrantup.com"
|
5
|
+
|
6
|
+
<% if config[:guest] %>
|
7
|
+
c.vm.guest = <%= config[:guest] %>
|
8
|
+
<% end %>
|
9
|
+
<% if config[:username] %>
|
10
|
+
c.ssh.username = "<%= config[:username] %>"
|
11
|
+
<% end %>
|
12
|
+
<% if config[:ssh_key] %>
|
13
|
+
c.ssh.private_key_path = "<%= config[:ssh_key] %>"
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<% Array(config[:network]).each do |opts| %>
|
17
|
+
c.vm.network(:<%= opts[0] %>, <%= opts[1..-1].join(", ") %>)
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
c.vm.synced_folder ".", "/vagrant", disabled: true
|
21
|
+
<% config[:synced_folders].each do |source, destination, options|
|
22
|
+
l_source = source.gsub("%{instance_name}", instance.name)
|
23
|
+
l_destination = destination.gsub("%{instance_name}", instance.name)
|
24
|
+
opt = (options.nil? ? '' : ", #{options}")
|
25
|
+
%>
|
26
|
+
c.vm.synced_folder "<%= l_source %>", "<%= l_destination %>"<%= opt %>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
c.vm.provider :<%= config[:provider] %> do |p|
|
30
|
+
<% config[:customize].each do |key, value| %>
|
31
|
+
<% case config[:provider]
|
32
|
+
when "virtualbox" %>
|
33
|
+
p.customize ["modifyvm", :id, "--<%= key %>", "<%= value %>"]
|
34
|
+
<% when "rackspace" %>
|
35
|
+
p.<%= key %> = "<%= value%>"
|
36
|
+
<% when /^vmware_/ %>
|
37
|
+
<% if key == :memory %>
|
38
|
+
<% unless config[:customize].include?(:memsize) %>
|
39
|
+
p.vmx["memsize"] = "<%= value %>"
|
40
|
+
<% end %>
|
41
|
+
<% else %>
|
42
|
+
p.vmx["<%= key %>"] = "<%= value %>"
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-vagrant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fletcher Nichol
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0.
|
19
|
+
version: 1.0.0.rc
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.0.
|
26
|
+
version: 1.0.0.rc
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cane
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,7 +83,7 @@ files:
|
|
83
83
|
- kitchen-vagrant.gemspec
|
84
84
|
- lib/kitchen/driver/vagrant.rb
|
85
85
|
- lib/kitchen/driver/vagrant_version.rb
|
86
|
-
-
|
86
|
+
- templates/Vagrantfile.erb
|
87
87
|
homepage: https://github.com/opscode/kitchen-vagrant/
|
88
88
|
licenses:
|
89
89
|
- Apache 2.0
|
@@ -1,173 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2013, Fletcher Nichol
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
module Kitchen
|
20
|
-
|
21
|
-
module Vagrant
|
22
|
-
|
23
|
-
# Class to render Vagrantfiles to be used by the Kitchen Vagrant driver.
|
24
|
-
#
|
25
|
-
# @author Fletcher Nichol <fnichol@nichol.ca>
|
26
|
-
class VagrantfileCreator
|
27
|
-
|
28
|
-
def initialize(instance, config)
|
29
|
-
@instance = instance
|
30
|
-
@config = config
|
31
|
-
end
|
32
|
-
|
33
|
-
def render
|
34
|
-
arr = []
|
35
|
-
arr << %{Vagrant.configure("2") do |c|}
|
36
|
-
common_block(arr)
|
37
|
-
guest_block(arr)
|
38
|
-
network_block(arr)
|
39
|
-
provider_block(arr)
|
40
|
-
chef_block(arr) if config[:use_vagrant_provision]
|
41
|
-
synced_folders_block(arr)
|
42
|
-
arr << %{end}
|
43
|
-
arr.join("\n")
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
attr_reader :instance, :config
|
49
|
-
|
50
|
-
def common_block(arr)
|
51
|
-
arr << %{ c.vm.box = "#{config[:box]}"}
|
52
|
-
arr << %{ c.vm.box_url = "#{config[:box_url]}"} if config[:box_url]
|
53
|
-
arr << %{ c.vm.synced_folder ".", "/vagrant", disabled: true}
|
54
|
-
if config[:ssh_key]
|
55
|
-
arr << %{ c.ssh.private_key_path = "#{config[:ssh_key]}"}
|
56
|
-
end
|
57
|
-
arr << %{ c.vm.hostname = "#{instance.name}.vagrantup.com"}
|
58
|
-
arr << %{ c.ssh.username = "#{config[:username]}"} if config[:username]
|
59
|
-
end
|
60
|
-
|
61
|
-
def guest_block(arr)
|
62
|
-
if config[:guest]
|
63
|
-
arr << %{ c.vm.guest = #{config[:guest]}}
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def network_block(arr)
|
68
|
-
Array(config[:network]).each do |network_options|
|
69
|
-
options = Array(network_options.dup)
|
70
|
-
type = options.shift
|
71
|
-
arr << %{ c.vm.network(:#{type}, #{options.join(", ")})}
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def provider_block(arr)
|
76
|
-
arr << %{ c.vm.provider :#{provider} do |p|}
|
77
|
-
case provider
|
78
|
-
when 'virtualbox'
|
79
|
-
virtualbox_customize(arr)
|
80
|
-
when 'vmware_fusion', 'vmware_workstation'
|
81
|
-
vmware_customize(arr)
|
82
|
-
when 'rackspace'
|
83
|
-
rackspace_customize(arr)
|
84
|
-
end
|
85
|
-
arr << %{ end}
|
86
|
-
end
|
87
|
-
|
88
|
-
def chef_block(arr)
|
89
|
-
arr << %{ c.vm.provision :chef_solo do |chef|}
|
90
|
-
arr << %{ chef.log_level = #{vagrant_logger_level}}
|
91
|
-
arr << %{ chef.run_list = #{instance.run_list.inspect}}
|
92
|
-
arr << %{ chef.json = #{instance.attributes.to_s}}
|
93
|
-
if instance.suite.data_bags_path
|
94
|
-
arr << %{ chef.data_bags_path = "#{instance.suite.data_bags_path}"}
|
95
|
-
end
|
96
|
-
if key_path
|
97
|
-
arr << %{ chef.encrypted_data_bag_secret_key_path = "#{key_path}"}
|
98
|
-
end
|
99
|
-
if instance.suite.roles_path
|
100
|
-
arr << %{ chef.roles_path = "#{instance.suite.roles_path}"}
|
101
|
-
end
|
102
|
-
arr << %{ end}
|
103
|
-
end
|
104
|
-
|
105
|
-
def synced_folders_block(arr)
|
106
|
-
config[:synced_folders].each do |source, destination|
|
107
|
-
arr << %{ c.vm.synced_folder "#{source}", "#{destination}" }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def vagrant_logger_level
|
112
|
-
if instance.logger.debug?
|
113
|
-
":debug"
|
114
|
-
elsif instance.logger.info?
|
115
|
-
":info"
|
116
|
-
elsif instance.logger.error?
|
117
|
-
":error"
|
118
|
-
elsif instance.logger.fatal?
|
119
|
-
":fatal"
|
120
|
-
else
|
121
|
-
":info"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def berksfile
|
126
|
-
File.join(config[:kitchen_root], "Berksfile")
|
127
|
-
end
|
128
|
-
|
129
|
-
def provider
|
130
|
-
config[:provider] || ENV['VAGRANT_DEFAULT_PROVIDER'] || 'virtualbox'
|
131
|
-
end
|
132
|
-
|
133
|
-
def virtualbox_customize(arr)
|
134
|
-
config[:customize].each do |key, value|
|
135
|
-
arr << %{ p.customize ["modifyvm", :id, "--#{key}", "#{value}"]}
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def vmware_customize(arr)
|
140
|
-
config[:customize].each do |key, value|
|
141
|
-
if key == :memory
|
142
|
-
# XXX: This is kind of a hack to address the fact that
|
143
|
-
# "memory" is a default attribute in our Vagrant driver.
|
144
|
-
#
|
145
|
-
# The VMware VMX format expects to see "memsize" instead of
|
146
|
-
# just "memory" like Virtualbox would. So if "memsize" has
|
147
|
-
# been specified we simply ignore the "memory" option.
|
148
|
-
unless config[:customize].include?(:memsize)
|
149
|
-
arr << %{ p.vmx["memsize"] = "#{value}"}
|
150
|
-
end
|
151
|
-
else
|
152
|
-
arr << %{ p.vmx["#{key}"] = "#{value}"}
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def rackspace_customize(arr)
|
158
|
-
config[:customize].each do |key, value|
|
159
|
-
arr << %{ p.#{key} = "#{value}"}
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def key_path
|
164
|
-
return nil if instance.suite.encrypted_data_bag_secret_key_path.nil?
|
165
|
-
|
166
|
-
File.join(
|
167
|
-
config[:kitchen_root],
|
168
|
-
instance.suite.encrypted_data_bag_secret_key_path
|
169
|
-
)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|