kitchen-vagrant_winrm 0.1.0.dev

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 731e936ca7b82e40170ad4b5ff87fe021ba81f07
4
+ data.tar.gz: ec0f4402b789b1d8aa3ec1c56c3f0836c6f2d16c
5
+ SHA512:
6
+ metadata.gz: 3401aa4464a02e901e43513237fd787546cc0158c196c6cd60e5e28052d48456983ae2fa2348c12e7c2ef0ab6a56ec9ae129bac42d1c8180ff92298c3c00f4cf
7
+ data.tar.gz: e9c02e178485c0d4ad707f9f70537457601c9ba0b9cad01a162d0530aa659d46c65a34878ea0f60f2b9e2d4cd169ba62f03f5f3c2ceb94ee61c5fc8a2ee1168b
data/.cane ADDED
File without changes
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/.tailor ADDED
@@ -0,0 +1,4 @@
1
+ Tailor.config do |config|
2
+ config.formatters "text"
3
+ config.file_set 'lib/**/*.rb'
4
+ end
@@ -0,0 +1,3 @@
1
+ ## 0.1.0 / Unreleased
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'goag', :git => 'https://gitlab.criteois.lan/ruby-gems/goag.git', :branch => '0.0.3'
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Author:: Baptiste Courtois (<b.courtois@criteo.com>)
2
+
3
+ Copyright (C) 2014, Baptiste Courtois
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -0,0 +1,334 @@
1
+ # <a name="title"></a> Kitchen::VagrantWinrm
2
+
3
+ A Test Kitchen Driver for Vagrant using WinRM.
4
+
5
+ This driver is mainly the same as [kitchen-vagrant][kitchen_vagrant], but
6
+ instead of using SSHBase class it's using the vagrant plugin
7
+ [Vagrant-winrm][vagrant_winrm] to communicate with the machine through WinRM
8
+ protocol.
9
+
10
+ ## <a name="requirements"></a> Requirements
11
+
12
+ ### <a name="dependencies-vagrant"></a> Vagrant
13
+
14
+ A Vagrant version of 1.1.0 or higher is required for this driver which means
15
+ that a [native package][vagrant_dl] must be installed on the system running
16
+ Test Kitchen.
17
+
18
+ **Note:** If you have previously installed Vagrant as a gem (a version prior
19
+ to 1.1.0), this version may be resolved first in your `PATH`. If you receive an
20
+ error message that Vagrant is too old despite having installed Vagrant as a
21
+ package, you may be required to uninstall the gem version or modify your `PATH`
22
+ environment. If you require the vagrant gem for older projects you should
23
+ consider the [vagrant-wrapper][vagrant_wrapper] gem which helps manage both
24
+ styles of Vagrant installations
25
+ ([background details][vagrant_wrapper_background]).
26
+
27
+ ### <a name="dependencies-vagrant-winrm"></a> Vagrant-Winrm plugin
28
+
29
+ The [Vagrant-winrm][vagrant_winrm] plugin is required for this driver to
30
+ communicate with the machine.
31
+
32
+ ### <a name="dependencies-virtualization"></a> Virtualbox and/or VMware Fusion/Workstation
33
+
34
+ Currently this driver supports VirtualBox and VMware Fusion/Workstation.
35
+ Virtualbox is free and is the default provider for Vagrant.
36
+
37
+ [VirtualBox package][virtualbox_dl]
38
+
39
+ If you would like to use VMware Fusion/Workstation you must purchase the
40
+ software from VMware and then must also purchase the Vagrant VMware plugin.
41
+
42
+ [Vagrant VMware Plugin][vmware_plugin]
43
+
44
+ [VMware Fusion][fusion_dl]
45
+
46
+ [VMware Workstation][workstation_dl]
47
+
48
+ ## <a name="installation"></a> Installation and Setup
49
+
50
+ Add this line to your application's `Gemfile`:
51
+
52
+ gem 'kitchen-vagrant_winrm'
53
+
54
+ And then execute:
55
+
56
+ $ bundle
57
+
58
+ Or install it yourself as:
59
+
60
+ $ gem install kitchen-vagrant_winrm
61
+
62
+ Then edit your `.kitchen.yml` to use **vagrant_winrm** as default kitchen driver:
63
+
64
+ driver_plugin: vagrant_winrm
65
+
66
+ Or as machine specific driver:
67
+
68
+ ```ruby
69
+ platforms:
70
+ - name: windows-2008r2
71
+ driver:
72
+ name: vagrant_winrm
73
+ driver_config:
74
+ communicator: 'winrm'
75
+ winrm_username: 'winrm'
76
+ winrm_password: 'winrm_pwd'
77
+ #...
78
+ ```
79
+
80
+ Please read the [Driver usage][driver_usage] page for more details.
81
+
82
+ ## <a name="config"></a> Configuration
83
+
84
+ ### <a name="config-box"></a> box
85
+
86
+ **Required** This determines which Vagrant box will be used. For more
87
+ details, please read the Vagrant [machine settings][vagrant_machine_settings]
88
+ page.
89
+
90
+ The default will be computed from the platform name of the instance. For
91
+ example, a platform called "fuzzypants-9.000" will produce a default `box`
92
+ value of `"opscode-fuzzypants-9.000"`.
93
+
94
+ ### <a name="config-box-url"></a> box\_url
95
+
96
+ The URL that the configured box can be found at. If the box is not installed on
97
+ the system, it will be retrieved from this URL when the virtual machine is
98
+ started.
99
+
100
+ The default will be computed from the platform name of the instance.
101
+
102
+ ### <a name="config-provider"></a> provider
103
+
104
+ This determines which Vagrant provider to use. The value should match
105
+ the provider name in Vagrant. For example, to use VMware Fusion the provider
106
+ should be `vmware_fusion`. Please see the docs on [providers][vagrant_providers]
107
+ for further details.
108
+
109
+ By default the value is unset, or `nil`. In this case the driver will use the
110
+ Vagrant [default provider][vagrant_default_provider] which at this current time
111
+ is `virtualbox` unless set by `VAGRANT_DEFAULT_PROVIDER` environment variable.
112
+
113
+ ### <a name="config-customize"></a> customize
114
+
115
+ A **Hash** of customizations to a Vagrant virtual machine. Each key/value
116
+ pair will be passed to your providers customization block. For example, with
117
+ the default `virtualbox` provider:
118
+
119
+ ```ruby
120
+ driver:
121
+ customize:
122
+ memory: 1024
123
+ cpuexecutioncap: 50
124
+ ```
125
+
126
+ will generate a Vagrantfile configuration similar to:
127
+
128
+ ```ruby
129
+ Vagrant.configure("2") do |config|
130
+ # ...
131
+
132
+ config.vm.provider :virtualbox do |virtualbox|
133
+ virtualbox.customize ["modifyvm", :id, "--memory", "1024"]
134
+ virtualbox.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
135
+ end
136
+ end
137
+ ```
138
+
139
+ Please read the "Customizations" sections for [VirtualBox][vagrant_config_vbox] and [VMware][vagrant_config_vmware] for more details.
140
+
141
+ ### <a name="config-dry-run"></a> dry\_run
142
+
143
+ Useful when debugging Vagrant CLI commands. If set to `true`, all Vagrant CLI
144
+ commands will be displayed rather than executed.
145
+
146
+ The default is unset, or `nil`.
147
+
148
+ ### <a name="config-guest"></a> guest
149
+
150
+ Set the `config.vm.guest` setting in the default Vagrantfile. For more details
151
+ please read the
152
+ [config.vm.guest](http://docs.vagrantup.com/v2/vagrantfile/machine_settings.html)
153
+ section of the Vagrant documentation.
154
+
155
+ The default is unset, or `nil`.
156
+
157
+ ### <a name="config-network"></a> network
158
+
159
+ An **Array** of network customizations for the virtual machine. Each Array
160
+ element is itself an Array of arguments to be passed to the `config.vm.network`
161
+ method. For example:
162
+
163
+ ```ruby
164
+ driver:
165
+ network:
166
+ - ["forwarded_port", {guest: 80, host: 8080}]
167
+ - ["private_network", {ip: "192.168.33.33"}]
168
+ ```
169
+
170
+ will generate a Vagrantfile configuration similar to:
171
+
172
+ ```ruby
173
+ Vagrant.configure("2") do |config|
174
+ # ...
175
+
176
+ config.vm.network :forwarded_port, guest: 80, host: 8080
177
+ config.vm.network :private_network, ip: "192.168.33.33"
178
+ end
179
+ ```
180
+
181
+ Please read the Vagrant [networking basic usage][vagrant_networking] page for
182
+ more details.
183
+
184
+ The default is an empty Array, `[]`.
185
+
186
+ ### <a name="config-pre-create-command"></a> pre\_create\_command
187
+
188
+ An optional hook to run a command immediately prior to the
189
+ `vagrant up --no-provisioner` command being executed.
190
+
191
+ There is an optional token, `{{vagrant_root}}` that can be used in the
192
+ `pre_create_command` string which will be expanded by the driver to be the full
193
+ path to the sandboxed Vagrant root directory containing the Vagrantfile. This
194
+ command will be executed from the directory containing the .kitchen.yml file,
195
+ or the `kitchen_root`.
196
+
197
+ For example, if your project requires
198
+ [Bindler](https://github.com/fgrehm/bindler), this command could be:
199
+
200
+ ```
201
+ pre_create_command: cp .vagrant_plugins.json {{vagrant_root}}/ && vagrant plugin bundle
202
+ ```
203
+
204
+ The default is unset, or `nil`.
205
+
206
+ ### <a name="config-synced-folders"></a> synced_folders
207
+
208
+ Allow the user to specify a collection of synced folders on each Vagrant
209
+ instance. Source paths can be relative to the kitchen root.
210
+
211
+ The default is an empty Array, or `[]`. The example:
212
+
213
+ ```ruby
214
+ driver:
215
+ synced_folders:
216
+ - ["data/%{instance_name}", "/opt/instance_data"]
217
+ - ["/host_path", "/vm_path", "create: true, type: :nfs"]
218
+ ```
219
+
220
+ will generate a Vagrantfile configuration similar to:
221
+
222
+ ```ruby
223
+ Vagrant.configure("2") do |config|
224
+ # ...
225
+
226
+ c.vm.synced_folder "/Users/mray/cookbooks/pxe_dust/data/default-ubuntu-1204", "/opt/instance_data"
227
+ c.vm.synced_folder "/host_path", "/vm_path", create: true, type: :nfs
228
+ end
229
+ ```
230
+
231
+ ### <a name="config-username"></a> username
232
+
233
+ This is the username used for SSH authentication if you
234
+ would like to connect with a different account than Vagrant default user.
235
+
236
+ If this value is nil, then Vagrant parameter `config.ssh.default.username`
237
+ will be used (which is usually set to 'vagrant').
238
+
239
+ ### <a name="config-vagrantfile-erb"></a> vagrantfile\_erb
240
+
241
+ An alternate 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
+
254
+ ### <a name="config-vm-hostname"></a> vm\_hostname
255
+
256
+ Sets the internal hostname for the instance. This is not used when connecting
257
+ to the Vagrant virtual machine.
258
+
259
+ For more details on this setting please read the
260
+ [config.vm.hostname](http://docs.vagrantup.com/v2/vagrantfile/machine_settings.html)
261
+ section of the Vagrant documentation.
262
+
263
+ To prevent this value from being rendered in the default Vagrantfile, you can
264
+ set this value to `false`.
265
+
266
+ The default will be computed from the name of the instance. For
267
+ example, the instance was called "default-fuzz-9" will produce a default
268
+ `vm_hostname` value of `"default-fuzz-9.vagrantup.com"`.
269
+
270
+ ### <a name="config-winrm-username"></a> winrm-username
271
+
272
+ This is the username used for WinRm authentication.
273
+
274
+ The default value is unset, or `nil`.
275
+
276
+ ### <a name="config-winrm-password"></a> winrm-password
277
+
278
+ This is the password used for WinRm authentication.
279
+
280
+ The default value is unset, or `nil`.
281
+
282
+ ### <a name="config-winrm-port"></a> winrm-port
283
+
284
+ This is the port used for WinRm communication.
285
+
286
+ The default value is 5985.
287
+
288
+ ## <a name="development"></a> Development
289
+
290
+ * Source hosted at [Gitlab][repo]
291
+ * Report issues/questions/feature requests on [Gitlab Issues][issues]
292
+
293
+ Pull requests are very welcome! Make sure your patches are well tested.
294
+ Ideally create a topic branch for every separate change you make. For
295
+ example:
296
+
297
+ 1. Fork the repo
298
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
299
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
300
+ 4. Push to the branch (`git push origin my-new-feature`)
301
+ 5. Create new Pull Request
302
+
303
+ ## <a name="authors"></a> Authors
304
+
305
+ Created and maintained by [Baptiste Courtois][author] (<b.courtois@criteo.com>)
306
+
307
+ ## <a name="license"></a> License
308
+
309
+ Apache 2.0 (see [LICENSE][license])
310
+
311
+
312
+ [author]: https://github.com/Annih
313
+ [issues]: https://gitlab.criteois.lan/ruby-gems/kitchen-vagrant_winrm/issues
314
+ [license]: https://gitlab.criteois.lan/ruby-gems/kitchen-vagrant_winrm/blob/master/LICENSE
315
+ [repo]: https://gitlab.criteois.lan/ruby-gems/kitchen-vagrant_winrm
316
+ [driver_usage]: http://docs.kitchen-ci.org/drivers/usage
317
+ [chef_omnibus_dl]: http://www.getchef.com/chef/install/
318
+
319
+ [vagrant_dl]: http://downloads.vagrantup.com/
320
+ [vagrant_machine_settings]: http://docs.vagrantup.com/v2/vagrantfile/machine_settings.html
321
+ [vagrant_networking]: http://docs.vagrantup.com/v2/networking/basic_usage.html
322
+ [virtualbox_dl]: https://www.virtualbox.org/wiki/Downloads
323
+ [vagrantfile]: http://docs.vagrantup.com/v2/vagrantfile/index.html
324
+ [vagrant_default_provider]: http://docs.vagrantup.com/v2/providers/default.html
325
+ [vagrant_config_vbox]: http://docs.vagrantup.com/v2/virtualbox/configuration.html
326
+ [vagrant_config_vmware]: http://docs.vagrantup.com/v2/vmware/configuration.html
327
+ [vagrant_providers]: http://docs.vagrantup.com/v2/providers/index.html
328
+ [vagrant_wrapper]: https://github.com/org-binbab/gem-vagrant-wrapper
329
+ [vagrant_wrapper_background]: https://github.com/org-binbab/gem-vagrant-wrapper#background---aka-the-vagrant-gem-enigma
330
+ [vmware_plugin]: http://www.vagrantup.com/vmware
331
+ [fusion_dl]: http://www.vmware.com/products/fusion/overview.html
332
+ [workstation_dl]: http://www.vmware.com/products/workstation/
333
+ [vagrant_winrm]: https://gitlab.criteois.lan/ruby-gems/vagrant-winrm
334
+ [kitchen_vagrant]: https://github.com/test-kitchen/kitchen-vagrant
@@ -0,0 +1,21 @@
1
+ require "bundler/gem_tasks"
2
+ require 'cane/rake_task'
3
+ require 'tailor/rake_task'
4
+
5
+ desc "Run cane to check quality metrics"
6
+ Cane::RakeTask.new do |cane|
7
+ cane.canefile = './.cane'
8
+ end
9
+
10
+ Tailor::RakeTask.new
11
+
12
+ desc "Display LOC stats"
13
+ task :stats do
14
+ puts "\n## Production Code Stats"
15
+ sh "countloc -r lib"
16
+ end
17
+
18
+ desc "Run all quality tasks"
19
+ task :quality => [:cane, :tailor, :stats]
20
+
21
+ task :default => [:quality]
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kitchen/driver/vagrant_winrm_version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'kitchen-vagrant_winrm'
8
+ spec.version = Kitchen::Driver::VAGRANT_WINRM_VERSION
9
+ spec.authors = ['Baptiste Courtois']
10
+ spec.email = ['b.courtois@criteo.com']
11
+ spec.description = %q{Kitchen::Driver::VagrantWinRM - A Test Kitchen Driver for using Vagrant-WinRM}
12
+ spec.summary = 'A Test Kitchen Driver using vagrant winrm'
13
+ spec.homepage = 'https://gitlab.criteois.lan/ruby-gems/kitchen-vagrant_winrm'
14
+ spec.license = 'Apache 2.0'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = []
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'test-kitchen', '>= 1.2.1'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake'
25
+
26
+ spec.add_development_dependency 'cane'
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'tailor'
29
+ spec.add_development_dependency 'countloc'
30
+ end
@@ -0,0 +1,201 @@
1
+ require 'fileutils'
2
+ require 'rubygems/version'
3
+ require 'kitchen'
4
+
5
+ module Kitchen
6
+
7
+ module Driver
8
+
9
+ # VagrantWinrm driver for Kitchen.
10
+ #
11
+ # @author Baptiste Courtois <b.courtois@criteo.com>
12
+ class VagrantWinrm < Base
13
+
14
+ default_config :customize, {}
15
+ default_config :network, []
16
+ default_config :synced_folders, []
17
+ default_config :pre_create_command, nil
18
+
19
+ default_config :vagrantfile_erb,
20
+ File.join(File.dirname(__FILE__), '../../../templates/Vagrantfile.erb')
21
+
22
+ default_config :provider,
23
+ ENV.fetch('VAGRANT_DEFAULT_PROVIDER', 'virtualbox')
24
+
25
+ default_config :vm_hostname do |driver|
26
+ "#{driver.instance.name}.vagrantup.com"
27
+ end
28
+
29
+ default_config :box do |driver|
30
+ "opscode-#{driver.instance.platform.name}"
31
+ end
32
+
33
+ required_config :box
34
+
35
+ no_parallel_for :create, :destroy
36
+
37
+ def create(state)
38
+ create_vagrantfile
39
+ run_pre_create_command
40
+ cmd = 'vagrant up --no-provision'
41
+ cmd += " --provider=#{config[:provider]}" if config[:provider]
42
+ run cmd
43
+ info("Vagrant instance #{instance.to_str} created.")
44
+ state[:created] = true
45
+ end
46
+
47
+ def converge(state)
48
+ create_vagrantfile
49
+ provisioner = instance.provisioner
50
+ provisioner.create_sandbox
51
+
52
+ run_remote provisioner.install_command
53
+ run_remote provisioner.init_command
54
+
55
+ Dir.glob("#{provisioner.sandbox_path}/*").each do |file|
56
+ remote_file = File.join(provisioner[:root_path], File.basename(file))
57
+ run "vagrant winrm-upload \"#{file}\" \"#{remote_file}\""
58
+ end
59
+
60
+ run_remote provisioner.prepare_command
61
+ run_remote provisioner.run_command
62
+ ensure
63
+ provisioner && provisioner.cleanup_sandbox
64
+ end
65
+
66
+ def setup(state)
67
+ create_vagrantfile
68
+ run "vagrant winrm -c \"#{busser_setup_cmd}\""
69
+ end
70
+
71
+ def verify(state)
72
+ create_vagrantfile
73
+ run "vagrant winrm -c \"#{busser_sync_cmd}\" -c \"#{busser_run_cmd}\""
74
+ end
75
+
76
+ def destroy(state)
77
+ return unless state[:created]
78
+
79
+ create_vagrantfile
80
+ @vagrantfile_created = false
81
+ run 'vagrant destroy -f'
82
+ FileUtils.rm_rf(vagrant_root)
83
+ info("Vagrant instance #{instance.to_str} destroyed.")
84
+ state.delete(:created)
85
+ end
86
+
87
+ def verify_dependencies
88
+ check_vagrant_version
89
+ end
90
+
91
+ def instance=(instance)
92
+ @instance = instance
93
+ resolve_config!
94
+ end
95
+
96
+ protected
97
+
98
+ WEBSITE = 'http://downloads.vagrantup.com/'
99
+ MIN_VER = '1.1.0'
100
+
101
+ def run_remote(cmd, options = {})
102
+ run "vagrant winrm -c \"#{cmd}\""
103
+ end
104
+
105
+ def run(cmd, options = {})
106
+ cmd = "echo #{cmd}" if config[:dry_run]
107
+ run_command(cmd, { :cwd => vagrant_root }.merge(options))
108
+ end
109
+
110
+ def silently_run(cmd)
111
+ run_command(cmd,
112
+ :live_stream => nil, :quiet => logger.debug? ? false : true)
113
+ end
114
+
115
+ def run_pre_create_command
116
+ if config[:pre_create_command]
117
+ run(config[:pre_create_command], :cwd => config[:kitchen_root])
118
+ end
119
+ end
120
+
121
+ def vagrant_root
122
+ @vagrant_root ||= File.join(
123
+ config[:kitchen_root], %w{.kitchen kitchen-vagrant}, instance.name
124
+ )
125
+ end
126
+
127
+ def create_vagrantfile
128
+ return if @vagrantfile_created
129
+
130
+ finalize_synced_folder_config
131
+
132
+ vagrantfile = File.join(vagrant_root, 'Vagrantfile')
133
+ debug("Creating Vagrantfile for #{instance.to_str} (#{vagrantfile})")
134
+ FileUtils.mkdir_p(vagrant_root)
135
+ File.open(vagrantfile, 'wb') { |f| f.write(render_template) }
136
+ debug_vagrantfile(vagrantfile)
137
+ @vagrantfile_created = true
138
+ end
139
+
140
+ def finalize_synced_folder_config
141
+ config[:synced_folders].map! do |source, destination, options|
142
+ [
143
+ File.expand_path(
144
+ source.gsub("%{instance_name}", instance.name),
145
+ config[:kitchen_root]
146
+ ),
147
+ destination.gsub("%{instance_name}", instance.name),
148
+ options || 'nil'
149
+ ]
150
+ end
151
+ end
152
+
153
+ def render_template
154
+ if File.exists?(template)
155
+ ERB.new(IO.read(template)).result(binding).gsub(%r{^\s*$\n}, '')
156
+ else
157
+ raise ActionFailed, "Could not find Vagrantfile template #{template}"
158
+ end
159
+ end
160
+
161
+ def template
162
+ File.expand_path(config[:vagrantfile_erb], config[:kitchen_root])
163
+ end
164
+
165
+ def debug_vagrantfile(vagrantfile)
166
+ if logger.debug?
167
+ debug('------------')
168
+ IO.read(vagrantfile).each_line { |l| debug(l.chomp) }
169
+ debug('------------')
170
+ end
171
+ end
172
+
173
+ def resolve_config!
174
+ unless config[:vagrantfile_erb].nil?
175
+ config[:vagrantfile_erb] =
176
+ File.expand_path(config[:vagrantfile_erb], config[:kitchen_root])
177
+ end
178
+ unless config[:pre_create_command].nil?
179
+ config[:pre_create_command] =
180
+ config[:pre_create_command].gsub('{{vagrant_root}}', vagrant_root)
181
+ end
182
+ end
183
+
184
+ def vagrant_version
185
+ version_string = silently_run('vagrant --version')
186
+ version_string = version_string.chomp.split(' ').last
187
+ rescue Errno::ENOENT
188
+ raise UserError, "Vagrant #{MIN_VER} or higher is not installed." +
189
+ " Please download a package from #{WEBSITE}."
190
+ end
191
+
192
+ def check_vagrant_version
193
+ version = vagrant_version
194
+ if Gem::Version.new(version) < Gem::Version.new(MIN_VER)
195
+ raise UserError, "Detected an old version of Vagrant (#{version})." +
196
+ " Please upgrade to version #{MIN_VER} or higher from #{WEBSITE}."
197
+ end
198
+ end
199
+ end
200
+ end
201
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Baptiste Courtois (<b.courtois@criteo.com>)
4
+ #
5
+ # Copyright (C) 2014, Baptiste Courtois
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 Driver
22
+
23
+ # Version string for VagrantWinrm Kitchen driver
24
+ VAGRANT_WINRM_VERSION = '0.1.0.dev'
25
+ end
26
+ end
@@ -0,0 +1,78 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, make a
10
+ # separate helper file that requires this one and then use it only in the specs
11
+ # that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # The settings below are suggested to provide a good initial experience
19
+ # with RSpec, but feel free to customize to your heart's content.
20
+ =begin
21
+ # These two settings work together to allow you to limit a spec run
22
+ # to individual examples or groups you care about by tagging them with
23
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
24
+ # get run.
25
+ config.filter_run :focus
26
+ config.run_all_when_everything_filtered = true
27
+
28
+ # Many RSpec users commonly either run the entire suite or an individual
29
+ # file, and it's useful to allow more verbose output when running an
30
+ # individual spec file.
31
+ if config.files_to_run.one?
32
+ # Use the documentation formatter for detailed output,
33
+ # unless a formatter has already been configured
34
+ # (e.g. via a command-line flag).
35
+ config.default_formatter = 'doc'
36
+ end
37
+
38
+ # Print the 10 slowest examples and example groups at the
39
+ # end of the spec run, to help surface which specs are running
40
+ # particularly slow.
41
+ config.profile_examples = 10
42
+
43
+ # Run specs in random order to surface order dependencies. If you find an
44
+ # order dependency and want to debug it, you can fix the order by providing
45
+ # the seed, which is printed after each run.
46
+ # --seed 1234
47
+ config.order = :random
48
+
49
+ # Seed global randomization in this process using the `--seed` CLI option.
50
+ # Setting this allows you to use `--seed` to deterministically reproduce
51
+ # test failures related to randomization by passing the same `--seed` value
52
+ # as the one that triggered the failure.
53
+ Kernel.srand config.seed
54
+
55
+ # rspec-expectations config goes here. You can use an alternate
56
+ # assertion/expectation library such as wrong or the stdlib/minitest
57
+ # assertions if you prefer.
58
+ config.expect_with :rspec do |expectations|
59
+ # Enable only the newer, non-monkey-patching expect syntax.
60
+ # For more details, see:
61
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
62
+ expectations.syntax = :expect
63
+ end
64
+
65
+ # rspec-mocks config goes here. You can use an alternate test double
66
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
67
+ config.mock_with :rspec do |mocks|
68
+ # Enable only the newer, non-monkey-patching expect syntax.
69
+ # For more details, see:
70
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71
+ mocks.syntax = :expect
72
+
73
+ # Prevents you from mocking or stubbing a method that does not exist on
74
+ # a real object. This is generally recommended.
75
+ mocks.verify_partial_doubles = true
76
+ end
77
+ =end
78
+ end
@@ -0,0 +1,51 @@
1
+ Vagrant.configure("2") do |c|
2
+ c.vm.box = "<%= config[:box] %>"
3
+ c.vm.box_url = "<%= config[:box_url] %>"
4
+
5
+ <% if config[:vm_hostname] %>
6
+ c.vm.hostname = "<%= config[:vm_hostname] %>"
7
+ <% end %>
8
+ <% if config[:guest] %>
9
+ c.vm.guest = "<%= config[:guest] %>"
10
+ <% end %>
11
+ c.vm.communicator = 'winrm'
12
+
13
+ <% if config[:winrm_username] %>
14
+ c.winrm.username = "<%= config[:winrm_username] %>"
15
+ <% end %>
16
+ <% if config[:winrm_password] %>
17
+ c.winrm.password = "<%= config[:winrm_password] %>"
18
+ <% end %>
19
+ <% if config[:winrm_port] %>
20
+ c.winrm.port = <%= config[:winrm_port] %>
21
+ <% end %>
22
+
23
+ <% Array(config[:network]).each do |opts| %>
24
+ c.vm.network(:<%= opts[0] %>, <%= opts[1..-1].join(", ") %>)
25
+ <% end %>
26
+
27
+ c.vm.synced_folder ".", "/vagrant", disabled: true
28
+ <% config[:synced_folders].each do |source, destination, options| %>
29
+ c.vm.synced_folder "<%= source %>", "<%= destination %>", <%= options %>
30
+ <% end %>
31
+
32
+ c.vm.provider :<%= config[:provider] %> do |p|
33
+ <% config[:customize].each do |key, value| %>
34
+ <% case config[:provider]
35
+ when "virtualbox" %>
36
+ p.customize ["modifyvm", :id, "--<%= key %>", "<%= value %>"]
37
+ <% when "rackspace", "softlayer" %>
38
+ p.<%= key %> = "<%= value%>"
39
+ <% when /^vmware_/ %>
40
+ <% if key == :memory %>
41
+ <% unless config[:customize].include?(:memsize) %>
42
+ p.vmx["memsize"] = "<%= value %>"
43
+ <% end %>
44
+ <% else %>
45
+ p.vmx["<%= key %>"] = "<%= value %>"
46
+ <% end %>
47
+ <% end %>
48
+ <% end %>
49
+ end
50
+
51
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-vagrant_winrm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.dev
5
+ platform: ruby
6
+ authors:
7
+ - Baptiste Courtois
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: test-kitchen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cane
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tailor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: countloc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Kitchen::Driver::VagrantWinRM - A Test Kitchen Driver for using Vagrant-WinRM
112
+ email:
113
+ - b.courtois@criteo.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .cane
119
+ - .gitignore
120
+ - .rspec
121
+ - .tailor
122
+ - CHANGELOG.md
123
+ - Gemfile
124
+ - LICENSE
125
+ - README.md
126
+ - Rakefile
127
+ - kitchen-vagrant_winrm.gemspec
128
+ - lib/kitchen/driver/vagrant_winrm.rb
129
+ - lib/kitchen/driver/vagrant_winrm_version.rb
130
+ - spec/spec_helper.rb
131
+ - templates/Vagrantfile.erb
132
+ homepage: https://gitlab.criteois.lan/ruby-gems/kitchen-vagrant_winrm
133
+ licenses:
134
+ - Apache 2.0
135
+ metadata: {}
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>'
148
+ - !ruby/object:Gem::Version
149
+ version: 1.3.1
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 2.0.14
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: A Test Kitchen Driver using vagrant winrm
156
+ test_files:
157
+ - spec/spec_helper.rb