test-kitchen 2.12.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Rakefile +1 -1
- data/lib/kitchen/configurable.rb +1 -1
- data/lib/kitchen/data_munger.rb +2 -0
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +15 -10
- data/lib/kitchen/provisioner/chef/policyfile.rb +14 -4
- data/lib/kitchen/provisioner/chef_base.rb +4 -3
- data/lib/kitchen/provisioner/chef_infra.rb +167 -0
- data/lib/kitchen/provisioner/chef_zero.rb +3 -158
- data/lib/kitchen/provisioner.rb +3 -1
- data/lib/kitchen/transport/ssh.rb +5 -3
- data/lib/kitchen/transport/winrm.rb +21 -8
- data/lib/kitchen/version.rb +1 -1
- data/test-kitchen.gemspec +3 -3
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ca7e5ea2276e74e8d5d6555731377aa0aacce64482f3ff810f18bca54095616
|
4
|
+
data.tar.gz: a726dfed16b6c6177559ed80a6450573fda9b9d3777aa008b3d639a81f152201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69456998d9b85ad5d28f522a98d7668279081c67a5c8dbdf17b299de2a8364d65064a641088d32f0dd820305beb07263ca0f2c66c49f6e433b9b9a3c49fe2b9b
|
7
|
+
data.tar.gz: c24f12f481427bf8a259afaaf09b93efe23c2d27632083fc3b78a25182a35e37f2fcfabf8344a7f0b30745a27b205904e21e247540e486e13f9810b8831db039
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
require "cucumber"
|
12
12
|
require "cucumber/rake/task"
|
13
13
|
Cucumber::Rake::Task.new(:features) do |t|
|
14
|
-
t.cucumber_opts = ["features", "-x", "--format progress", "--no-color", "--tags
|
14
|
+
t.cucumber_opts = ["features", "-x", "--format progress", "--no-color", "--tags 'not @ignore'"]
|
15
15
|
end
|
16
16
|
rescue LoadError
|
17
17
|
puts "cucumber is not available. (sudo) gem install cucumber to run tests."
|
data/lib/kitchen/configurable.rb
CHANGED
@@ -149,7 +149,7 @@ module Kitchen
|
|
149
149
|
# @return [String] joined path for instance's os_type
|
150
150
|
def remote_path_join(*parts)
|
151
151
|
path = File.join(*parts)
|
152
|
-
windows_os? ? path.tr("/",
|
152
|
+
windows_os? ? path.tr("/", "\\") : path.tr("\\", "/")
|
153
153
|
end
|
154
154
|
|
155
155
|
# @return [TrueClass,FalseClass] true if `:os_type` is `"unix"` (or
|
data/lib/kitchen/data_munger.rb
CHANGED
@@ -720,12 +720,14 @@ module Kitchen
|
|
720
720
|
move_data_to!(:provisioner, suite, :attributes)
|
721
721
|
move_data_to!(:provisioner, suite, :run_list)
|
722
722
|
move_data_to!(:provisioner, suite, :named_run_list)
|
723
|
+
move_data_to!(:provisioner, suite, :policy_group)
|
723
724
|
end
|
724
725
|
|
725
726
|
data.fetch(:platforms, []).each do |platform|
|
726
727
|
move_data_to!(:provisioner, platform, :attributes)
|
727
728
|
move_data_to!(:provisioner, platform, :run_list)
|
728
729
|
move_data_to!(:provisioner, platform, :named_run_list)
|
730
|
+
move_data_to!(:provisioner, platform, :policy_group)
|
729
731
|
end
|
730
732
|
end
|
731
733
|
|
@@ -73,6 +73,10 @@ module Kitchen
|
|
73
73
|
# @api private
|
74
74
|
attr_reader :sandbox_path
|
75
75
|
|
76
|
+
# @return [String] name of the policy_group, nil results in "local"
|
77
|
+
# @api private
|
78
|
+
attr_reader :policy_group
|
79
|
+
|
76
80
|
# Generates a list of all files in the cookbooks directory in the
|
77
81
|
# sandbox path.
|
78
82
|
#
|
@@ -281,19 +285,17 @@ module Kitchen
|
|
281
285
|
end
|
282
286
|
|
283
287
|
def update_dna_for_policyfile
|
284
|
-
|
285
|
-
|
286
|
-
"kitchen config. The run_list in your config will be ignored.")
|
287
|
-
warn("Ignored run_list: #{config[:run_list].inspect}")
|
288
|
-
end
|
289
|
-
policy = Chef::Policyfile.new(policyfile, sandbox_path,
|
288
|
+
policy = Chef::Policyfile.new(
|
289
|
+
policyfile, sandbox_path,
|
290
290
|
logger: logger,
|
291
|
-
always_update: config[:always_update_cookbooks]
|
291
|
+
always_update: config[:always_update_cookbooks],
|
292
|
+
policy_group: policy_group
|
293
|
+
)
|
292
294
|
Kitchen.mutex.synchronize do
|
293
295
|
policy.compile
|
294
296
|
end
|
295
297
|
policy_name = JSON.parse(IO.read(policy.lockfile))["name"]
|
296
|
-
policy_group = "local"
|
298
|
+
policy_group = config[:policy_group] || "local"
|
297
299
|
config[:attributes].merge(policy_name: policy_name, policy_group: policy_group)
|
298
300
|
end
|
299
301
|
|
@@ -302,9 +304,12 @@ module Kitchen
|
|
302
304
|
# @api private
|
303
305
|
def resolve_with_policyfile
|
304
306
|
Kitchen.mutex.synchronize do
|
305
|
-
Chef::Policyfile.new(
|
307
|
+
Chef::Policyfile.new(
|
308
|
+
policyfile, sandbox_path,
|
306
309
|
logger: logger,
|
307
|
-
always_update: config[:always_update_cookbooks]
|
310
|
+
always_update: config[:always_update_cookbooks],
|
311
|
+
policy_group: config[:policy_group]
|
312
|
+
).resolve
|
308
313
|
end
|
309
314
|
end
|
310
315
|
|
@@ -41,11 +41,12 @@ module Kitchen
|
|
41
41
|
# cookbooks
|
42
42
|
# @param logger [Kitchen::Logger] a logger to use for output, defaults
|
43
43
|
# to `Kitchen.logger`
|
44
|
-
def initialize(policyfile, path, logger: Kitchen.logger, always_update: false)
|
44
|
+
def initialize(policyfile, path, logger: Kitchen.logger, always_update: false, policy_group: nil)
|
45
45
|
@policyfile = policyfile
|
46
46
|
@path = path
|
47
47
|
@logger = logger
|
48
48
|
@always_update = always_update
|
49
|
+
@policy_group = policy_group
|
49
50
|
end
|
50
51
|
|
51
52
|
# Loads the library code required to use the resolver.
|
@@ -59,8 +60,13 @@ module Kitchen
|
|
59
60
|
# Performs the cookbook resolution and vendors the resulting cookbooks
|
60
61
|
# in the desired path.
|
61
62
|
def resolve
|
62
|
-
|
63
|
-
|
63
|
+
if policy_group
|
64
|
+
info("Exporting cookbook dependencies from Policyfile #{path} with policy_group #{policy_group} using `#{cli_path} export`...")
|
65
|
+
run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --policy_group #{policy_group} --force")
|
66
|
+
else
|
67
|
+
info("Exporting cookbook dependencies from Policyfile #{path} using `#{cli_path} export`...")
|
68
|
+
run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --force")
|
69
|
+
end
|
64
70
|
end
|
65
71
|
|
66
72
|
# Runs `chef install` to determine the correct cookbook set and
|
@@ -104,6 +110,10 @@ module Kitchen
|
|
104
110
|
# @api private
|
105
111
|
attr_reader :always_update
|
106
112
|
|
113
|
+
# @return [String] name of the policy_group, nil results in "local"
|
114
|
+
# @api private
|
115
|
+
attr_reader :policy_group
|
116
|
+
|
107
117
|
# Escape spaces in a path in way that works with both Sh (Unix) and
|
108
118
|
# Windows.
|
109
119
|
#
|
@@ -118,7 +128,7 @@ module Kitchen
|
|
118
128
|
# Windows command line parsing libraries. This covers the 99% case of
|
119
129
|
# spaces in the path without breaking other stuff.
|
120
130
|
if /[ \t\n\v"]/.match?(path)
|
121
|
-
"\"#{path.gsub(/[ \t\n\v\"\\]/) { |m|
|
131
|
+
"\"#{path.gsub(/[ \t\n\v\"\\]/) { |m| "\\" + m[0] }}\""
|
122
132
|
else
|
123
133
|
path
|
124
134
|
end
|
@@ -46,6 +46,7 @@ module Kitchen
|
|
46
46
|
default_config :chef_omnibus_install_options, nil
|
47
47
|
default_config :chef_license, nil
|
48
48
|
default_config :run_list, []
|
49
|
+
default_config :policy_group, nil
|
49
50
|
default_config :attributes, {}
|
50
51
|
default_config :config_path, nil
|
51
52
|
default_config :log_file, nil
|
@@ -63,12 +64,12 @@ module Kitchen
|
|
63
64
|
default_config :berksfile_path, nil
|
64
65
|
# If set to true (which is the default from `chef generate`), try to update
|
65
66
|
# backend cookbook downloader on every kitchen run.
|
66
|
-
default_config :always_update_cookbooks,
|
67
|
+
default_config :always_update_cookbooks, true
|
67
68
|
default_config :cookbook_files_glob, %w(
|
68
69
|
README.* VERSION metadata.{json,rb} attributes.rb recipe.rb
|
69
70
|
attributes/**/* definitions/**/* files/**/* libraries/**/*
|
70
71
|
providers/**/* recipes/**/* resources/**/* templates/**/*
|
71
|
-
ohai/**/*
|
72
|
+
ohai/**/* compliance/**/*
|
72
73
|
).join(",")
|
73
74
|
# to ease upgrades, allow the user to turn deprecation warnings into errors
|
74
75
|
default_config :deprecations_as_errors, false
|
@@ -441,7 +442,7 @@ module Kitchen
|
|
441
442
|
if obj.is_a?(String) && obj =~ /^:/
|
442
443
|
obj
|
443
444
|
elsif obj.is_a?(String)
|
444
|
-
%{"#{obj.gsub(/\\/,
|
445
|
+
%{"#{obj.gsub(/\\/, "\\\\\\\\")}"}
|
445
446
|
elsif obj.is_a?(Array)
|
446
447
|
%{[#{obj.map { |i| format_value(i) }.join(", ")}]}
|
447
448
|
else
|
@@ -0,0 +1,167 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
3
|
+
#
|
4
|
+
# Copyright (C) 2013, Fletcher Nichol
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require_relative "chef_base"
|
19
|
+
|
20
|
+
module Kitchen
|
21
|
+
module Provisioner
|
22
|
+
# Chef Zero provisioner.
|
23
|
+
#
|
24
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
25
|
+
class ChefInfra < ChefBase
|
26
|
+
kitchen_provisioner_api_version 2
|
27
|
+
|
28
|
+
plugin_version Kitchen::VERSION
|
29
|
+
|
30
|
+
default_config :client_rb, {}
|
31
|
+
default_config :named_run_list, {}
|
32
|
+
default_config :json_attributes, true
|
33
|
+
default_config :chef_zero_host, nil
|
34
|
+
default_config :chef_zero_port, 8889
|
35
|
+
|
36
|
+
default_config :chef_client_path do |provisioner|
|
37
|
+
provisioner
|
38
|
+
.remote_path_join(%W{#{provisioner[:chef_omnibus_root]} bin chef-client})
|
39
|
+
.tap { |path| path.concat(".bat") if provisioner.windows_os? }
|
40
|
+
end
|
41
|
+
|
42
|
+
default_config :ruby_bindir do |provisioner|
|
43
|
+
provisioner
|
44
|
+
.remote_path_join(%W{#{provisioner[:chef_omnibus_root]} embedded bin})
|
45
|
+
end
|
46
|
+
|
47
|
+
# (see Base#create_sandbox)
|
48
|
+
def create_sandbox
|
49
|
+
super
|
50
|
+
prepare_validation_pem
|
51
|
+
prepare_config_rb
|
52
|
+
end
|
53
|
+
|
54
|
+
def run_command
|
55
|
+
cmd = "#{sudo(config[:chef_client_path])} --local-mode".tap { |str| str.insert(0, "& ") if powershell_shell? }
|
56
|
+
|
57
|
+
chef_cmd(cmd)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
# Adds optional flags to a chef-client command, depending on
|
63
|
+
# configuration data. Note that this method mutates the incoming Array.
|
64
|
+
#
|
65
|
+
# @param args [Array<String>] array of flags
|
66
|
+
# @api private
|
67
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
68
|
+
def add_optional_chef_client_args!(args)
|
69
|
+
if config[:json_attributes]
|
70
|
+
json = remote_path_join(config[:root_path], "dna.json")
|
71
|
+
args << "--json-attributes #{json}"
|
72
|
+
end
|
73
|
+
|
74
|
+
args << "--logfile #{config[:log_file]}" if config[:log_file]
|
75
|
+
|
76
|
+
# these flags are chef-client local mode only and will not work
|
77
|
+
# on older versions of chef-client
|
78
|
+
if config[:chef_zero_host]
|
79
|
+
args << "--chef-zero-host #{config[:chef_zero_host]}"
|
80
|
+
end
|
81
|
+
|
82
|
+
if config[:chef_zero_port]
|
83
|
+
args << "--chef-zero-port #{config[:chef_zero_port]}"
|
84
|
+
end
|
85
|
+
|
86
|
+
args << "--profile-ruby" if config[:profile_ruby]
|
87
|
+
|
88
|
+
if config[:slow_resource_report]
|
89
|
+
if config[:slow_resource_report].is_a?(Integer)
|
90
|
+
args << "--slow-report #{config[:slow_resource_report]}"
|
91
|
+
else
|
92
|
+
args << "--slow-report"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
97
|
+
|
98
|
+
# Returns an Array of command line arguments for the chef client.
|
99
|
+
#
|
100
|
+
# @return [Array<String>] an array of command line arguments
|
101
|
+
# @api private
|
102
|
+
def chef_args(client_rb_filename)
|
103
|
+
level = config[:log_level]
|
104
|
+
args = [
|
105
|
+
"--config #{remote_path_join(config[:root_path], client_rb_filename)}",
|
106
|
+
"--log_level #{level}",
|
107
|
+
"--force-formatter",
|
108
|
+
"--no-color",
|
109
|
+
]
|
110
|
+
add_optional_chef_client_args!(args)
|
111
|
+
|
112
|
+
args
|
113
|
+
end
|
114
|
+
|
115
|
+
# Generates a string of shell environment variables needed for the
|
116
|
+
# chef-client-zero.rb shim script to properly function.
|
117
|
+
#
|
118
|
+
# @return [String] a shell script string
|
119
|
+
# @api private
|
120
|
+
def chef_client_zero_env
|
121
|
+
root = config[:root_path]
|
122
|
+
gem_home = gem_path = remote_path_join(root, "chef-client-zero-gems")
|
123
|
+
gem_cache = remote_path_join(gem_home, "cache")
|
124
|
+
|
125
|
+
[
|
126
|
+
shell_env_var("CHEF_REPO_PATH", root),
|
127
|
+
shell_env_var("GEM_HOME", gem_home),
|
128
|
+
shell_env_var("GEM_PATH", gem_path),
|
129
|
+
shell_env_var("GEM_CACHE", gem_cache),
|
130
|
+
].join("\n").concat("\n")
|
131
|
+
end
|
132
|
+
|
133
|
+
# Writes a fake (but valid) validation.pem into the sandbox directory.
|
134
|
+
#
|
135
|
+
# @api private
|
136
|
+
def prepare_validation_pem
|
137
|
+
info("Preparing validation.pem")
|
138
|
+
debug("Using a dummy validation.pem")
|
139
|
+
|
140
|
+
source = File.join(File.dirname(__FILE__),
|
141
|
+
%w{.. .. .. support dummy-validation.pem})
|
142
|
+
FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the command that will run a backwards compatible shim script
|
146
|
+
# that approximates local mode in a modern chef-client run.
|
147
|
+
#
|
148
|
+
# @return [String] the command string
|
149
|
+
# @api private
|
150
|
+
def shim_command
|
151
|
+
ruby = remote_path_join(config[:ruby_bindir], "ruby")
|
152
|
+
.tap { |path| path.concat(".exe") if windows_os? }
|
153
|
+
shim = remote_path_join(config[:root_path], "chef-client-zero.rb")
|
154
|
+
|
155
|
+
"#{chef_client_zero_env}\n#{sudo(ruby)} #{shim}"
|
156
|
+
end
|
157
|
+
|
158
|
+
# This provisioner supports policyfiles, so override the default (which
|
159
|
+
# is false)
|
160
|
+
# @return [true] always returns true
|
161
|
+
# @api private
|
162
|
+
def supports_policyfile?
|
163
|
+
true
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -1,167 +1,12 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (C) 2013, Fletcher Nichol
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
require_relative "chef_base"
|
1
|
+
# Deprecated AS PER THE PR - https://github.com/test-kitchen/test-kitchen/pull/1730
|
2
|
+
require_relative "chef_infra"
|
19
3
|
|
20
4
|
module Kitchen
|
21
5
|
module Provisioner
|
22
6
|
# Chef Zero provisioner.
|
23
7
|
#
|
24
8
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
25
|
-
class ChefZero <
|
26
|
-
kitchen_provisioner_api_version 2
|
27
|
-
|
28
|
-
plugin_version Kitchen::VERSION
|
29
|
-
|
30
|
-
default_config :client_rb, {}
|
31
|
-
default_config :named_run_list, {}
|
32
|
-
default_config :json_attributes, true
|
33
|
-
default_config :chef_zero_host, nil
|
34
|
-
default_config :chef_zero_port, 8889
|
35
|
-
|
36
|
-
default_config :chef_client_path do |provisioner|
|
37
|
-
provisioner
|
38
|
-
.remote_path_join(%W{#{provisioner[:chef_omnibus_root]} bin chef-client})
|
39
|
-
.tap { |path| path.concat(".bat") if provisioner.windows_os? }
|
40
|
-
end
|
41
|
-
|
42
|
-
default_config :ruby_bindir do |provisioner|
|
43
|
-
provisioner
|
44
|
-
.remote_path_join(%W{#{provisioner[:chef_omnibus_root]} embedded bin})
|
45
|
-
end
|
46
|
-
|
47
|
-
# (see Base#create_sandbox)
|
48
|
-
def create_sandbox
|
49
|
-
super
|
50
|
-
prepare_validation_pem
|
51
|
-
prepare_config_rb
|
52
|
-
end
|
53
|
-
|
54
|
-
def run_command
|
55
|
-
cmd = "#{sudo(config[:chef_client_path])} --local-mode".tap { |str| str.insert(0, "& ") if powershell_shell? }
|
56
|
-
|
57
|
-
chef_cmd(cmd)
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
# Adds optional flags to a chef-client command, depending on
|
63
|
-
# configuration data. Note that this method mutates the incoming Array.
|
64
|
-
#
|
65
|
-
# @param args [Array<String>] array of flags
|
66
|
-
# @api private
|
67
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
68
|
-
def add_optional_chef_client_args!(args)
|
69
|
-
if config[:json_attributes]
|
70
|
-
json = remote_path_join(config[:root_path], "dna.json")
|
71
|
-
args << "--json-attributes #{json}"
|
72
|
-
end
|
73
|
-
|
74
|
-
args << "--logfile #{config[:log_file]}" if config[:log_file]
|
75
|
-
|
76
|
-
# these flags are chef-client local mode only and will not work
|
77
|
-
# on older versions of chef-client
|
78
|
-
if config[:chef_zero_host]
|
79
|
-
args << "--chef-zero-host #{config[:chef_zero_host]}"
|
80
|
-
end
|
81
|
-
|
82
|
-
if config[:chef_zero_port]
|
83
|
-
args << "--chef-zero-port #{config[:chef_zero_port]}"
|
84
|
-
end
|
85
|
-
|
86
|
-
args << "--profile-ruby" if config[:profile_ruby]
|
87
|
-
|
88
|
-
if config[:slow_resource_report]
|
89
|
-
if config[:slow_resource_report].is_a?(Integer)
|
90
|
-
args << "--slow-report #{config[:slow_resource_report]}"
|
91
|
-
else
|
92
|
-
args << "--slow-report"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
97
|
-
|
98
|
-
# Returns an Array of command line arguments for the chef client.
|
99
|
-
#
|
100
|
-
# @return [Array<String>] an array of command line arguments
|
101
|
-
# @api private
|
102
|
-
def chef_args(client_rb_filename)
|
103
|
-
level = config[:log_level]
|
104
|
-
args = [
|
105
|
-
"--config #{remote_path_join(config[:root_path], client_rb_filename)}",
|
106
|
-
"--log_level #{level}",
|
107
|
-
"--force-formatter",
|
108
|
-
"--no-color",
|
109
|
-
]
|
110
|
-
add_optional_chef_client_args!(args)
|
111
|
-
|
112
|
-
args
|
113
|
-
end
|
114
|
-
|
115
|
-
# Generates a string of shell environment variables needed for the
|
116
|
-
# chef-client-zero.rb shim script to properly function.
|
117
|
-
#
|
118
|
-
# @return [String] a shell script string
|
119
|
-
# @api private
|
120
|
-
def chef_client_zero_env
|
121
|
-
root = config[:root_path]
|
122
|
-
gem_home = gem_path = remote_path_join(root, "chef-client-zero-gems")
|
123
|
-
gem_cache = remote_path_join(gem_home, "cache")
|
124
|
-
|
125
|
-
[
|
126
|
-
shell_env_var("CHEF_REPO_PATH", root),
|
127
|
-
shell_env_var("GEM_HOME", gem_home),
|
128
|
-
shell_env_var("GEM_PATH", gem_path),
|
129
|
-
shell_env_var("GEM_CACHE", gem_cache),
|
130
|
-
].join("\n").concat("\n")
|
131
|
-
end
|
132
|
-
|
133
|
-
# Writes a fake (but valid) validation.pem into the sandbox directory.
|
134
|
-
#
|
135
|
-
# @api private
|
136
|
-
def prepare_validation_pem
|
137
|
-
info("Preparing validation.pem")
|
138
|
-
debug("Using a dummy validation.pem")
|
139
|
-
|
140
|
-
source = File.join(File.dirname(__FILE__),
|
141
|
-
%w{.. .. .. support dummy-validation.pem})
|
142
|
-
FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
|
143
|
-
end
|
144
|
-
|
145
|
-
# Returns the command that will run a backwards compatible shim script
|
146
|
-
# that approximates local mode in a modern chef-client run.
|
147
|
-
#
|
148
|
-
# @return [String] the command string
|
149
|
-
# @api private
|
150
|
-
def shim_command
|
151
|
-
ruby = remote_path_join(config[:ruby_bindir], "ruby")
|
152
|
-
.tap { |path| path.concat(".exe") if windows_os? }
|
153
|
-
shim = remote_path_join(config[:root_path], "chef-client-zero.rb")
|
154
|
-
|
155
|
-
"#{chef_client_zero_env}\n#{sudo(ruby)} #{shim}"
|
156
|
-
end
|
157
|
-
|
158
|
-
# This provisioner supports policyfiles, so override the default (which
|
159
|
-
# is false)
|
160
|
-
# @return [true] always returns true
|
161
|
-
# @api private
|
162
|
-
def supports_policyfile?
|
163
|
-
true
|
164
|
-
end
|
9
|
+
class ChefZero < ChefInfra
|
165
10
|
end
|
166
11
|
end
|
167
12
|
end
|
data/lib/kitchen/provisioner.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
3
3
|
#
|
4
4
|
# Copyright (C) 2013, Fletcher Nichol
|
5
|
+
# Copyright (C) Chef Software Inc.
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
8
|
# you may not use this file except in compliance with the License.
|
@@ -25,7 +26,7 @@ module Kitchen
|
|
25
26
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
26
27
|
module Provisioner
|
27
28
|
# Default provisioner to use
|
28
|
-
DEFAULT_PLUGIN = "
|
29
|
+
DEFAULT_PLUGIN = "chef_infra".freeze
|
29
30
|
|
30
31
|
# Returns an instance of a provisioner given a plugin type string.
|
31
32
|
#
|
@@ -34,6 +35,7 @@ module Kitchen
|
|
34
35
|
# @return [Provisioner::Base] a provisioner instance
|
35
36
|
# @raise [ClientError] if a provisioner instance could not be created
|
36
37
|
def self.for_plugin(plugin, config)
|
38
|
+
plugin, config[:name] = "chef_infra", "chef_infra" if plugin == "chef_zero"
|
37
39
|
Kitchen::Plugin.load(self, plugin, config)
|
38
40
|
end
|
39
41
|
end
|
@@ -176,9 +176,11 @@ module Kitchen
|
|
176
176
|
Array(locals).map do |local|
|
177
177
|
opts = File.directory?(local) ? { recursive: true } : {}
|
178
178
|
|
179
|
-
waits.push
|
180
|
-
|
181
|
-
|
179
|
+
waits.push(
|
180
|
+
session.scp.upload(local, remote, opts) do |_ch, name, sent, total|
|
181
|
+
logger.debug("Async Uploaded #{name} (#{total} bytes)") if sent == total
|
182
|
+
end
|
183
|
+
)
|
182
184
|
waits.shift.wait while waits.length >= max_ssh_sessions
|
183
185
|
end
|
184
186
|
waits.each(&:wait)
|
@@ -439,18 +439,31 @@ module Kitchen
|
|
439
439
|
elevated_username: data[:elevated_username] || data[:username],
|
440
440
|
elevated_password: elevated_password,
|
441
441
|
}
|
442
|
-
opts.merge!(additional_transport_args(opts[:transport]))
|
442
|
+
opts.merge!(additional_transport_args(data, opts[:transport]))
|
443
|
+
if opts[:transport].to_sym == :ssl && opts.key?(:client_cert) && opts.key?(:client_key)
|
444
|
+
opts.delete(:user)
|
445
|
+
opts.delete(:password)
|
446
|
+
end
|
443
447
|
opts
|
444
448
|
end
|
445
449
|
|
446
|
-
def additional_transport_args(transport_type)
|
450
|
+
def additional_transport_args(data, transport_type)
|
451
|
+
opts = {
|
452
|
+
disable_sspi: false,
|
453
|
+
basic_auth_only: false,
|
454
|
+
}
|
455
|
+
|
447
456
|
case transport_type.to_sym
|
448
|
-
when :ssl
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
457
|
+
when :ssl
|
458
|
+
if data.key?(:client_cert) && data.key?(:client_key)
|
459
|
+
opts[:client_cert] = data[:client_cert]
|
460
|
+
opts[:client_key] = data[:client_key]
|
461
|
+
end
|
462
|
+
opts[:no_ssl_peer_verification] = data.key?(:no_ssl_peer_verification) ? data[:no_ssl_peer_verification] : true
|
463
|
+
opts
|
464
|
+
when :negotiate
|
465
|
+
opts[:no_ssl_peer_verification] = true
|
466
|
+
opts
|
454
467
|
when :plaintext
|
455
468
|
{
|
456
469
|
disable_sspi: true,
|
data/lib/kitchen/version.rb
CHANGED
data/test-kitchen.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.executables = %w{kitchen}
|
21
21
|
gem.require_paths = ["lib"]
|
22
22
|
|
23
|
-
gem.required_ruby_version = ">= 2.
|
23
|
+
gem.required_ruby_version = ">= 2.6"
|
24
24
|
|
25
25
|
gem.add_dependency "mixlib-shellout", ">= 1.2", "< 4.0"
|
26
26
|
gem.add_dependency "net-scp", ">= 1.1", "< 4.0" # pinning until we can confirm 4+ works
|
@@ -44,9 +44,9 @@ Gem::Specification.new do |gem|
|
|
44
44
|
|
45
45
|
gem.add_development_dependency "aruba", "~> 0.11", "< 1.0"
|
46
46
|
gem.add_development_dependency "fakefs", "~> 1.0"
|
47
|
-
gem.add_development_dependency "minitest", "~> 5.3", "< 5.
|
47
|
+
gem.add_development_dependency "minitest", "~> 5.3", "< 5.15"
|
48
48
|
gem.add_development_dependency "mocha", "~> 1.1"
|
49
|
-
gem.add_development_dependency "cucumber", ">= 2.1", "<
|
49
|
+
gem.add_development_dependency "cucumber", ">= 2.1", "< 8.0"
|
50
50
|
gem.add_development_dependency "countloc", "~> 0.4"
|
51
51
|
gem.add_development_dependency "maruku", "~> 0.6"
|
52
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-kitchen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 3.2.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: 2021-
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -313,7 +313,7 @@ dependencies:
|
|
313
313
|
version: '5.3'
|
314
314
|
- - "<"
|
315
315
|
- !ruby/object:Gem::Version
|
316
|
-
version: '5.
|
316
|
+
version: '5.15'
|
317
317
|
type: :development
|
318
318
|
prerelease: false
|
319
319
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -323,7 +323,7 @@ dependencies:
|
|
323
323
|
version: '5.3'
|
324
324
|
- - "<"
|
325
325
|
- !ruby/object:Gem::Version
|
326
|
-
version: '5.
|
326
|
+
version: '5.15'
|
327
327
|
- !ruby/object:Gem::Dependency
|
328
328
|
name: mocha
|
329
329
|
requirement: !ruby/object:Gem::Requirement
|
@@ -347,7 +347,7 @@ dependencies:
|
|
347
347
|
version: '2.1'
|
348
348
|
- - "<"
|
349
349
|
- !ruby/object:Gem::Version
|
350
|
-
version: '
|
350
|
+
version: '8.0'
|
351
351
|
type: :development
|
352
352
|
prerelease: false
|
353
353
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -357,7 +357,7 @@ dependencies:
|
|
357
357
|
version: '2.1'
|
358
358
|
- - "<"
|
359
359
|
- !ruby/object:Gem::Version
|
360
|
-
version: '
|
360
|
+
version: '8.0'
|
361
361
|
- !ruby/object:Gem::Dependency
|
362
362
|
name: countloc
|
363
363
|
requirement: !ruby/object:Gem::Requirement
|
@@ -449,6 +449,7 @@ files:
|
|
449
449
|
- lib/kitchen/provisioner/chef/policyfile.rb
|
450
450
|
- lib/kitchen/provisioner/chef_apply.rb
|
451
451
|
- lib/kitchen/provisioner/chef_base.rb
|
452
|
+
- lib/kitchen/provisioner/chef_infra.rb
|
452
453
|
- lib/kitchen/provisioner/chef_solo.rb
|
453
454
|
- lib/kitchen/provisioner/chef_zero.rb
|
454
455
|
- lib/kitchen/provisioner/dummy.rb
|
@@ -512,14 +513,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
512
513
|
requirements:
|
513
514
|
- - ">="
|
514
515
|
- !ruby/object:Gem::Version
|
515
|
-
version: '2.
|
516
|
+
version: '2.6'
|
516
517
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
517
518
|
requirements:
|
518
519
|
- - ">="
|
519
520
|
- !ruby/object:Gem::Version
|
520
521
|
version: '0'
|
521
522
|
requirements: []
|
522
|
-
rubygems_version: 3.2.
|
523
|
+
rubygems_version: 3.2.22
|
523
524
|
signing_key:
|
524
525
|
specification_version: 4
|
525
526
|
summary: Test Kitchen is an integration tool for developing and testing infrastructure
|