test-kitchen 1.3.1 → 1.4.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +2 -0
- data/.gitignore +4 -0
- data/CHANGELOG.md +45 -0
- data/Rakefile +15 -0
- data/features/kitchen_action_commands.feature +12 -9
- data/features/kitchen_defaults.feature +38 -0
- data/features/kitchen_init_command.feature +0 -1
- data/features/kitchen_list_command.feature +2 -2
- data/features/kitchen_login_command.feature +7 -1
- data/features/kitchen_test_command.feature +4 -4
- data/lib/kitchen.rb +40 -11
- data/lib/kitchen/cli.rb +38 -22
- data/lib/kitchen/command/list.rb +5 -2
- data/lib/kitchen/config.rb +45 -18
- data/lib/kitchen/configurable.rb +137 -1
- data/lib/kitchen/data_munger.rb +248 -17
- data/lib/kitchen/driver.rb +1 -1
- data/lib/kitchen/driver/base.rb +1 -83
- data/lib/kitchen/driver/dummy.rb +0 -5
- data/lib/kitchen/driver/ssh_base.rb +177 -22
- data/lib/kitchen/instance.rb +140 -20
- data/lib/kitchen/logger.rb +43 -8
- data/lib/kitchen/login_command.rb +14 -5
- data/lib/kitchen/platform.rb +19 -0
- data/lib/kitchen/provisioner.rb +5 -3
- data/lib/kitchen/provisioner/base.rb +46 -48
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +322 -0
- data/lib/kitchen/provisioner/chef_base.rb +179 -286
- data/lib/kitchen/provisioner/chef_solo.rb +11 -5
- data/lib/kitchen/provisioner/chef_zero.rb +108 -94
- data/lib/kitchen/provisioner/dummy.rb +47 -0
- data/lib/kitchen/provisioner/shell.rb +45 -12
- data/lib/kitchen/rake_tasks.rb +1 -1
- data/lib/kitchen/ssh.rb +1 -1
- data/lib/kitchen/thor_tasks.rb +1 -1
- data/lib/kitchen/transport.rb +54 -0
- data/lib/kitchen/transport/base.rb +146 -0
- data/lib/kitchen/transport/dummy.rb +75 -0
- data/lib/kitchen/transport/ssh.rb +325 -0
- data/lib/kitchen/transport/winrm.rb +508 -0
- data/lib/kitchen/transport/winrm/command_executor.rb +188 -0
- data/lib/kitchen/transport/winrm/file_transporter.rb +454 -0
- data/lib/kitchen/transport/winrm/logging.rb +50 -0
- data/lib/kitchen/transport/winrm/template.rb +74 -0
- data/lib/kitchen/transport/winrm/tmp_zip.rb +187 -0
- data/lib/kitchen/verifier.rb +55 -0
- data/lib/kitchen/verifier/base.rb +191 -0
- data/lib/kitchen/verifier/busser.rb +266 -0
- data/lib/kitchen/verifier/dummy.rb +75 -0
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/cli_spec.rb +56 -0
- data/spec/kitchen/config_spec.rb +61 -20
- data/spec/kitchen/configurable_spec.rb +327 -1
- data/spec/kitchen/data_munger_spec.rb +777 -14
- data/spec/kitchen/driver/base_spec.rb +7 -38
- data/spec/kitchen/driver/dummy_spec.rb +0 -29
- data/spec/kitchen/driver/ssh_base_spec.rb +580 -236
- data/spec/kitchen/driver_spec.rb +1 -0
- data/spec/kitchen/instance_spec.rb +383 -83
- data/spec/kitchen/login_command_spec.rb +29 -10
- data/spec/kitchen/platform_spec.rb +58 -2
- data/spec/kitchen/provisioner/base_spec.rb +170 -18
- data/spec/kitchen/provisioner/chef_base_spec.rb +454 -104
- data/spec/kitchen/provisioner/chef_solo_spec.rb +307 -104
- data/spec/kitchen/provisioner/chef_zero_spec.rb +561 -230
- data/spec/kitchen/provisioner/dummy_spec.rb +91 -0
- data/spec/kitchen/provisioner/shell_spec.rb +158 -56
- data/spec/kitchen/provisioner_spec.rb +37 -0
- data/spec/kitchen/ssh_spec.rb +19 -19
- data/spec/kitchen/transport/base_spec.rb +89 -0
- data/spec/kitchen/transport/ssh_spec.rb +1147 -0
- data/spec/kitchen/transport/winrm/command_executor_spec.rb +400 -0
- data/spec/kitchen/transport/winrm/file_transporter_spec.rb +876 -0
- data/spec/kitchen/transport/winrm/logging_spec.rb +92 -0
- data/spec/kitchen/transport/winrm/template_spec.rb +51 -0
- data/spec/kitchen/transport/winrm/tmp_zip_spec.rb +132 -0
- data/spec/kitchen/transport/winrm_spec.rb +1069 -0
- data/spec/kitchen/transport_spec.rb +112 -0
- data/spec/kitchen/verifier/base_spec.rb +310 -0
- data/spec/kitchen/verifier/busser_spec.rb +540 -0
- data/spec/kitchen/verifier/dummy_spec.rb +91 -0
- data/spec/kitchen/verifier_spec.rb +120 -0
- data/spec/kitchen_spec.rb +7 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/powershell_max_size_spec.rb +40 -0
- data/support/busser_install_command.ps1 +14 -0
- data/support/busser_install_command.sh +15 -0
- data/support/check_files.ps1.erb +48 -0
- data/support/chef_base_init_command.ps1 +18 -0
- data/support/chef_base_init_command.sh +2 -0
- data/support/chef_base_install_command.ps1 +76 -0
- data/support/chef_base_install_command.sh +137 -0
- data/support/chef_zero_prepare_command_legacy.ps1 +9 -0
- data/support/chef_zero_prepare_command_legacy.sh +10 -0
- data/support/decode_files.ps1.erb +61 -0
- data/test-kitchen.gemspec +2 -0
- metadata +97 -8
- data/lib/kitchen/busser.rb +0 -316
- data/spec/kitchen/busser_spec.rb +0 -490
- data/support/chef_helpers.sh +0 -16
@@ -30,7 +30,9 @@ module Kitchen
|
|
30
30
|
default_config :solo_rb, {}
|
31
31
|
|
32
32
|
default_config :chef_solo_path do |provisioner|
|
33
|
-
|
33
|
+
provisioner.
|
34
|
+
remote_path_join(%W[#{provisioner[:chef_omnibus_root]} bin chef-solo]).
|
35
|
+
tap { |path| path.concat(".bat") if provisioner.windows_os? }
|
34
36
|
end
|
35
37
|
|
36
38
|
# (see Base#create_sandbox)
|
@@ -43,17 +45,21 @@ module Kitchen
|
|
43
45
|
def run_command
|
44
46
|
level = config[:log_level] == :info ? :auto : config[:log_level]
|
45
47
|
|
46
|
-
cmd = sudo(config[:chef_solo_path])
|
48
|
+
cmd = sudo(config[:chef_solo_path]).dup.
|
49
|
+
tap { |str| str.insert(0, "& ") if powershell_shell? }
|
47
50
|
args = [
|
48
|
-
"--config #{config[:root_path]
|
51
|
+
"--config #{remote_path_join(config[:root_path], "solo.rb")}",
|
49
52
|
"--log_level #{level}",
|
50
53
|
"--force-formatter",
|
51
54
|
"--no-color",
|
52
|
-
"--json-attributes #{config[:root_path]
|
55
|
+
"--json-attributes #{remote_path_join(config[:root_path], "dna.json")}"
|
53
56
|
]
|
54
57
|
args << "--logfile #{config[:log_file]}" if config[:log_file]
|
55
58
|
|
56
|
-
|
59
|
+
wrap_shell_code(
|
60
|
+
[cmd, *args].join(" ").
|
61
|
+
tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
|
62
|
+
)
|
57
63
|
end
|
58
64
|
|
59
65
|
private
|
@@ -28,13 +28,19 @@ module Kitchen
|
|
28
28
|
class ChefZero < ChefBase
|
29
29
|
|
30
30
|
default_config :client_rb, {}
|
31
|
-
default_config :ruby_bindir, "/opt/chef/embedded/bin"
|
32
31
|
default_config :json_attributes, true
|
33
32
|
default_config :chef_zero_host, nil
|
34
33
|
default_config :chef_zero_port, 8889
|
35
34
|
|
36
35
|
default_config :chef_client_path do |provisioner|
|
37
|
-
|
36
|
+
provisioner.
|
37
|
+
remote_path_join(%W[#{provisioner[:chef_omnibus_root]} bin chef-client]).
|
38
|
+
tap { |path| path.concat(".bat") if provisioner.windows_os? }
|
39
|
+
end
|
40
|
+
|
41
|
+
default_config :ruby_bindir do |provisioner|
|
42
|
+
provisioner.
|
43
|
+
remote_path_join(%W[#{provisioner[:chef_omnibus_root]} embedded bin])
|
38
44
|
end
|
39
45
|
|
40
46
|
# (see Base#create_sandbox)
|
@@ -49,52 +55,51 @@ module Kitchen
|
|
49
55
|
def prepare_command
|
50
56
|
return if modern?
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
echo ">>>>>> Attempting to use chef-zero with old version of Chef"
|
61
|
-
echo "-----> Installing chef zero dependencies"
|
62
|
-
#{sudo(ruby_bin.join("gem"))} install chef --no-ri --no-rdoc --conservative
|
63
|
-
fi
|
64
|
-
PREPARE
|
65
|
-
|
66
|
-
Util.wrap_command(cmd)
|
58
|
+
gem_bin = remote_path_join(config[:ruby_bindir], "gem").
|
59
|
+
tap { |path| path.concat(".bat") if windows_os? }
|
60
|
+
vars = [
|
61
|
+
chef_client_zero_env,
|
62
|
+
shell_var("gem", sudo(gem_bin))
|
63
|
+
].join("\n").concat("\n")
|
64
|
+
|
65
|
+
shell_code_from_file(vars, "chef_zero_prepare_command_legacy")
|
67
66
|
end
|
68
67
|
|
69
68
|
# (see Base#run_command)
|
70
69
|
def run_command
|
71
70
|
cmd = modern? ? local_mode_command : shim_command
|
72
71
|
|
73
|
-
|
72
|
+
wrap_shell_code(
|
73
|
+
[cmd, *chef_client_args].join(" ").
|
74
|
+
tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
|
75
|
+
)
|
74
76
|
end
|
75
77
|
|
76
78
|
private
|
77
79
|
|
78
|
-
#
|
79
|
-
#
|
80
|
+
# Adds optional flags to a chef-client command, depending on
|
81
|
+
# configuration data. Note that this method mutates the incoming Array.
|
80
82
|
#
|
81
|
-
# @
|
83
|
+
# @param args [Array<String>] array of flags
|
82
84
|
# @api private
|
83
|
-
def
|
84
|
-
|
85
|
-
|
85
|
+
def add_optional_chef_client_args!(args)
|
86
|
+
if config[:json_attributes]
|
87
|
+
json = remote_path_join(config[:root_path], "dna.json")
|
88
|
+
args << "--json-attributes #{json}"
|
89
|
+
end
|
90
|
+
if config[:log_file]
|
91
|
+
args << "--logfile #{config[:log_file]}"
|
92
|
+
end
|
93
|
+
return unless modern?
|
86
94
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
sudo("#{config[:ruby_bindir]}/ruby"),
|
96
|
-
"#{config[:root_path]}/chef-client-zero.rb"
|
97
|
-
].join(" ")
|
95
|
+
# these flags are modern/chef-client local most only and will not work
|
96
|
+
# on older versions of chef-client
|
97
|
+
if config[:chef_zero_host]
|
98
|
+
args << "--chef-zero-host #{config[:chef_zero_host]}"
|
99
|
+
end
|
100
|
+
if config[:chef_zero_port]
|
101
|
+
args << "--chef-zero-port #{config[:chef_zero_port]}"
|
102
|
+
end
|
98
103
|
end
|
99
104
|
|
100
105
|
# Returns an Array of command line arguments for the chef client.
|
@@ -104,28 +109,66 @@ module Kitchen
|
|
104
109
|
def chef_client_args
|
105
110
|
level = config[:log_level] == :info ? :auto : config[:log_level]
|
106
111
|
args = [
|
107
|
-
"--config #{config[:root_path]
|
112
|
+
"--config #{remote_path_join(config[:root_path], "client.rb")}",
|
108
113
|
"--log_level #{level}",
|
109
114
|
"--force-formatter",
|
110
115
|
"--no-color"
|
111
116
|
]
|
112
|
-
|
113
|
-
if config[:chef_zero_host]
|
114
|
-
args << "--chef-zero-host #{config[:chef_zero_host]}"
|
115
|
-
end
|
116
|
-
if config[:chef_zero_port]
|
117
|
-
args << "--chef-zero-port #{config[:chef_zero_port]}"
|
118
|
-
end
|
119
|
-
if config[:json_attributes]
|
120
|
-
args << "--json-attributes #{config[:root_path]}/dna.json"
|
121
|
-
end
|
122
|
-
if config[:log_file]
|
123
|
-
args << "--logfile #{config[:log_file]}"
|
124
|
-
end
|
117
|
+
add_optional_chef_client_args!(args)
|
125
118
|
|
126
119
|
args
|
127
120
|
end
|
128
121
|
|
122
|
+
# Generates a string of shell environment variables needed for the
|
123
|
+
# chef-client-zero.rb shim script to properly function.
|
124
|
+
#
|
125
|
+
# @return [String] a shell script string
|
126
|
+
# @api private
|
127
|
+
def chef_client_zero_env
|
128
|
+
root = config[:root_path]
|
129
|
+
gem_home = gem_path = remote_path_join(root, "chef-client-zero-gems")
|
130
|
+
gem_cache = remote_path_join(gem_home, "cache")
|
131
|
+
|
132
|
+
[
|
133
|
+
shell_env_var("CHEF_REPO_PATH", root),
|
134
|
+
shell_env_var("GEM_HOME", gem_home),
|
135
|
+
shell_env_var("GEM_PATH", gem_path),
|
136
|
+
shell_env_var("GEM_CACHE", gem_cache)
|
137
|
+
].join("\n").concat("\n")
|
138
|
+
end
|
139
|
+
|
140
|
+
# Returns the command that will run chef client in local mode (a.k.a.
|
141
|
+
# chef zero mode).
|
142
|
+
#
|
143
|
+
# @return [String] the command string
|
144
|
+
# @api private
|
145
|
+
def local_mode_command
|
146
|
+
"#{sudo(config[:chef_client_path])} --local-mode".
|
147
|
+
tap { |str| str.insert(0, "& ") if powershell_shell? }
|
148
|
+
end
|
149
|
+
|
150
|
+
# Determines whether or not local mode (a.k.a chef zero mode) is
|
151
|
+
# supported in the version of Chef as determined by inspecting the
|
152
|
+
# require_chef_omnibus config variable.
|
153
|
+
#
|
154
|
+
# The only way this method returns false is if require_chef_omnibus has
|
155
|
+
# an explicit version set to less than 11.8.0, when chef zero mode was
|
156
|
+
# introduced. Otherwise a modern Chef installation is assumed.
|
157
|
+
#
|
158
|
+
# @return [true,false] whether or not the desired version of Chef
|
159
|
+
# supports local mode
|
160
|
+
# @api private
|
161
|
+
def modern?
|
162
|
+
version = config[:require_chef_omnibus]
|
163
|
+
|
164
|
+
case version
|
165
|
+
when nil, false, true, "latest"
|
166
|
+
true
|
167
|
+
else
|
168
|
+
Gem::Version.new(version) >= Gem::Version.new("11.8.0") ? true : false
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
129
172
|
# Writes a chef-client local-mode shim script to the sandbox directory
|
130
173
|
# only if the desired version of Chef is old enough. The version of Chef
|
131
174
|
# is determined using the `config[:require_chef_omnibus]` value.
|
@@ -142,18 +185,6 @@ module Kitchen
|
|
142
185
|
FileUtils.cp(source, File.join(sandbox_path, "chef-client-zero.rb"))
|
143
186
|
end
|
144
187
|
|
145
|
-
# Writes a fake (but valid) validation.pem into the sandbox directory.
|
146
|
-
#
|
147
|
-
# @api private
|
148
|
-
def prepare_validation_pem
|
149
|
-
info("Preparing validation.pem")
|
150
|
-
debug("Using a dummy validation.pem")
|
151
|
-
|
152
|
-
source = File.join(File.dirname(__FILE__),
|
153
|
-
%w[.. .. .. support dummy-validation.pem])
|
154
|
-
FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
|
155
|
-
end
|
156
|
-
|
157
188
|
# Writes a client.rb configuration file to the sandbox directory.
|
158
189
|
#
|
159
190
|
# @api private
|
@@ -168,46 +199,29 @@ module Kitchen
|
|
168
199
|
end
|
169
200
|
end
|
170
201
|
|
171
|
-
#
|
172
|
-
# chef-client-zero.rb shim script to properly function.
|
202
|
+
# Writes a fake (but valid) validation.pem into the sandbox directory.
|
173
203
|
#
|
174
|
-
# @param extra [Symbol] whether or not the environment variables need to
|
175
|
-
# be exported, using the `:export` symbol (default: `nil`)
|
176
|
-
# @return [String] a shell script string
|
177
204
|
# @api private
|
178
|
-
def
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
%
|
184
|
-
|
185
|
-
if extra == :export
|
186
|
-
args << %{; export CHEF_REPO_PATH GEM_HOME GEM_PATH GEM_CACHE;}
|
187
|
-
end
|
188
|
-
args.join(" ")
|
205
|
+
def prepare_validation_pem
|
206
|
+
info("Preparing validation.pem")
|
207
|
+
debug("Using a dummy validation.pem")
|
208
|
+
|
209
|
+
source = File.join(File.dirname(__FILE__),
|
210
|
+
%w[.. .. .. support dummy-validation.pem])
|
211
|
+
FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
|
189
212
|
end
|
190
213
|
|
191
|
-
#
|
192
|
-
#
|
193
|
-
# require_chef_omnibus config variable.
|
194
|
-
#
|
195
|
-
# The only way this method returns false is if require_chef_omnibus has
|
196
|
-
# an explicit version set to less than 11.8.0, when chef zero mode was
|
197
|
-
# introduced. Otherwise a modern Chef installation is assumed.
|
214
|
+
# Returns the command that will run a backwards compatible shim script
|
215
|
+
# that approximates local mode in a modern chef-client run.
|
198
216
|
#
|
199
|
-
# @return [
|
200
|
-
# supports local mode
|
217
|
+
# @return [String] the command string
|
201
218
|
# @api private
|
202
|
-
def
|
203
|
-
|
219
|
+
def shim_command
|
220
|
+
ruby = remote_path_join(config[:ruby_bindir], "ruby").
|
221
|
+
tap { |path| path.concat(".exe") if windows_os? }
|
222
|
+
shim = remote_path_join(config[:root_path], "chef-client-zero.rb")
|
204
223
|
|
205
|
-
|
206
|
-
when nil, false, true, "latest"
|
207
|
-
true
|
208
|
-
else
|
209
|
-
Gem::Version.new(version) >= Gem::Version.new("11.8.0") ? true : false
|
210
|
-
end
|
224
|
+
"#{chef_client_zero_env}\n#{sudo(ruby)} #{shim}"
|
211
225
|
end
|
212
226
|
end
|
213
227
|
end
|
@@ -22,7 +22,54 @@ module Kitchen
|
|
22
22
|
|
23
23
|
module Provisioner
|
24
24
|
|
25
|
+
# Dummy provisioner for Kitchen. This driver does nothing but report what
|
26
|
+
# would happen if this provisioner did anything of consequence. As a result
|
27
|
+
# it may be a useful provisioner to use when debugging or developing new
|
28
|
+
# features or plugins.
|
29
|
+
#
|
30
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
25
31
|
class Dummy < Kitchen::Provisioner::Base
|
32
|
+
|
33
|
+
default_config :sleep, 0
|
34
|
+
default_config :random_failure, false
|
35
|
+
|
36
|
+
# (see Base#call)
|
37
|
+
def call(state)
|
38
|
+
info("[#{name}] Converge on instance=#{instance} with state=#{state}")
|
39
|
+
sleep_if_set
|
40
|
+
failure_if_set
|
41
|
+
debug("[#{name}] Converge completed (#{config[:sleep]}s).")
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# Sleep for a period of time, if a value is set in the config.
|
47
|
+
#
|
48
|
+
# @api private
|
49
|
+
def sleep_if_set
|
50
|
+
sleep(config[:sleep].to_f) if config[:sleep].to_f > 0.0
|
51
|
+
end
|
52
|
+
|
53
|
+
# Simulate a failure in an action, if set in the config.
|
54
|
+
#
|
55
|
+
# @api private
|
56
|
+
def failure_if_set
|
57
|
+
if config[:"fail"]
|
58
|
+
debug("Failure for Provisioner #{name}.")
|
59
|
+
raise ActionFailed, "Action #converge failed for #{instance.to_str}."
|
60
|
+
elsif config[:random_failure] && randomly_fail?
|
61
|
+
debug("Random failure for Provisioner #{name}.")
|
62
|
+
raise ActionFailed, "Action #converge failed for #{instance.to_str}."
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Determine whether or not to randomly fail.
|
67
|
+
#
|
68
|
+
# @return [true, false]
|
69
|
+
# @api private
|
70
|
+
def randomly_fail?
|
71
|
+
[true, false].sample
|
72
|
+
end
|
26
73
|
end
|
27
74
|
end
|
28
75
|
end
|
@@ -28,7 +28,8 @@ module Kitchen
|
|
28
28
|
class Shell < Base
|
29
29
|
|
30
30
|
default_config :script do |provisioner|
|
31
|
-
provisioner.
|
31
|
+
src = provisioner.powershell_shell? ? "bootstrap.ps1" : "bootstrap.sh"
|
32
|
+
provisioner.calculate_path(src, :type => :file)
|
32
33
|
end
|
33
34
|
expand_path_for :script
|
34
35
|
|
@@ -46,17 +47,37 @@ module Kitchen
|
|
46
47
|
|
47
48
|
# (see Base#init_command)
|
48
49
|
def init_command
|
49
|
-
|
50
|
-
|
50
|
+
root = config[:root_path]
|
51
|
+
data = remote_path_join(root, "data")
|
52
|
+
|
53
|
+
if powershell_shell?
|
54
|
+
Util.outdent!(<<-POWERSHELL)
|
55
|
+
if (Test-Path "#{data}") {
|
56
|
+
Remove-Item "#{data}" -Recurse -Force
|
57
|
+
}
|
58
|
+
if (-Not (Test-Path "#{root}")) {
|
59
|
+
New-Item "#{root}" -ItemType directory | Out-Null
|
60
|
+
}
|
61
|
+
POWERSHELL
|
62
|
+
else
|
63
|
+
cmd = "#{sudo("rm")} -rf #{data} ; mkdir -p #{root}"
|
51
64
|
|
52
|
-
|
65
|
+
Util.wrap_command(cmd)
|
66
|
+
end
|
53
67
|
end
|
54
68
|
|
55
69
|
# (see Base#run_command)
|
56
70
|
def run_command
|
57
|
-
|
58
|
-
|
71
|
+
script = remote_path_join(
|
72
|
+
config[:root_path],
|
73
|
+
File.basename(config[:script])
|
59
74
|
)
|
75
|
+
|
76
|
+
if powershell_shell?
|
77
|
+
%{& "#{script}"}
|
78
|
+
else
|
79
|
+
Util.wrap_command(sudo(script))
|
80
|
+
end
|
60
81
|
end
|
61
82
|
|
62
83
|
private
|
@@ -87,17 +108,29 @@ module Kitchen
|
|
87
108
|
debug("Using script from #{config[:script]}")
|
88
109
|
FileUtils.cp_r(config[:script], sandbox_path)
|
89
110
|
else
|
90
|
-
|
91
|
-
info("#{File.basename(config[:script])} not found " \
|
92
|
-
"so Kitchen will run a stubbed script. Is this intended?")
|
93
|
-
File.open(config[:script], "wb") do |file|
|
94
|
-
file.write(%{#!/bin/sh\necho "NO BOOTSTRAP SCRIPT PRESENT"\n})
|
95
|
-
end
|
111
|
+
prepare_stubbed_script
|
96
112
|
end
|
97
113
|
|
98
114
|
FileUtils.chmod(0755,
|
99
115
|
File.join(sandbox_path, File.basename(config[:script])))
|
100
116
|
end
|
117
|
+
|
118
|
+
# Creates a minimal, no-op script in the sandbox path.
|
119
|
+
#
|
120
|
+
# @api private
|
121
|
+
def prepare_stubbed_script
|
122
|
+
base = powershell_shell? ? "bootstrap.ps1" : "bootstrap.sh"
|
123
|
+
config[:script] = File.join(sandbox_path, base)
|
124
|
+
info("#{File.basename(config[:script])} not found " \
|
125
|
+
"so Kitchen will run a stubbed script. Is this intended?")
|
126
|
+
File.open(config[:script], "wb") do |file|
|
127
|
+
if powershell_shell?
|
128
|
+
file.write(%{Write-Host "NO BOOTSTRAP SCRIPT PRESENT`n"\n})
|
129
|
+
else
|
130
|
+
file.write(%{#!/bin/sh\necho "NO BOOTSTRAP SCRIPT PRESENT"\n})
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
101
134
|
end
|
102
135
|
end
|
103
136
|
end
|
data/lib/kitchen/rake_tasks.rb
CHANGED
@@ -32,7 +32,7 @@ module Kitchen
|
|
32
32
|
# @yield [self] gives itself to the block
|
33
33
|
def initialize
|
34
34
|
@config = Kitchen::Config.new
|
35
|
-
Kitchen.logger = Kitchen.default_file_logger
|
35
|
+
Kitchen.logger = Kitchen.default_file_logger(nil, false)
|
36
36
|
yield self if block_given?
|
37
37
|
define
|
38
38
|
end
|