test-kitchen 3.9.0 → 4.0.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/Gemfile +5 -6
- data/lib/kitchen/collection.rb +1 -1
- data/lib/kitchen/configurable.rb +4 -4
- data/lib/kitchen/data_munger.rb +7 -9
- data/lib/kitchen/driver/exec.rb +2 -2
- data/lib/kitchen/driver/proxy.rb +11 -6
- data/lib/kitchen/generator/init.rb +1 -1
- data/lib/kitchen/instance.rb +6 -102
- data/lib/kitchen/lazy_hash.rb +1 -1
- data/lib/kitchen/loader/yaml.rb +1 -1
- data/lib/kitchen/logger.rb +1 -1
- data/lib/kitchen/metadata_chopper.rb +1 -1
- data/lib/kitchen/provisioner/base.rb +23 -55
- data/lib/kitchen/provisioner.rb +1 -2
- data/lib/kitchen/transport/winrm.rb +8 -8
- data/lib/kitchen/util.rb +1 -1
- data/lib/kitchen/version.rb +1 -1
- data/lib/kitchen.rb +0 -2
- data/lib/vendor/hash_recursive_merge.rb +2 -2
- data/templates/driver/driver.rb.erb +1 -1
- data/test-kitchen.gemspec +4 -6
- metadata +26 -39
- data/lib/kitchen/driver/ssh_base.rb +0 -346
- data/lib/kitchen/provisioner/chef/berkshelf.rb +0 -116
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +0 -352
- data/lib/kitchen/provisioner/chef/policyfile.rb +0 -173
- data/lib/kitchen/provisioner/chef_apply.rb +0 -121
- data/lib/kitchen/provisioner/chef_base.rb +0 -723
- data/lib/kitchen/provisioner/chef_infra.rb +0 -167
- data/lib/kitchen/provisioner/chef_solo.rb +0 -82
- data/lib/kitchen/provisioner/chef_target.rb +0 -130
- data/lib/kitchen/provisioner/chef_zero.rb +0 -12
- data/lib/kitchen/ssh.rb +0 -296
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80afb157c2779c990f0194d9711cf3a35d949a1916515fbaf722056306314a6d
|
|
4
|
+
data.tar.gz: d06ecf45e9c7c2288a772c2202505f2d5cdd722b357fb7fa9cf0433e06eec725
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 323e94d69dfadaa75a6214b504f47c7114227ee5ce98ae5dcdd64f9961945caf8212d9ef015a778ace055b6b63eb6fa5917dc072aa7f977a9da2a734ccfa66cd
|
|
7
|
+
data.tar.gz: fcf0647d42a9482a9da0656ed68b90b6cc17eb8a14cd999a6316b3be4a2cc02796a3ef4a0ccf7ee8938a0cd92bb8910efb7243342f6677f63b624f8b9756cb64
|
data/Gemfile
CHANGED
|
@@ -9,18 +9,17 @@ group :test do
|
|
|
9
9
|
gem "countloc", "~> 0.4"
|
|
10
10
|
gem "cucumber", ">= 9.2", "< 11"
|
|
11
11
|
gem "fakefs", "~> 3.0"
|
|
12
|
-
gem "maruku", "~> 0.
|
|
13
|
-
gem "minitest", "~>
|
|
14
|
-
gem "mocha", "~>
|
|
12
|
+
gem "maruku", "~> 0.7"
|
|
13
|
+
gem "minitest", "~> 6.0", "< 6.1"
|
|
14
|
+
gem "mocha", "~> 3.0"
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
group :integration do
|
|
18
18
|
gem "chef-cli"
|
|
19
19
|
gem "kitchen-dokken"
|
|
20
|
-
gem "kitchen-inspec"
|
|
21
20
|
gem "kitchen-vagrant"
|
|
22
|
-
gem "inspec"
|
|
23
|
-
gem "
|
|
21
|
+
gem "kitchen-inspec"
|
|
22
|
+
gem "kitchen-omnibus-chef", ">= 1.0"
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
group :linting do
|
data/lib/kitchen/collection.rb
CHANGED
data/lib/kitchen/configurable.rb
CHANGED
|
@@ -180,7 +180,7 @@ module Kitchen
|
|
|
180
180
|
|
|
181
181
|
private
|
|
182
182
|
|
|
183
|
-
# @return [
|
|
183
|
+
# @return [LazyHash] a configuration hash
|
|
184
184
|
# @api private
|
|
185
185
|
attr_reader :config
|
|
186
186
|
|
|
@@ -472,7 +472,7 @@ module Kitchen
|
|
|
472
472
|
# easier to debug and diagnose.
|
|
473
473
|
#
|
|
474
474
|
# Note that the file path expansion is only intended for paths on the
|
|
475
|
-
# local workstation
|
|
475
|
+
# local workstation invoking the Test Kitchen code.
|
|
476
476
|
#
|
|
477
477
|
# @example the default usage
|
|
478
478
|
#
|
|
@@ -598,8 +598,8 @@ module Kitchen
|
|
|
598
598
|
end
|
|
599
599
|
end
|
|
600
600
|
|
|
601
|
-
# @return [Hash] a hash of attribute keys and
|
|
602
|
-
# which has been merged with any superclass
|
|
601
|
+
# @return [Hash] a hash of attribute keys and validation callable blocks
|
|
602
|
+
# which has been merged with any superclass validations
|
|
603
603
|
# @api private
|
|
604
604
|
def validations
|
|
605
605
|
@validations ||= {}.merge(super_validations)
|
data/lib/kitchen/data_munger.rb
CHANGED
|
@@ -231,7 +231,7 @@ module Kitchen
|
|
|
231
231
|
# platforms, or the like, just a vanilla hash.
|
|
232
232
|
#
|
|
233
233
|
# @param root [Hash] a hash to use as the root of the conversion
|
|
234
|
-
# @deprecated The following configuration
|
|
234
|
+
# @deprecated The following configuration hashes should no longer be
|
|
235
235
|
# created in a Test Kitchen hash: `:busser`. Use a `:verifier` hash
|
|
236
236
|
# block in their place.
|
|
237
237
|
# @api private
|
|
@@ -378,7 +378,7 @@ module Kitchen
|
|
|
378
378
|
#
|
|
379
379
|
# @param root [Hash] a hash to use as the root of the conversion
|
|
380
380
|
# @deprecated The following configuration hashes should no longer be
|
|
381
|
-
# created in a Test
|
|
381
|
+
# created in a Test Kitchen hash: [`:driver_plugin`, `:driver_config`].
|
|
382
382
|
# Use a `:driver` hash block in their place.
|
|
383
383
|
# @api private
|
|
384
384
|
def convert_legacy_driver_format_at!(root)
|
|
@@ -396,9 +396,7 @@ module Kitchen
|
|
|
396
396
|
end
|
|
397
397
|
|
|
398
398
|
# Copies `:http_proxy` and `:https_proxy` values in a driver hash into the
|
|
399
|
-
# provisioner and verifier hashes.
|
|
400
|
-
# Drivers (those inheriting directly from `SSHBase`), the original
|
|
401
|
-
# values are maintained in the driver hash.
|
|
399
|
+
# provisioner and verifier hashes.
|
|
402
400
|
#
|
|
403
401
|
# This method converts the following:
|
|
404
402
|
#
|
|
@@ -589,9 +587,9 @@ module Kitchen
|
|
|
589
587
|
end
|
|
590
588
|
|
|
591
589
|
# Destructively moves a `:require_chef_omnibus` key/value pair from a
|
|
592
|
-
# `:driver` hash block to a `:provisioner` hash block in the first
|
|
590
|
+
# `:driver` hash block to a `:provisioner` hash block in the first level
|
|
593
591
|
# depth of a hash. This method has no knowledge of suites, platforms, or
|
|
594
|
-
# the like, just a vanilla
|
|
592
|
+
# the like, just a vanilla hash.
|
|
595
593
|
#
|
|
596
594
|
# @param root [Hash] a hash to use as the root of the conversion
|
|
597
595
|
# @deprecated The `:require_chef_omnibus` key/value pair should no longer
|
|
@@ -753,9 +751,9 @@ module Kitchen
|
|
|
753
751
|
# takes an array value and transforms it into a hash with a bucket name
|
|
754
752
|
# containing the original Array. This way semantic Hash merging will do
|
|
755
753
|
# its thing and another process can collapse the hash into a flat array
|
|
756
|
-
# afterwards, given a strategy (like use the array
|
|
754
|
+
# afterwards, given a strategy (like use the array segment from one
|
|
757
755
|
# bucket first, then another one second). To anyone who made it this far,
|
|
758
|
-
# Fletcher
|
|
756
|
+
# Fletcher apologizes.
|
|
759
757
|
#
|
|
760
758
|
# @param root [Hash] a hash to use as the root of the conversion
|
|
761
759
|
# @param key [Symbol] a key in the root hash that, if exists, has its
|
data/lib/kitchen/driver/exec.rb
CHANGED
|
@@ -53,8 +53,8 @@ module Kitchen
|
|
|
53
53
|
|
|
54
54
|
private
|
|
55
55
|
|
|
56
|
-
# Resets the non-Kitchen managed instance
|
|
57
|
-
#
|
|
56
|
+
# Resets the non-Kitchen managed instance by issuing a command
|
|
57
|
+
# locally.
|
|
58
58
|
#
|
|
59
59
|
# @param state [Hash] the state hash
|
|
60
60
|
# @api private
|
data/lib/kitchen/driver/proxy.rb
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
# limitations under the License.
|
|
12
12
|
#
|
|
13
13
|
|
|
14
|
-
require_relative "
|
|
14
|
+
require_relative "base"
|
|
15
15
|
require_relative "../version"
|
|
16
16
|
|
|
17
17
|
module Kitchen
|
|
@@ -23,7 +23,7 @@ module Kitchen
|
|
|
23
23
|
# the driver was created.
|
|
24
24
|
#
|
|
25
25
|
# @author Seth Chisamore <schisamo@opscode.com>
|
|
26
|
-
class Proxy < Kitchen::Driver::
|
|
26
|
+
class Proxy < Kitchen::Driver::Base
|
|
27
27
|
plugin_version Kitchen::VERSION
|
|
28
28
|
|
|
29
29
|
required_config :host
|
|
@@ -33,8 +33,11 @@ module Kitchen
|
|
|
33
33
|
|
|
34
34
|
# (see Base#create)
|
|
35
35
|
def create(state)
|
|
36
|
-
|
|
36
|
+
super
|
|
37
37
|
state[:hostname] = config[:host]
|
|
38
|
+
state[:port] = config[:port] if config[:port]
|
|
39
|
+
state[:username] = config[:username] if config[:username]
|
|
40
|
+
state[:password] = config[:password] if config[:password]
|
|
38
41
|
reset_instance(state)
|
|
39
42
|
end
|
|
40
43
|
|
|
@@ -48,15 +51,17 @@ module Kitchen
|
|
|
48
51
|
|
|
49
52
|
private
|
|
50
53
|
|
|
51
|
-
# Resets the non-Kitchen managed instance
|
|
52
|
-
# over
|
|
54
|
+
# Resets the non-Kitchen managed instance by issuing a command
|
|
55
|
+
# over the transport.
|
|
53
56
|
#
|
|
54
57
|
# @param state [Hash] the state hash
|
|
55
58
|
# @api private
|
|
56
59
|
def reset_instance(state)
|
|
57
60
|
if (cmd = config[:reset_command])
|
|
58
61
|
info("Resetting instance state with command: #{cmd}")
|
|
59
|
-
|
|
62
|
+
instance.transport.connection(state) do |conn|
|
|
63
|
+
conn.execute(cmd)
|
|
64
|
+
end
|
|
60
65
|
end
|
|
61
66
|
end
|
|
62
67
|
end
|
data/lib/kitchen/instance.rb
CHANGED
|
@@ -210,11 +210,7 @@ module Kitchen
|
|
|
210
210
|
raise UserError, "Instance #{to_str} has not yet been created"
|
|
211
211
|
end
|
|
212
212
|
|
|
213
|
-
lc =
|
|
214
|
-
legacy_ssh_base_login(state)
|
|
215
|
-
else
|
|
216
|
-
transport.connection(state).login_command
|
|
217
|
-
end
|
|
213
|
+
lc = transport.connection(state).login_command
|
|
218
214
|
|
|
219
215
|
debug(%{Login command: #{lc.command} #{lc.arguments.join(" ")} } \
|
|
220
216
|
"(Options: #{lc.options})")
|
|
@@ -412,12 +408,8 @@ module Kitchen
|
|
|
412
408
|
def converge_action
|
|
413
409
|
banner "Converging #{to_str}..."
|
|
414
410
|
elapsed = action(:converge) do |state|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
else
|
|
418
|
-
provisioner.check_license
|
|
419
|
-
provisioner.call(state)
|
|
420
|
-
end
|
|
411
|
+
provisioner.check_license
|
|
412
|
+
provisioner.call(state)
|
|
421
413
|
end
|
|
422
414
|
info("Finished converging #{to_str} #{Util.duration(elapsed.real)}.")
|
|
423
415
|
self
|
|
@@ -431,26 +423,11 @@ module Kitchen
|
|
|
431
423
|
def setup_action
|
|
432
424
|
banner "Setting up #{to_str}..."
|
|
433
425
|
elapsed = action(:setup) do |state|
|
|
434
|
-
legacy_ssh_base_setup(state) if legacy_ssh_base_driver?
|
|
435
426
|
end
|
|
436
427
|
info("Finished setting up #{to_str} #{Util.duration(elapsed.real)}.")
|
|
437
428
|
self
|
|
438
429
|
end
|
|
439
430
|
|
|
440
|
-
# returns true, if the verifier is busser
|
|
441
|
-
def verifier_busser?(verifier)
|
|
442
|
-
!defined?(Kitchen::Verifier::Busser).nil? && verifier.is_a?(Kitchen::Verifier::Busser)
|
|
443
|
-
end
|
|
444
|
-
|
|
445
|
-
# returns true, if the verifier is dummy
|
|
446
|
-
def verifier_dummy?(verifier)
|
|
447
|
-
!defined?(Kitchen::Verifier::Dummy).nil? && verifier.is_a?(Kitchen::Verifier::Dummy)
|
|
448
|
-
end
|
|
449
|
-
|
|
450
|
-
def use_legacy_ssh_verifier?(verifier)
|
|
451
|
-
verifier_busser?(verifier) || verifier_dummy?(verifier)
|
|
452
|
-
end
|
|
453
|
-
|
|
454
431
|
# Perform the verify action.
|
|
455
432
|
#
|
|
456
433
|
# @see Driver::Base#verify
|
|
@@ -459,15 +436,7 @@ module Kitchen
|
|
|
459
436
|
def verify_action
|
|
460
437
|
banner "Verifying #{to_str}..."
|
|
461
438
|
elapsed = action(:verify) do |state|
|
|
462
|
-
|
|
463
|
-
if legacy_ssh_base_driver? && use_legacy_ssh_verifier?(verifier)
|
|
464
|
-
legacy_ssh_base_verify(state)
|
|
465
|
-
elsif legacy_ssh_base_driver?
|
|
466
|
-
# read ssh options from legacy driver
|
|
467
|
-
verifier.call(driver.legacy_state(state))
|
|
468
|
-
else
|
|
469
|
-
verifier.call(state)
|
|
470
|
-
end
|
|
439
|
+
verifier.call(state)
|
|
471
440
|
end
|
|
472
441
|
info("Finished verifying #{to_str} #{Util.duration(elapsed.real)}.")
|
|
473
442
|
self
|
|
@@ -487,7 +456,7 @@ module Kitchen
|
|
|
487
456
|
# @param verb [Symbol] the action to be performed
|
|
488
457
|
# @param output_verb [String] a verb representing the action, suitable for
|
|
489
458
|
# use in output logging
|
|
490
|
-
# @yield perform optional work just after action has
|
|
459
|
+
# @yield perform optional work just after action has completed
|
|
491
460
|
# @return [self] this instance, used to chain actions
|
|
492
461
|
# @api private
|
|
493
462
|
def perform_action(verb, output_verb)
|
|
@@ -616,71 +585,6 @@ module Kitchen
|
|
|
616
585
|
"#{what.capitalize} failed on instance #{to_str}."
|
|
617
586
|
end
|
|
618
587
|
|
|
619
|
-
# Invokes `Driver#converge` on a legacy Driver, which inherits from
|
|
620
|
-
# `Kitchen::Driver::SSHBase`.
|
|
621
|
-
#
|
|
622
|
-
# @param state [Hash] mutable instance state
|
|
623
|
-
# @deprecated When legacy Driver::SSHBase support is removed, the
|
|
624
|
-
# `#converge` method will no longer be called on the Driver.
|
|
625
|
-
# @api private
|
|
626
|
-
def legacy_ssh_base_converge(state)
|
|
627
|
-
warn("Running legacy converge for '#{driver.name}' Driver")
|
|
628
|
-
# TODO: Document upgrade path and provide link
|
|
629
|
-
# warn("Driver authors: please read http://example.com for more details.")
|
|
630
|
-
driver.converge(state)
|
|
631
|
-
end
|
|
632
|
-
|
|
633
|
-
# @return [TrueClass,FalseClass] whether or not the Driver inherits from
|
|
634
|
-
# `Kitchen::Driver::SSHBase`
|
|
635
|
-
# @deprecated When legacy Driver::SSHBase support is removed, the
|
|
636
|
-
# `#converge` method will no longer be called on the Driver.
|
|
637
|
-
# @api private
|
|
638
|
-
def legacy_ssh_base_driver?
|
|
639
|
-
driver.class < Kitchen::Driver::SSHBase
|
|
640
|
-
end
|
|
641
|
-
|
|
642
|
-
# Invokes `Driver#login_command` on a legacy Driver, which inherits from
|
|
643
|
-
# `Kitchen::Driver::SSHBase`.
|
|
644
|
-
#
|
|
645
|
-
# @param state [Hash] mutable instance state
|
|
646
|
-
# @deprecated When legacy Driver::SSHBase support is removed, the
|
|
647
|
-
# `#login_command` method will no longer be called on the Driver.
|
|
648
|
-
# @api private
|
|
649
|
-
def legacy_ssh_base_login(state)
|
|
650
|
-
warn("Running legacy login for '#{driver.name}' Driver")
|
|
651
|
-
# TODO: Document upgrade path and provide link
|
|
652
|
-
# warn("Driver authors: please read http://example.com for more details.")
|
|
653
|
-
driver.login_command(state)
|
|
654
|
-
end
|
|
655
|
-
|
|
656
|
-
# Invokes `Driver#setup` on a legacy Driver, which inherits from
|
|
657
|
-
# `Kitchen::Driver::SSHBase`.
|
|
658
|
-
#
|
|
659
|
-
# @param state [Hash] mutable instance state
|
|
660
|
-
# @deprecated When legacy Driver::SSHBase support is removed, the
|
|
661
|
-
# `#setup` method will no longer be called on the Driver.
|
|
662
|
-
# @api private
|
|
663
|
-
def legacy_ssh_base_setup(state)
|
|
664
|
-
warn("Running legacy setup for '#{driver.name}' Driver")
|
|
665
|
-
# TODO: Document upgrade path and provide link
|
|
666
|
-
# warn("Driver authors: please read http://example.com for more details.")
|
|
667
|
-
driver.setup(state)
|
|
668
|
-
end
|
|
669
|
-
|
|
670
|
-
# Invokes `Driver#verify` on a legacy Driver, which inherits from
|
|
671
|
-
# `Kitchen::Driver::SSHBase`.
|
|
672
|
-
#
|
|
673
|
-
# @param state [Hash] mutable instance state
|
|
674
|
-
# @deprecated When legacy Driver::SSHBase support is removed, the
|
|
675
|
-
# `#verify` method will no longer be called on the Driver.
|
|
676
|
-
# @api private
|
|
677
|
-
def legacy_ssh_base_verify(state)
|
|
678
|
-
warn("Running legacy verify for '#{driver.name}' Driver")
|
|
679
|
-
# TODO: Document upgrade path and provide link
|
|
680
|
-
# warn("Driver authors: please read http://example.com for more details.")
|
|
681
|
-
driver.verify(state)
|
|
682
|
-
end
|
|
683
|
-
|
|
684
588
|
# The simplest finite state machine pseudo-implementation needed to manage
|
|
685
589
|
# an Instance.
|
|
686
590
|
#
|
|
@@ -688,7 +592,7 @@ module Kitchen
|
|
|
688
592
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
|
689
593
|
class FSM
|
|
690
594
|
# Returns an Array of all transitions to bring an Instance from its last
|
|
691
|
-
# reported
|
|
595
|
+
# reported transitioned state into the desired transitioned state.
|
|
692
596
|
#
|
|
693
597
|
# @param last [String,Symbol,nil] the last known transitioned state of
|
|
694
598
|
# the Instance, defaulting to `nil` (for unknown or no history)
|
data/lib/kitchen/lazy_hash.rb
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
require "delegate"
|
|
19
19
|
|
|
20
20
|
module Kitchen
|
|
21
|
-
# A
|
|
21
|
+
# A modified Hash object that may contain callables as a value which must be
|
|
22
22
|
# executed in the context of another object. This allows for delayed
|
|
23
23
|
# evaluation of a hash value while still looking and largely feeling like a
|
|
24
24
|
# normal Ruby Hash.
|
data/lib/kitchen/loader/yaml.rb
CHANGED
data/lib/kitchen/logger.rb
CHANGED
|
@@ -285,7 +285,7 @@ module Kitchen
|
|
|
285
285
|
# Construct a new standard out logger.
|
|
286
286
|
#
|
|
287
287
|
# @param stdout [IO] the IO object that represents stdout (or similar)
|
|
288
|
-
# @param color [Symbol] color to use when
|
|
288
|
+
# @param color [Symbol] color to use when outputting messages
|
|
289
289
|
# @param colorize [Boolean] whether to enable color
|
|
290
290
|
# @return [StdoutLogger] a new logger
|
|
291
291
|
# @api private
|
|
@@ -33,7 +33,7 @@ module Kitchen
|
|
|
33
33
|
[mc[:name], mc[:version]]
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
# Creates a new instances and loads in the contents of the
|
|
36
|
+
# Creates a new instances and loads in the contents of the metadata.rb
|
|
37
37
|
# file. If you value your life, you may want to avoid reading the
|
|
38
38
|
# implementation.
|
|
39
39
|
#
|
|
@@ -70,7 +70,6 @@ module Kitchen
|
|
|
70
70
|
# rubocop:disable Metrics/AbcSize
|
|
71
71
|
def call(state)
|
|
72
72
|
create_sandbox
|
|
73
|
-
prepare_install_script
|
|
74
73
|
|
|
75
74
|
instance.transport.connection(state) do |conn|
|
|
76
75
|
config[:uploads].to_h.each do |locals, remote|
|
|
@@ -78,21 +77,24 @@ module Kitchen
|
|
|
78
77
|
conn.upload(locals.to_s, remote)
|
|
79
78
|
end
|
|
80
79
|
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
# Check if we need to upload script (for Windows SSH or other scenarios requiring script upload)
|
|
81
|
+
transport_config = instance.transport.instance_variable_get(:@config)
|
|
82
|
+
debug("Windows OS: #{windows_os?} and Transport config: #{transport_config.inspect}")
|
|
83
|
+
if windows_os? && transport_config && transport_config[:name] == "ssh"
|
|
84
|
+
prepare_install_script
|
|
85
|
+
# Run the init command to create the kitchen tmp directory
|
|
86
|
+
conn.execute(encode_for_powershell(init_command))
|
|
87
|
+
remote_script_path = remote_path_join(resolve_remote_path(config[:root_path]), "install_script.ps1")
|
|
88
88
|
if install_script_path
|
|
89
89
|
debug("Uploading install script to #{remote_script_path}")
|
|
90
90
|
conn.upload(install_script_path, remote_script_path)
|
|
91
|
-
|
|
92
|
-
conn.execute(make_executable_command(remote_script_path))
|
|
93
|
-
# Execute the uploaded script
|
|
91
|
+
debug("Executing install script with #{run_script_command(remote_script_path)}")
|
|
94
92
|
conn.execute(run_script_command(remote_script_path))
|
|
95
93
|
end
|
|
94
|
+
else
|
|
95
|
+
# For all other scenarios, execute install command directly
|
|
96
|
+
debug("Executing install command: #{install_command}")
|
|
97
|
+
conn.execute(install_command)
|
|
96
98
|
end
|
|
97
99
|
|
|
98
100
|
# The install script will remove the kitchen tmp directory, hence creating it again.
|
|
@@ -100,7 +102,9 @@ module Kitchen
|
|
|
100
102
|
info("Transferring files to #{instance.to_str}")
|
|
101
103
|
conn.upload(sandbox_dirs, resolve_remote_path(config[:root_path]))
|
|
102
104
|
debug("Transfer complete")
|
|
105
|
+
debug("Executing prepare command: #{prepare_command}")
|
|
103
106
|
conn.execute(prepare_command)
|
|
107
|
+
debug("Executing run command: #{run_command}")
|
|
104
108
|
conn.execute_with_retry(
|
|
105
109
|
encode_for_powershell(run_command),
|
|
106
110
|
config[:retry_on_exit_code],
|
|
@@ -243,24 +247,6 @@ module Kitchen
|
|
|
243
247
|
|
|
244
248
|
private
|
|
245
249
|
|
|
246
|
-
# Builds a complete command given a variables String preamble and a file
|
|
247
|
-
# containing shell code.
|
|
248
|
-
#
|
|
249
|
-
# @param vars [String] shell variables, as a String
|
|
250
|
-
# @param file [String] file basename (without extension) containing
|
|
251
|
-
# shell code
|
|
252
|
-
# @return [String] command
|
|
253
|
-
# @api private
|
|
254
|
-
def shell_code_from_file(vars, file)
|
|
255
|
-
src_file = File.join(
|
|
256
|
-
File.dirname(__FILE__),
|
|
257
|
-
%w{.. .. .. support},
|
|
258
|
-
file + (powershell_shell? ? ".ps1" : ".sh")
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
wrap_shell_code([vars, "", File.read(src_file)].join("\n"))
|
|
262
|
-
end
|
|
263
|
-
|
|
264
250
|
# Conditionally prefixes a command with a sudo command.
|
|
265
251
|
#
|
|
266
252
|
# @param command [String] command to be prefixed
|
|
@@ -292,8 +278,8 @@ module Kitchen
|
|
|
292
278
|
end
|
|
293
279
|
|
|
294
280
|
def encode_for_powershell(script)
|
|
295
|
-
return script unless windows_os?
|
|
296
281
|
return script if script.nil? || script.empty?
|
|
282
|
+
return script unless windows_os? && instance.transport.instance_variable_get(:@config)[:name] == "ssh"
|
|
297
283
|
|
|
298
284
|
utf16le = script.encode(Encoding::UTF_16LE)
|
|
299
285
|
encoded = [utf16le].pack("m0")
|
|
@@ -306,18 +292,16 @@ module Kitchen
|
|
|
306
292
|
#
|
|
307
293
|
# @api private
|
|
308
294
|
def prepare_install_script
|
|
295
|
+
return unless windows_os?
|
|
296
|
+
|
|
309
297
|
command = install_command
|
|
310
298
|
return if command.nil? || command.empty?
|
|
311
299
|
|
|
312
300
|
info("Preparing install script")
|
|
313
|
-
|
|
314
|
-
@install_script_path = File.join(sandbox_path, script_filename)
|
|
301
|
+
@install_script_path = File.join(sandbox_path, "install_script.ps1")
|
|
315
302
|
|
|
316
303
|
debug("Creating install script at #{@install_script_path}")
|
|
317
304
|
File.open(@install_script_path, "wb") do |file|
|
|
318
|
-
unless windows_os?
|
|
319
|
-
file.write("#!/bin/sh\n")
|
|
320
|
-
end
|
|
321
305
|
file.write(command)
|
|
322
306
|
end
|
|
323
307
|
|
|
@@ -329,31 +313,15 @@ module Kitchen
|
|
|
329
313
|
@install_script_path
|
|
330
314
|
end
|
|
331
315
|
|
|
332
|
-
# Returns a command to make a script executable on the remote host.
|
|
333
|
-
#
|
|
334
|
-
# @param script_path [String] path to the script on the remote host
|
|
335
|
-
# @return [String] command to make the script executable
|
|
336
|
-
# @api private
|
|
337
|
-
def make_executable_command(script_path)
|
|
338
|
-
debug "echo Making script executable"
|
|
339
|
-
return if windows_os?
|
|
340
|
-
|
|
341
|
-
prefix_command(wrap_shell_code(sudo("chmod +x #{script_path}")))
|
|
342
|
-
end
|
|
343
|
-
|
|
344
316
|
# Returns a command to execute a script on the remote host.
|
|
345
317
|
#
|
|
346
318
|
# @param script_path [String] path to the script on the remote host
|
|
347
319
|
# @return [String] command to execute the script
|
|
348
320
|
# @api private
|
|
349
321
|
def run_script_command(script_path)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
"powershell -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File #{script_path}"
|
|
354
|
-
else
|
|
355
|
-
prefix_command(wrap_shell_code(sudo(script_path)))
|
|
356
|
-
end
|
|
322
|
+
# Use parameters to suppress PowerShell formatting and control characters
|
|
323
|
+
# that can interfere with console output over SSH
|
|
324
|
+
"powershell -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File #{script_path}"
|
|
357
325
|
end
|
|
358
326
|
|
|
359
327
|
# Resolves PowerShell environment variables in remote paths to actual paths
|
|
@@ -364,7 +332,7 @@ module Kitchen
|
|
|
364
332
|
# @return [String] the resolved path
|
|
365
333
|
# @api private
|
|
366
334
|
def resolve_remote_path(path)
|
|
367
|
-
return path unless windows_os?
|
|
335
|
+
return path unless windows_os? && instance.transport.instance_variable_get(:@config)[:name] == "ssh"
|
|
368
336
|
|
|
369
337
|
# For Windows, resolve common PowerShell environment variables
|
|
370
338
|
resolved_path = path.dup
|
data/lib/kitchen/provisioner.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Kitchen
|
|
|
26
26
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
|
27
27
|
module Provisioner
|
|
28
28
|
# Default provisioner to use
|
|
29
|
-
DEFAULT_PLUGIN = "
|
|
29
|
+
DEFAULT_PLUGIN = "shell".freeze
|
|
30
30
|
|
|
31
31
|
# Returns an instance of a provisioner given a plugin type string.
|
|
32
32
|
#
|
|
@@ -35,7 +35,6 @@ module Kitchen
|
|
|
35
35
|
# @return [Provisioner::Base] a provisioner instance
|
|
36
36
|
# @raise [ClientError] if a provisioner instance could not be created
|
|
37
37
|
def self.for_plugin(plugin, config)
|
|
38
|
-
plugin, config[:name] = "chef_infra", "chef_infra" if plugin == "chef_zero"
|
|
39
38
|
Kitchen::Plugin.load(self, plugin, config)
|
|
40
39
|
end
|
|
41
40
|
end
|
|
@@ -21,8 +21,8 @@ require "rbconfig" unless defined?(RbConfig)
|
|
|
21
21
|
require "uri" unless defined?(URI)
|
|
22
22
|
require_relative "../../kitchen"
|
|
23
23
|
require_relative "../util"
|
|
24
|
-
require "winrm" unless defined?(WinRM::Connection)
|
|
25
|
-
require "winrm/exceptions" unless defined?(WinRM::WinRMHTTPTransportError)
|
|
24
|
+
require "chef-winrm" unless defined?(WinRM::Connection)
|
|
25
|
+
require "chef-winrm/exceptions" unless defined?(WinRM::WinRMHTTPTransportError)
|
|
26
26
|
|
|
27
27
|
module Kitchen
|
|
28
28
|
module Transport
|
|
@@ -420,9 +420,9 @@ module Kitchen
|
|
|
420
420
|
|
|
421
421
|
private
|
|
422
422
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
423
|
+
CHEF_WINRM_SPEC_VERSION = ["~> 2.0"].freeze
|
|
424
|
+
CHEF_WINRM_FS_SPEC_VERSION = ["~> 1.0"].freeze
|
|
425
|
+
CHEF_WINRM_ELEVATED_SPEC_VERSION = ["~> 1.0"].freeze
|
|
426
426
|
|
|
427
427
|
# Builds the hash of options needed by the Connection object on
|
|
428
428
|
# construction.
|
|
@@ -515,9 +515,9 @@ module Kitchen
|
|
|
515
515
|
# (see Base#load_needed_dependencies!)
|
|
516
516
|
def load_needed_dependencies!
|
|
517
517
|
super
|
|
518
|
-
load_with_rescue!("winrm",
|
|
519
|
-
load_with_rescue!("winrm-fs",
|
|
520
|
-
load_with_rescue!("winrm-elevated",
|
|
518
|
+
load_with_rescue!("chef-winrm", CHEF_WINRM_SPEC_VERSION.dup)
|
|
519
|
+
load_with_rescue!("chef-winrm-fs", CHEF_WINRM_FS_SPEC_VERSION.dup)
|
|
520
|
+
load_with_rescue!("chef-winrm-elevated", CHEF_WINRM_ELEVATED_SPEC_VERSION.dup) if config[:elevated]
|
|
521
521
|
end
|
|
522
522
|
|
|
523
523
|
def load_with_rescue!(gem_name, spec_version)
|
data/lib/kitchen/util.rb
CHANGED
|
@@ -128,7 +128,7 @@ module Kitchen
|
|
|
128
128
|
"sh -c '\n#{cmd}\n'"
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
#
|
|
131
|
+
# Modifies the given string to strip leading whitespace on each line, the
|
|
132
132
|
# amount which is calculated by using the first line of text.
|
|
133
133
|
#
|
|
134
134
|
# @example
|
data/lib/kitchen/version.rb
CHANGED
data/lib/kitchen.rb
CHANGED
|
@@ -31,7 +31,6 @@ require_relative "kitchen/config"
|
|
|
31
31
|
require_relative "kitchen/data_munger"
|
|
32
32
|
require_relative "kitchen/driver"
|
|
33
33
|
require_relative "kitchen/driver/base"
|
|
34
|
-
require_relative "kitchen/driver/ssh_base"
|
|
35
34
|
require_relative "kitchen/driver/proxy"
|
|
36
35
|
require_relative "kitchen/instance"
|
|
37
36
|
require_relative "kitchen/lifecycle_hooks"
|
|
@@ -41,7 +40,6 @@ require_relative "kitchen/loader/yaml"
|
|
|
41
40
|
require_relative "kitchen/metadata_chopper"
|
|
42
41
|
require_relative "kitchen/platform"
|
|
43
42
|
require_relative "kitchen/state_file"
|
|
44
|
-
require_relative "kitchen/ssh"
|
|
45
43
|
require_relative "kitchen/suite"
|
|
46
44
|
require_relative "kitchen/verifier"
|
|
47
45
|
require_relative "kitchen/verifier/base"
|
|
@@ -48,8 +48,8 @@ module HashRecursiveMerge
|
|
|
48
48
|
# When both +hsh+ and +other_hash+ contains an entry with the same key,
|
|
49
49
|
# it merges and returns the values from both arrays.
|
|
50
50
|
#
|
|
51
|
-
# Compared with Hash#merge, this method provides a different
|
|
52
|
-
# for merging
|
|
51
|
+
# Compared with Hash#merge, this method provides a different approach
|
|
52
|
+
# for merging nested hashes.
|
|
53
53
|
# If the value of a given key is an Hash and both +other_hash+ abd +hsh
|
|
54
54
|
# includes the same key, the value is merged instead replaced with
|
|
55
55
|
# +other_hash+ value.
|