kitchen-vagrant 1.5.2 → 1.7.2
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/lib/kitchen/driver/helpers.rb +7 -4
- data/lib/kitchen/driver/vagrant.rb +70 -22
- data/lib/kitchen/driver/vagrant_version.rb +1 -2
- data/templates/Vagrantfile.erb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3c72511abbc2ebaecf070000334cfb6007e2ea9d4b7b37510dc37cb615ef6683
|
|
4
|
+
data.tar.gz: cc7d51dd336a7834f4a41cef38ac61a5ee032b04ede79ee0e5bd49c73152f4dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 412f726eac124fed8de34891cef4156d54de487db7a25464f6d6fe95f6076273333c5328bcfab8a1288e262a5bcdebffda329ebdb81ea1efdbebf1035ff22f76
|
|
7
|
+
data.tar.gz: 44f6fac1806fada336fb1cb6ceb2fd36bb416833ec59cc213076f89c2f24e4ed79c92b049275a9d91c11105a79195dba4fabb76005a2cd6bc42c7c1298082bf4
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
|
-
require "mixlib/shellout"
|
|
19
|
-
require "fileutils"
|
|
20
|
-
require "json"
|
|
18
|
+
require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
|
|
19
|
+
require "fileutils" unless defined?(FileUtils)
|
|
20
|
+
require "json" unless defined?(JSON)
|
|
21
21
|
|
|
22
22
|
module Kitchen
|
|
23
23
|
module Driver
|
|
@@ -76,6 +76,7 @@ module Kitchen
|
|
|
76
76
|
sh.run_command
|
|
77
77
|
debug("Local Command END #{Util.duration(sh.execution_time)}")
|
|
78
78
|
raise "Failed: #{sh.stderr}" if sh.error?
|
|
79
|
+
|
|
79
80
|
stdout = sanitize_stdout(sh.stdout)
|
|
80
81
|
JSON.parse(stdout) if stdout.length > 2
|
|
81
82
|
end
|
|
@@ -91,12 +92,13 @@ module Kitchen
|
|
|
91
92
|
default_switch_object["Name"].empty?
|
|
92
93
|
raise "Failed to find a default VM Switch."
|
|
93
94
|
end
|
|
95
|
+
|
|
94
96
|
default_switch_object["Name"]
|
|
95
97
|
end
|
|
96
98
|
|
|
97
99
|
def hyperv_default_switch_ps
|
|
98
100
|
<<-VMSWITCH
|
|
99
|
-
Get-DefaultVMSwitch #{ENV[
|
|
101
|
+
Get-DefaultVMSwitch #{ENV["KITCHEN_HYPERV_SWITCH"]} | ConvertTo-Json
|
|
100
102
|
VMSWITCH
|
|
101
103
|
end
|
|
102
104
|
|
|
@@ -104,6 +106,7 @@ module Kitchen
|
|
|
104
106
|
|
|
105
107
|
def ruby_array_to_ps_array(list)
|
|
106
108
|
return "@()" if list.nil? || list.empty?
|
|
109
|
+
|
|
107
110
|
list.to_s.tr("[]", "()").prepend("@")
|
|
108
111
|
end
|
|
109
112
|
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
1
|
#
|
|
3
2
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
|
4
3
|
#
|
|
@@ -16,13 +15,13 @@
|
|
|
16
15
|
# See the License for the specific language governing permissions and
|
|
17
16
|
# limitations under the License.
|
|
18
17
|
|
|
19
|
-
require "erb"
|
|
20
|
-
require "fileutils"
|
|
18
|
+
require "erb" unless defined?(Erb)
|
|
19
|
+
require "fileutils" unless defined?(FileUtils)
|
|
21
20
|
require "rubygems/version"
|
|
22
21
|
|
|
23
22
|
require "kitchen"
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
require_relative "vagrant_version"
|
|
24
|
+
require_relative "helpers"
|
|
26
25
|
|
|
27
26
|
module Kitchen
|
|
28
27
|
|
|
@@ -40,16 +39,20 @@ module Kitchen
|
|
|
40
39
|
|
|
41
40
|
plugin_version Kitchen::Driver::VAGRANT_VERSION
|
|
42
41
|
|
|
43
|
-
default_config(:box
|
|
42
|
+
default_config(:box, &:default_box)
|
|
44
43
|
required_config :box
|
|
45
44
|
|
|
46
45
|
default_config :box_check_update, nil
|
|
47
46
|
|
|
47
|
+
default_config :box_auto_update, nil
|
|
48
|
+
|
|
49
|
+
default_config :box_auto_prune, nil
|
|
50
|
+
|
|
48
51
|
default_config :box_download_insecure, nil
|
|
49
52
|
|
|
50
53
|
default_config :box_download_ca_cert, nil
|
|
51
54
|
|
|
52
|
-
default_config(:box_url
|
|
55
|
+
default_config(:box_url, &:default_box_url)
|
|
53
56
|
|
|
54
57
|
default_config :box_version, nil
|
|
55
58
|
|
|
@@ -109,6 +112,8 @@ module Kitchen
|
|
|
109
112
|
def create(state)
|
|
110
113
|
create_vagrantfile
|
|
111
114
|
run_pre_create_command
|
|
115
|
+
run_box_auto_update
|
|
116
|
+
run_box_auto_prune
|
|
112
117
|
run_vagrant_up
|
|
113
118
|
update_state(state)
|
|
114
119
|
instance.transport.connection(state).wait_until_ready
|
|
@@ -149,7 +154,8 @@ module Kitchen
|
|
|
149
154
|
if state[:hostname].nil?
|
|
150
155
|
raise UserError, "Vagrant instance not created!"
|
|
151
156
|
end
|
|
152
|
-
|
|
157
|
+
|
|
158
|
+
unless config[:ssh] && config[:ssh][:insert_key] == false
|
|
153
159
|
m = "Disable vagrant ssh key replacement to preserve the default key!"
|
|
154
160
|
warn(m)
|
|
155
161
|
end
|
|
@@ -171,6 +177,8 @@ module Kitchen
|
|
|
171
177
|
def finalize_config!(instance)
|
|
172
178
|
super
|
|
173
179
|
finalize_vm_hostname!
|
|
180
|
+
finalize_box_auto_update!
|
|
181
|
+
finalize_box_auto_prune!
|
|
174
182
|
finalize_pre_create_command!
|
|
175
183
|
finalize_synced_folders!
|
|
176
184
|
finalize_ca_cert!
|
|
@@ -246,8 +254,9 @@ module Kitchen
|
|
|
246
254
|
# shared folders
|
|
247
255
|
# @api private
|
|
248
256
|
def safe_share?(box)
|
|
249
|
-
return false if
|
|
250
|
-
|
|
257
|
+
return false if /(hyperv|libvirt)/.match?(config[:provider])
|
|
258
|
+
|
|
259
|
+
box =~ %r{^bento/(centos|debian|fedora|opensuse|ubuntu|oracle|amazonlinux)-}
|
|
251
260
|
end
|
|
252
261
|
|
|
253
262
|
# Return true if we found the criteria to enable the cache_directory
|
|
@@ -255,6 +264,7 @@ module Kitchen
|
|
|
255
264
|
def enable_cache?
|
|
256
265
|
return false unless config[:cache_directory]
|
|
257
266
|
return true if safe_share?(config[:box])
|
|
267
|
+
|
|
258
268
|
# Otherwise
|
|
259
269
|
false
|
|
260
270
|
end
|
|
@@ -291,10 +301,25 @@ module Kitchen
|
|
|
291
301
|
def finalize_ca_cert!
|
|
292
302
|
unless config[:box_download_ca_cert].nil?
|
|
293
303
|
config[:box_download_ca_cert] = File.expand_path(
|
|
294
|
-
config[:box_download_ca_cert], config[:kitchen_root]
|
|
304
|
+
config[:box_download_ca_cert], config[:kitchen_root]
|
|
305
|
+
)
|
|
295
306
|
end
|
|
296
307
|
end
|
|
297
308
|
|
|
309
|
+
# Create vagrant command to update box to the latest version
|
|
310
|
+
def finalize_box_auto_update!
|
|
311
|
+
return if config[:box_auto_update].nil?
|
|
312
|
+
|
|
313
|
+
config[:box_auto_update] = "vagrant box update #{"--insecure " if config[:box_download_insecure]}--box #{config[:box]}"
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
# Create vagrant command to remove older versions of the box
|
|
317
|
+
def finalize_box_auto_prune!
|
|
318
|
+
return if config[:box_auto_prune].nil?
|
|
319
|
+
|
|
320
|
+
config[:box_auto_prune] = "vagrant box prune --keep-active-boxes --name #{config[:box]}"
|
|
321
|
+
end
|
|
322
|
+
|
|
298
323
|
# Replaces any `{{vagrant_root}}` tokens in the pre create command.
|
|
299
324
|
#
|
|
300
325
|
# @api private
|
|
@@ -344,8 +369,8 @@ module Kitchen
|
|
|
344
369
|
def finalize_vm_hostname!
|
|
345
370
|
string = config[:vm_hostname]
|
|
346
371
|
|
|
347
|
-
if windows_os? && string.is_a?(String) && string.size
|
|
348
|
-
config[:vm_hostname] = "#{string[0...
|
|
372
|
+
if windows_os? && string.is_a?(String) && string.size > 15
|
|
373
|
+
config[:vm_hostname] = "#{string[0...12]}-#{string[-1]}"
|
|
349
374
|
end
|
|
350
375
|
end
|
|
351
376
|
|
|
@@ -382,10 +407,11 @@ module Kitchen
|
|
|
382
407
|
# @api private
|
|
383
408
|
def render_template
|
|
384
409
|
template = File.expand_path(
|
|
385
|
-
config[:vagrantfile_erb], config[:kitchen_root]
|
|
410
|
+
config[:vagrantfile_erb], config[:kitchen_root]
|
|
411
|
+
)
|
|
386
412
|
|
|
387
413
|
if File.exist?(template)
|
|
388
|
-
ERB.new(IO.read(template)).result(binding).gsub(
|
|
414
|
+
ERB.new(IO.read(template)).result(binding).gsub(/^\s*$\n/, "")
|
|
389
415
|
else
|
|
390
416
|
raise ActionFailed, "Could not find Vagrantfile template #{template}"
|
|
391
417
|
end
|
|
@@ -432,8 +458,8 @@ module Kitchen
|
|
|
432
458
|
env = merged[:environment]
|
|
433
459
|
%w{BUNDLE_BIN_PATH BUNDLE_GEMFILE GEM_HOME GEM_PATH GEM_ROOT RUBYLIB
|
|
434
460
|
RUBYOPT _ORIGINAL_GEM_PATH}.each do |var|
|
|
435
|
-
|
|
436
|
-
|
|
461
|
+
env[var] = nil
|
|
462
|
+
end
|
|
437
463
|
|
|
438
464
|
# Altering the path seems to break vagrant. When the :environment
|
|
439
465
|
# is passed to a windows process with a PATH, Vagrant's batch installer
|
|
@@ -456,6 +482,26 @@ module Kitchen
|
|
|
456
482
|
end
|
|
457
483
|
# rubocop:enable Metrics/CyclomaticComplexity
|
|
458
484
|
|
|
485
|
+
# Tell vagrant to update vagrant box to latest version
|
|
486
|
+
def run_box_auto_update
|
|
487
|
+
if config[:box_auto_update]
|
|
488
|
+
begin
|
|
489
|
+
run(config[:box_auto_update])
|
|
490
|
+
rescue Kitchen::ShellOut::ShellCommandFailed => e
|
|
491
|
+
# If the box has never been downloaded, the update command will fail with this message.
|
|
492
|
+
# Just ignore it and move on. Re-raise all other errors.
|
|
493
|
+
raise e unless e.message.match?(/The box '.*' does not exist/m)
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# Tell vagrant to remove older vagrant boxes
|
|
499
|
+
def run_box_auto_prune
|
|
500
|
+
if config[:box_auto_prune]
|
|
501
|
+
run(config[:box_auto_prune])
|
|
502
|
+
end
|
|
503
|
+
end
|
|
504
|
+
|
|
459
505
|
# Runs a local command before `vagrant up` has been called.
|
|
460
506
|
#
|
|
461
507
|
# @api private
|
|
@@ -529,9 +575,9 @@ module Kitchen
|
|
|
529
575
|
def vagrant_config(type)
|
|
530
576
|
lines = run_silently("#{config[:vagrant_binary]} #{type}-config")
|
|
531
577
|
.split("\n").map do |line|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
578
|
+
tokens = line.strip.partition(" ")
|
|
579
|
+
[tokens.first, tokens.last.delete('"')]
|
|
580
|
+
end
|
|
535
581
|
Hash[lines]
|
|
536
582
|
end
|
|
537
583
|
|
|
@@ -540,7 +586,8 @@ module Kitchen
|
|
|
540
586
|
# @api private
|
|
541
587
|
def vagrant_version
|
|
542
588
|
self.class.vagrant_version ||= run_silently(
|
|
543
|
-
"#{config[:vagrant_binary]} --version", cwd: Dir.pwd
|
|
589
|
+
"#{config[:vagrant_binary]} --version", cwd: Dir.pwd
|
|
590
|
+
)
|
|
544
591
|
.chomp.split(" ").last
|
|
545
592
|
rescue Errno::ENOENT
|
|
546
593
|
raise UserError, "Vagrant #{MIN_VER} or higher is not installed." \
|
|
@@ -583,7 +630,8 @@ module Kitchen
|
|
|
583
630
|
return true if self.class.winrm_plugin_passed
|
|
584
631
|
|
|
585
632
|
self.class.winrm_plugin_passed = run_silently(
|
|
586
|
-
"#{config[:vagrant_binary]} plugin list", cwd: Dir.pwd
|
|
633
|
+
"#{config[:vagrant_binary]} plugin list", cwd: Dir.pwd
|
|
634
|
+
)
|
|
587
635
|
.split("\n").find { |line| line =~ /vagrant-winrm\s+/ }
|
|
588
636
|
end
|
|
589
637
|
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
1
|
#
|
|
3
2
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
|
4
3
|
#
|
|
@@ -21,6 +20,6 @@ module Kitchen
|
|
|
21
20
|
module Driver
|
|
22
21
|
|
|
23
22
|
# Version string for Vagrant Kitchen driver
|
|
24
|
-
VAGRANT_VERSION = "1.
|
|
23
|
+
VAGRANT_VERSION = "1.7.2".freeze
|
|
25
24
|
end
|
|
26
25
|
end
|
data/templates/Vagrantfile.erb
CHANGED
|
@@ -108,7 +108,7 @@ Vagrant.configure("2") do |c|
|
|
|
108
108
|
p.linked_clone = <%= config[:linked_clone] %>
|
|
109
109
|
<% end
|
|
110
110
|
when "hyperv" %>
|
|
111
|
-
p.vmname = "kitchen
|
|
111
|
+
p.vmname = "<%="kitchen-#{File.basename(config[:kitchen_root])}-#{instance.name}-#{SecureRandom.uuid}"[0..99].chomp('-') %>"
|
|
112
112
|
<% if config[:linked_clone] == true || config[:linked_clone] == false %>
|
|
113
113
|
p.linked_clone = <%= config[:linked_clone] %>
|
|
114
114
|
<% 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: 1.
|
|
4
|
+
version: 1.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fletcher Nichol
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
@@ -117,7 +117,7 @@ homepage: https://github.com/test-kitchen/kitchen-vagrant/
|
|
|
117
117
|
licenses:
|
|
118
118
|
- Apache-2.0
|
|
119
119
|
metadata: {}
|
|
120
|
-
post_install_message:
|
|
120
|
+
post_install_message:
|
|
121
121
|
rdoc_options: []
|
|
122
122
|
require_paths:
|
|
123
123
|
- lib
|
|
@@ -125,15 +125,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
125
125
|
requirements:
|
|
126
126
|
- - ">="
|
|
127
127
|
- !ruby/object:Gem::Version
|
|
128
|
-
version: '
|
|
128
|
+
version: '2.3'
|
|
129
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
requirements:
|
|
131
131
|
- - ">="
|
|
132
132
|
- !ruby/object:Gem::Version
|
|
133
133
|
version: '0'
|
|
134
134
|
requirements: []
|
|
135
|
-
rubygems_version: 3.
|
|
136
|
-
signing_key:
|
|
135
|
+
rubygems_version: 3.1.4
|
|
136
|
+
signing_key:
|
|
137
137
|
specification_version: 4
|
|
138
138
|
summary: Kitchen::Driver::Vagrant - A Vagrant Driver for Test Kitchen.
|
|
139
139
|
test_files: []
|