chef-apply 0.1.18 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e4309991a02465e139c4ac2da82cf3bc9acfa164b564fa7428b80cc7122d6f4
4
- data.tar.gz: c60806b1eb3ad8e93fe66b7821b5545ca407db5acecd167cbb3e5ad07d7086e4
3
+ metadata.gz: 8086d987312367597bbad62738f67c8b8595b44b62514e1b4e1c8526ef417c72
4
+ data.tar.gz: 9bab05e2fa8aeb213a120cb26bb8e822025f0a339cffced136dde7a38a8bc142
5
5
  SHA512:
6
- metadata.gz: d281858ffdf9616b2cba493e364ae4d3f938abd227f9a012d5e13d5bbaa0f8433a1ea2ddf9c795fb83b85e57b97c2fee10403bce1eac6b98daaf34c7f5cfae67
7
- data.tar.gz: bf94d6c3ce3834c207ef83ac887a808a2fd26f7fbfaa5d6ca5438a7f7b119bc402755cc93feac477e66a5b2379760b0726aaff50c434b8f3fdf7eeb4b4c31013
6
+ metadata.gz: b3e55c36d4fe20ae7e91a47332380d65fc70956c9d97d2edb602130c72889d91bad321faddd0316f26882b83e81a6edbd8fed62c1bc0333265bd9b984286279a
7
+ data.tar.gz: 3a07a9aa07e46c6aca8e49bab6b4e4e856173b9187c049f89154d411ea2f26da96d59d88604b0aab227527a3f80d5757527758cb409f4a0e4d3a77ab1a4edc5d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chef-apply (0.1.18)
4
+ chef-apply (0.1.21)
5
5
  chef (>= 14.0)
6
6
  chef-dk (>= 3.0)
7
7
  chef-telemetry
@@ -21,16 +21,16 @@ GEM
21
21
  addressable (2.5.2)
22
22
  public_suffix (>= 2.0.2, < 4.0)
23
23
  ast (2.4.0)
24
- aws-sdk (2.11.97)
25
- aws-sdk-resources (= 2.11.97)
26
- aws-sdk-core (2.11.97)
24
+ aws-sdk (2.11.104)
25
+ aws-sdk-resources (= 2.11.104)
26
+ aws-sdk-core (2.11.104)
27
27
  aws-sigv4 (~> 1.0)
28
28
  jmespath (~> 1.0)
29
- aws-sdk-resources (2.11.97)
30
- aws-sdk-core (= 2.11.97)
29
+ aws-sdk-resources (2.11.104)
30
+ aws-sdk-core (= 2.11.104)
31
31
  aws-sigv4 (1.0.3)
32
- azure_mgmt_resources (0.16.0)
33
- ms_rest_azure (~> 0.10.0)
32
+ azure_mgmt_resources (0.17.0)
33
+ ms_rest_azure (~> 0.11.0)
34
34
  binding_of_caller (0.8.0)
35
35
  debug_inspector (>= 0.0.1)
36
36
  builder (3.2.3)
@@ -119,7 +119,6 @@ GEM
119
119
  declarative (0.0.10)
120
120
  declarative-option (0.1.0)
121
121
  diff-lcs (1.3)
122
- digest-crc (0.4.1)
123
122
  docile (1.3.1)
124
123
  docker-api (1.34.2)
125
124
  excon (>= 0.47.0)
@@ -145,134 +144,13 @@ GEM
145
144
  mime-types (~> 3.0)
146
145
  representable (~> 3.0)
147
146
  retriable (>= 2.0, < 4.0)
148
- google-cloud (0.51.1)
149
- google-cloud-bigquery (~> 1.1)
150
- google-cloud-bigquery-data_transfer (~> 0.1)
151
- google-cloud-container (~> 0.1)
152
- google-cloud-dataproc (~> 0.1)
153
- google-cloud-datastore (~> 1.4)
154
- google-cloud-dlp (~> 0.1)
155
- google-cloud-dns (~> 0.28)
156
- google-cloud-error_reporting (~> 0.30)
157
- google-cloud-firestore (~> 0.21)
158
- google-cloud-language (~> 0.30)
159
- google-cloud-logging (~> 1.5)
160
- google-cloud-monitoring (~> 0.27)
161
- google-cloud-os_login (~> 0.1)
162
- google-cloud-pubsub (~> 0.30)
163
- google-cloud-resource_manager (~> 0.29)
164
- google-cloud-spanner (~> 1.3)
165
- google-cloud-speech (~> 0.29)
166
- google-cloud-storage (~> 1.10)
167
- google-cloud-trace (~> 0.31)
168
- google-cloud-translate (~> 1.2)
169
- google-cloud-video_intelligence (~> 1.0)
170
- google-cloud-vision (~> 0.28)
171
- google-cloud-bigquery (1.5.0)
172
- concurrent-ruby (~> 1.0)
173
- google-api-client (~> 0.19.8)
174
- google-cloud-core (~> 1.2)
175
- googleauth (~> 0.6.2)
176
- google-cloud-bigquery-data_transfer (0.1.0)
177
- google-gax (~> 1.0)
178
- google-cloud-container (0.1.0)
179
- google-gax (~> 1.0.1)
180
- google-cloud-core (1.2.2)
181
- google-cloud-env (~> 1.0)
182
- google-cloud-dataproc (0.1.0)
183
- google-gax (~> 1.0.0)
184
- google-cloud-datastore (1.4.0)
185
- google-cloud-core (~> 1.2)
186
- google-gax (~> 1.0)
187
- google-protobuf (~> 3.3)
188
- google-cloud-dlp (0.4.0)
189
- google-gax (~> 1.0)
190
- google-cloud-dns (0.28.0)
191
- google-api-client (~> 0.19.0)
192
- google-cloud-core (~> 1.2)
193
- googleauth (~> 0.6.2)
194
- zonefile (~> 1.04)
195
- google-cloud-env (1.0.2)
196
- faraday (~> 0.11)
197
- google-cloud-error_reporting (0.30.1)
198
- google-cloud-core (~> 1.2)
199
- google-gax (~> 1.0)
200
- stackdriver-core (~> 1.3)
201
- google-cloud-firestore (0.22.0)
202
- concurrent-ruby (~> 1.0)
203
- google-cloud-core (~> 1.2)
204
- google-gax (~> 1.0)
205
- google-cloud-language (0.30.0)
206
- google-gax (~> 1.0)
207
- google-cloud-logging (1.5.1)
208
- google-cloud-core (~> 1.2)
209
- google-gax (~> 1.0)
210
- stackdriver-core (~> 1.3)
211
- google-cloud-monitoring (0.28.0)
212
- google-gax (~> 1.0)
213
- google-cloud-os_login (0.1.0)
214
- google-gax (~> 1.0.0)
215
- google-cloud-pubsub (0.31.0)
216
- concurrent-ruby (~> 1.0)
217
- google-cloud-core (~> 1.2)
218
- google-gax (~> 1.0)
219
- grpc-google-iam-v1 (~> 0.6.9)
220
- google-cloud-resource_manager (0.29.0)
221
- google-api-client (~> 0.19.8)
222
- google-cloud-core (~> 1.2)
223
- googleauth (~> 0.6.2)
224
- google-cloud-spanner (1.6.0)
225
- concurrent-ruby (~> 1.0)
226
- google-cloud-core (~> 1.2)
227
- google-gax (~> 1.0)
228
- grpc-google-iam-v1 (~> 0.6.9)
229
- google-cloud-speech (0.30.0)
230
- google-gax (~> 1.0)
231
- google-cloud-storage (1.12.0)
232
- digest-crc (~> 0.4)
233
- google-api-client (~> 0.19.0)
234
- google-cloud-core (~> 1.2)
235
- googleauth (~> 0.6.2)
236
- google-cloud-trace (0.33.1)
237
- google-cloud-core (~> 1.2)
238
- google-gax (~> 1.0)
239
- stackdriver-core (~> 1.3)
240
- google-cloud-translate (1.2.0)
241
- faraday (~> 0.13)
242
- google-cloud-core (~> 1.2)
243
- googleauth (~> 0.6.2)
244
- google-cloud-video_intelligence (1.0.0)
245
- google-gax (~> 1.0)
246
- google-cloud-vision (0.29.0)
247
- google-cloud-core (~> 1.2)
248
- google-gax (~> 1.0)
249
- google-gax (1.0.1)
250
- google-protobuf (~> 3.2)
251
- googleapis-common-protos (>= 1.3.5, < 2.0)
252
- googleauth (~> 0.6.2)
253
- grpc (>= 1.7.2, < 2.0)
254
- rly (~> 0.2.3)
255
- google-protobuf (3.6.0)
256
- googleapis-common-protos (1.3.7)
257
- google-protobuf (~> 3.0)
258
- googleapis-common-protos-types (~> 1.0)
259
- grpc (~> 1.0)
260
- googleapis-common-protos-types (1.0.1)
261
- google-protobuf (~> 3.0)
262
- googleauth (0.6.2)
147
+ googleauth (0.6.4)
263
148
  faraday (~> 0.12)
264
149
  jwt (>= 1.4, < 3.0)
265
- logging (~> 2.0)
266
150
  memoist (~> 0.12)
267
151
  multi_json (~> 1.11)
268
- os (~> 0.9)
152
+ os (>= 0.9, < 2.0)
269
153
  signet (~> 0.7)
270
- grpc (1.13.0)
271
- google-protobuf (~> 3.1)
272
- googleapis-common-protos-types (~> 1.0.0)
273
- grpc-google-iam-v1 (0.6.9)
274
- googleapis-common-protos (>= 1.3.1, < 2.0)
275
- grpc (~> 1.0)
276
154
  gssapi (1.2.0)
277
155
  ffi (>= 1.0.1)
278
156
  gyoku (1.3.1)
@@ -307,25 +185,25 @@ GEM
307
185
  mime-types-data (~> 3.2015)
308
186
  mime-types-data (3.2016.0521)
309
187
  minitar (0.6.1)
310
- mixlib-archive (0.4.8)
188
+ mixlib-archive (0.4.13)
311
189
  mixlib-log
312
190
  mixlib-authentication (2.1.1)
313
191
  mixlib-cli (1.7.0)
314
192
  mixlib-config (2.2.13)
315
193
  tomlrb
316
- mixlib-install (3.11.2)
194
+ mixlib-install (3.11.5)
317
195
  mixlib-shellout
318
196
  mixlib-versioning
319
197
  thor
320
198
  mixlib-log (2.0.4)
321
199
  mixlib-shellout (2.4.0)
322
200
  mixlib-versioning (1.2.2)
323
- molinillo (0.6.5)
201
+ molinillo (0.6.6)
324
202
  ms_rest (0.7.2)
325
203
  concurrent-ruby (~> 1.0)
326
204
  faraday (~> 0.9)
327
205
  timeliness (~> 0.3)
328
- ms_rest_azure (0.10.8)
206
+ ms_rest_azure (0.11.0)
329
207
  concurrent-ruby (~> 1.0)
330
208
  faraday (~> 0.9)
331
209
  faraday-cookie_jar (~> 0.0.6)
@@ -344,19 +222,19 @@ GEM
344
222
  net-ssh-gateway (>= 1.2.0)
345
223
  net-telnet (0.2.0)
346
224
  nori (2.6.0)
347
- ohai (14.3.0)
225
+ ohai (14.4.0)
348
226
  chef-config (>= 12.8, < 15)
349
227
  ffi (~> 1.9)
350
228
  ffi-yajl (~> 2.2)
351
229
  ipaddress
352
- mixlib-cli
230
+ mixlib-cli (>= 1.7.0)
353
231
  mixlib-config (~> 2.0)
354
232
  mixlib-log (~> 2.0, >= 2.0.1)
355
233
  mixlib-shellout (~> 2.0)
356
234
  plist (~> 3.1)
357
235
  systemu (~> 2.6.4)
358
236
  wmi-lite (~> 1.0)
359
- os (0.9.6)
237
+ os (1.0.0)
360
238
  paint (1.0.1)
361
239
  parallel (1.12.1)
362
240
  parser (2.5.1.2)
@@ -388,23 +266,22 @@ GEM
388
266
  declarative-option (< 0.2.0)
389
267
  uber (< 0.2.0)
390
268
  retriable (3.1.2)
391
- rly (0.2.3)
392
- rspec (3.7.0)
393
- rspec-core (~> 3.7.0)
394
- rspec-expectations (~> 3.7.0)
395
- rspec-mocks (~> 3.7.0)
396
- rspec-core (3.7.1)
397
- rspec-support (~> 3.7.0)
398
- rspec-expectations (3.7.0)
269
+ rspec (3.8.0)
270
+ rspec-core (~> 3.8.0)
271
+ rspec-expectations (~> 3.8.0)
272
+ rspec-mocks (~> 3.8.0)
273
+ rspec-core (3.8.0)
274
+ rspec-support (~> 3.8.0)
275
+ rspec-expectations (3.8.1)
399
276
  diff-lcs (>= 1.2.0, < 2.0)
400
- rspec-support (~> 3.7.0)
277
+ rspec-support (~> 3.8.0)
401
278
  rspec-its (1.2.0)
402
279
  rspec-core (>= 3.0.0)
403
280
  rspec-expectations (>= 3.0.0)
404
- rspec-mocks (3.7.0)
281
+ rspec-mocks (3.8.0)
405
282
  diff-lcs (>= 1.2.0, < 2.0)
406
- rspec-support (~> 3.7.0)
407
- rspec-support (3.7.1)
283
+ rspec-support (~> 3.8.0)
284
+ rspec-support (3.8.0)
408
285
  rspec_junit_formatter (0.2.3)
409
286
  builder (< 4)
410
287
  rspec-core (>= 2, < 4, != 2.12.0)
@@ -438,13 +315,11 @@ GEM
438
315
  solve (4.0.0)
439
316
  molinillo (~> 0.6)
440
317
  semverse (>= 1.1, < 3.0)
441
- specinfra (2.75.0)
318
+ specinfra (2.75.1)
442
319
  net-scp
443
320
  net-ssh (>= 2.7)
444
321
  net-telnet
445
322
  sfl
446
- stackdriver-core (1.3.0)
447
- google-cloud-core (~> 1.2)
448
323
  syslog-logger (1.6.8)
449
324
  systemu (2.6.5)
450
325
  thor (0.20.0)
@@ -452,12 +327,11 @@ GEM
452
327
  toml-rb (1.1.1)
453
328
  citrus (~> 3.0, > 3.0)
454
329
  tomlrb (1.2.7)
455
- train (1.4.24)
330
+ train (1.4.25)
456
331
  aws-sdk (~> 2)
457
332
  azure_mgmt_resources (~> 0.15)
458
333
  docker-api (~> 1.26)
459
334
  google-api-client (~> 0.19.8)
460
- google-cloud (~> 0.51.1)
461
335
  googleauth (~> 0.6.2)
462
336
  inifile
463
337
  json (>= 1.8, < 3.0)
@@ -494,7 +368,6 @@ GEM
494
368
  rubyzip (~> 1.1)
495
369
  winrm (~> 2.0)
496
370
  wmi-lite (1.0.0)
497
- zonefile (1.06)
498
371
 
499
372
  PLATFORMS
500
373
  ruby
@@ -512,4 +385,4 @@ DEPENDENCIES
512
385
  simplecov
513
386
 
514
387
  BUNDLED WITH
515
- 1.16.2
388
+ 1.16.3
@@ -88,19 +88,19 @@ module ChefApply
88
88
  # Chef 13 on Linux requires full path specifiers for --config and --recipe-url while on Chef 13 and 14 on
89
89
  # Windows must use relative specifiers to prevent URI from causing an error
90
90
  # (https://github.com/chef/chef/pull/7223/files).
91
- def run_chef(working_dir, config, policy)
91
+ def run_chef(working_dir, config_file, policy)
92
92
  case family
93
93
  when :windows
94
94
  "Set-Location -Path #{working_dir}; " +
95
95
  # We must 'wait' for chef-client to finish before changing directories and Out-Null does that
96
- "chef-client -z --config #{config} --recipe-url #{policy} | Out-Null; " +
96
+ "chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)} | Out-Null; " +
97
97
  # We have to leave working dir so we don't hold a lock on it, which allows us to delete this tempdir later
98
98
  "Set-Location C:/; " +
99
99
  "exit $LASTEXITCODE"
100
100
  else
101
101
  # cd is shell a builtin, so much call bash. This also means all commands are executed
102
102
  # with sudo (as long as we are hardcoding our sudo use)
103
- "bash -c 'cd #{working_dir}; chef-client -z --config #{File.join(working_dir, config)} --recipe-url #{File.join(working_dir, policy)}'"
103
+ "bash -c 'cd #{working_dir}; chef-client -z --config #{File.join(working_dir, config_file)} --recipe-url #{File.join(working_dir, policy)}'"
104
104
  end
105
105
  end
106
106
 
@@ -16,15 +16,14 @@
16
16
  #
17
17
 
18
18
  require "chef_apply/action/base"
19
+ require "chef_apply/minimum_chef_version"
19
20
  require "fileutils"
20
21
 
21
22
  module ChefApply::Action::InstallChef
22
23
  class Base < ChefApply::Action::Base
23
- MIN_14_VERSION = Gem::Version.new("14.1.1")
24
- MIN_13_VERSION = Gem::Version.new("13.10.0")
25
24
 
26
25
  def perform_action
27
- if check_minimum_chef_version!(target_host) == :minimum_version_met
26
+ if ChefApply::MinimumChefVersion.check!(target_host, config[:check_only]) == :minimum_version_met
28
27
  notify(:already_installed)
29
28
  else
30
29
  perform_local_install
@@ -107,31 +106,6 @@ module ChefApply::Action::InstallChef
107
106
  remote_path
108
107
  end
109
108
 
110
- def check_minimum_chef_version!(target)
111
- begin
112
- installed_version = target.installed_chef_version
113
- rescue ChefApply::TargetHost::ChefNotInstalled
114
- if config[:check_only]
115
- raise ClientNotInstalled.new()
116
- end
117
- return :client_not_installed
118
- end
119
-
120
- case
121
- when installed_version >= Gem::Version.new("14.0.0") && installed_version < MIN_14_VERSION
122
- raise Client14Outdated.new(installed_version, MIN_14_VERSION)
123
- when installed_version >= Gem::Version.new("13.0.0") && installed_version < MIN_13_VERSION
124
- raise Client13Outdated.new(installed_version, MIN_13_VERSION, MIN_14_VERSION)
125
- when installed_version < Gem::Version.new("13.0.0")
126
- # If they have Chef < 13.0.0 installed we want to show them the easiest upgrade path -
127
- # Chef 13 first and then Chef 14 since most customers cannot make the leap directly
128
- # to 14.
129
- raise Client13Outdated.new(installed_version, MIN_13_VERSION, MIN_14_VERSION)
130
- end
131
-
132
- :minimum_version_met
133
- end
134
-
135
109
  def setup_remote_temp_path
136
110
  raise NotImplementedError
137
111
  end
@@ -140,20 +114,4 @@ module ChefApply::Action::InstallChef
140
114
  raise NotImplementedError
141
115
  end
142
116
  end
143
-
144
- class ClientNotInstalled < ChefApply::ErrorNoLogs
145
- def initialize(); super("CHEFINS002"); end
146
- end
147
-
148
- class Client13Outdated < ChefApply::ErrorNoLogs
149
- def initialize(current_version, min_13_version, min_14_version)
150
- super("CHEFINS003", current_version, min_13_version, min_14_version)
151
- end
152
- end
153
-
154
- class Client14Outdated < ChefApply::ErrorNoLogs
155
- def initialize(current_version, target_version)
156
- super("CHEFINS004", current_version, target_version)
157
- end
158
- end
159
117
  end
@@ -22,7 +22,6 @@ module ChefApply
22
22
  extend Mixlib::Log
23
23
 
24
24
  def self.setup(location, log_level)
25
- @location = location
26
25
  if location.is_a?(String)
27
26
  if location.casecmp("stdout") == 0
28
27
  location = $stdout
@@ -30,6 +29,7 @@ module ChefApply
30
29
  location = File.open(location, "w+")
31
30
  end
32
31
  end
32
+ @location = location
33
33
  init(location)
34
34
  Log.level = log_level
35
35
  end
@@ -0,0 +1,79 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2017 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
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.
16
+ #
17
+
18
+ require "chef_apply/error"
19
+
20
+ module ChefApply
21
+ class MinimumChefVersion
22
+
23
+ CONSTRAINTS = {
24
+ windows: {
25
+ 13 => Gem::Version.new("13.10.4"),
26
+ 14 => Gem::Version.new("14.4.22")
27
+ },
28
+ linux: {
29
+ 13 => Gem::Version.new("13.10.4"),
30
+ 14 => Gem::Version.new("14.1.1")
31
+ }
32
+ }
33
+
34
+ def self.check!(target, check_only)
35
+ begin
36
+ installed_version = target.installed_chef_version
37
+ rescue ChefApply::TargetHost::ChefNotInstalled
38
+ if check_only
39
+ raise ClientNotInstalled.new()
40
+ end
41
+ return :client_not_installed
42
+ end
43
+
44
+ os_constraints = CONSTRAINTS[target.base_os]
45
+ min_14_version = os_constraints[14]
46
+ min_13_version = os_constraints[13]
47
+
48
+ case
49
+ when installed_version >= Gem::Version.new("14.0.0") && installed_version < min_14_version
50
+ raise Client14Outdated.new(installed_version, min_14_version)
51
+ when installed_version >= Gem::Version.new("13.0.0") && installed_version < min_13_version
52
+ raise Client13Outdated.new(installed_version, min_13_version, min_14_version)
53
+ when installed_version < Gem::Version.new("13.0.0")
54
+ # If they have Chef < 13.0.0 installed we want to show them the easiest upgrade path -
55
+ # Chef 13 first and then Chef 14 since most customers cannot make the leap directly
56
+ # to 14.
57
+ raise Client13Outdated.new(installed_version, min_13_version, min_14_version)
58
+ end
59
+
60
+ :minimum_version_met
61
+ end
62
+
63
+ class ClientNotInstalled < ChefApply::ErrorNoLogs
64
+ def initialize(); super("CHEFINS002"); end
65
+ end
66
+
67
+ class Client13Outdated < ChefApply::ErrorNoLogs
68
+ def initialize(current_version, min_13_version, min_14_version)
69
+ super("CHEFINS003", current_version, min_13_version, min_14_version)
70
+ end
71
+ end
72
+
73
+ class Client14Outdated < ChefApply::ErrorNoLogs
74
+ def initialize(current_version, target_version)
75
+ super("CHEFINS004", current_version, target_version)
76
+ end
77
+ end
78
+ end
79
+ end
@@ -165,7 +165,7 @@ module ChefApply
165
165
  ChefConfig.logger = ChefApply::Log
166
166
  # Setting the config isn't enough, we need to ensure the logger is initialized
167
167
  # or automatic initialization will still go to stdout
168
- Chef::Log.init(ChefApply::Log)
168
+ Chef::Log.init(ChefApply::Log.location)
169
169
  Chef::Log.level = ChefApply::Log.level
170
170
  end
171
171
 
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefApply
19
- VERSION = "0.1.18"
19
+ VERSION = "0.1.21"
20
20
  end
@@ -70,7 +70,7 @@ RSpec.describe ChefApply::Action::Base do
70
70
  it "correctly returns chef run string" do
71
71
  expect(action.run_chef("a", "b", "c")).to eq(
72
72
  "Set-Location -Path a; " \
73
- "chef-client -z --config b --recipe-url c | Out-Null; " \
73
+ "chef-client -z --config #{File.join("a", "b")} --recipe-url #{File.join("a", "c")} | Out-Null; " \
74
74
  "Set-Location C:/; " \
75
75
  "exit $LASTEXITCODE"
76
76
  )
@@ -41,7 +41,8 @@ RSpec.describe ChefApply::Action::InstallChef::Base do
41
41
 
42
42
  subject(:install) do
43
43
  ChefApply::Action::InstallChef::Base.new(target_host: target_host,
44
- reporter: reporter) end
44
+ reporter: reporter,
45
+ check_only: false) end
45
46
  before do
46
47
  target_host.connect!
47
48
  target_host.backend.mock_os(mock_opts)
@@ -50,7 +51,7 @@ RSpec.describe ChefApply::Action::InstallChef::Base do
50
51
  context "#perform_action" do
51
52
  context "when chef is already installed on target" do
52
53
  it "notifies of success and takes no further action" do
53
- expect(install).to receive(:check_minimum_chef_version!).with(install.target_host)
54
+ expect(ChefApply::MinimumChefVersion).to receive(:check!).with(install.target_host, false)
54
55
  .and_return(:minimum_version_met)
55
56
  expect(install).not_to receive(:perform_local_install)
56
57
  install.perform_action
@@ -59,7 +60,7 @@ RSpec.describe ChefApply::Action::InstallChef::Base do
59
60
 
60
61
  context "when chef is not already installed on target" do
61
62
  it "should invoke perform_local_install" do
62
- expect(install).to receive(:check_minimum_chef_version!).with(install.target_host)
63
+ expect(ChefApply::MinimumChefVersion).to receive(:check!).with(install.target_host, false)
63
64
  .and_return(:client_not_installed)
64
65
  expect(install).to receive(:perform_local_install)
65
66
  install.perform_action
@@ -164,71 +165,4 @@ RSpec.describe ChefApply::Action::InstallChef::Base do
164
165
  end
165
166
  end
166
167
  end
167
-
168
- context "#check_minimum_chef_version!" do
169
- let(:target) { install.target_host }
170
- context "when chef is not already installed on target" do
171
- before do
172
- expect(target).to receive(:installed_chef_version).
173
- and_raise ChefApply::TargetHost::ChefNotInstalled.new
174
- end
175
-
176
- it "should return :client_not_installed" do
177
- actual = install.check_minimum_chef_version!(target)
178
- expect(:client_not_installed).to eq(actual)
179
- end
180
-
181
- context "when config is set to check_only" do
182
- after do
183
- install.config.clear
184
- end
185
-
186
- it "raises ClientNotInstalled" do
187
- install.config[:check_only] = true
188
- expect do
189
- install.check_minimum_chef_version!(target)
190
- end.to raise_error(ChefApply::Action::InstallChef::ClientNotInstalled)
191
- end
192
- end
193
- end
194
-
195
- min_14_version = ChefApply::Action::InstallChef::Base::MIN_14_VERSION
196
- min_13_version = ChefApply::Action::InstallChef::Base::MIN_13_VERSION
197
- context "when chef is already installed on target at the correct minimum Chef 14 version" do
198
- before do
199
- expect(target).to receive(:installed_chef_version).and_return min_14_version
200
- end
201
- it "should return :minimum_version_met" do
202
- actual = install.check_minimum_chef_version!(target)
203
- expect(:minimum_version_met).to eq(actual)
204
- end
205
- end
206
-
207
- context "when chef is already installed on target at the correct minimum Chef 13 version" do
208
- before do
209
- expect(target).to receive(:installed_chef_version).and_return min_13_version
210
- end
211
- it "should return :minimum_version_met" do
212
- actual = install.check_minimum_chef_version!(target)
213
- expect(:minimum_version_met).to eq(actual)
214
- end
215
- end
216
-
217
- installed_expected = {
218
- Gem::Version.new("12.1.1") => ChefApply::Action::InstallChef::Client13Outdated,
219
- Gem::Version.new("13.9.0") => ChefApply::Action::InstallChef::Client13Outdated,
220
- Gem::Version.new("14.1.0") => ChefApply::Action::InstallChef::Client14Outdated,
221
- }
222
- installed_expected.each do |installed, expected|
223
- context "when chef is already installed on target at version #{installed}" do
224
- before do
225
- expect(target).to receive(:installed_chef_version).
226
- and_return installed
227
- end
228
- it "notifies of failure and takes no further action" do
229
- expect { install.check_minimum_chef_version!(target) }.to raise_error(expected)
230
- end
231
- end
232
- end
233
- end
234
168
  end
@@ -0,0 +1,90 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2018 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
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.
16
+ #
17
+
18
+ require "chef_apply/minimum_chef_version"
19
+ require "chef_apply/target_host"
20
+ require "spec_helper"
21
+
22
+ RSpec.describe ChefApply::MinimumChefVersion do
23
+ let(:base_os) { :linux }
24
+ let(:version) { 14 }
25
+ let(:target) { instance_double(ChefApply::TargetHost, base_os: base_os, installed_chef_version: version) }
26
+ subject(:klass) { ChefApply::MinimumChefVersion }
27
+
28
+ context "#check!" do
29
+ context "when chef is not already installed on target" do
30
+ before do
31
+ expect(target).to receive(:installed_chef_version).
32
+ and_raise ChefApply::TargetHost::ChefNotInstalled.new
33
+ end
34
+
35
+ it "should return :client_not_installed" do
36
+ actual = klass.check!(target, false)
37
+ expect(:client_not_installed).to eq(actual)
38
+ end
39
+
40
+ context "when config is set to check_only" do
41
+ it "raises ClientNotInstalled" do
42
+ expect do
43
+ klass.check!(target, true)
44
+ end.to raise_error(ChefApply::MinimumChefVersion::ClientNotInstalled)
45
+ end
46
+ end
47
+ end
48
+
49
+ [:windows, :linux].each do |os|
50
+ context "on #{os}" do
51
+ let(:base_os) { os }
52
+ [13, 14].each do |major_version|
53
+ context "when chef is already installed at the correct minimum Chef #{major_version} version" do
54
+ let(:version) { ChefApply::MinimumChefVersion::CONSTRAINTS[os][major_version] }
55
+ it "should return :minimum_version_met" do
56
+ actual = klass.check!(target, false)
57
+ expect(:minimum_version_met).to eq(actual)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ installed_expected = {
65
+ windows: {
66
+ Gem::Version.new("12.1.1") => ChefApply::MinimumChefVersion::Client13Outdated,
67
+ Gem::Version.new("13.9.0") => ChefApply::MinimumChefVersion::Client13Outdated,
68
+ Gem::Version.new("14.3.37") => ChefApply::MinimumChefVersion::Client14Outdated,
69
+ },
70
+ linux: {
71
+ Gem::Version.new("12.1.1") => ChefApply::MinimumChefVersion::Client13Outdated,
72
+ Gem::Version.new("13.9.0") => ChefApply::MinimumChefVersion::Client13Outdated,
73
+ Gem::Version.new("14.1.0") => ChefApply::MinimumChefVersion::Client14Outdated,
74
+ }
75
+ }
76
+ [:windows, :linux].each do |os|
77
+ context "on #{os}" do
78
+ let(:base_os) { os }
79
+ installed_expected[os].each do |installed, expected|
80
+ context "when chef is already installed on target at version #{installed}" do
81
+ let(:version) { installed }
82
+ it "notifies of failure and takes no further action" do
83
+ expect { klass.check!(target, false) }.to raise_error(expected)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -265,7 +265,7 @@ RSpec.describe ChefApply::Startup do
265
265
  expect(ChefApply::Log).to receive(:setup).
266
266
  with(log_path, log_level)
267
267
  expect(Chef::Log).to receive(:init).
268
- with(ChefApply::Log)
268
+ with(ChefApply::Log.location)
269
269
  subject.setup_logging
270
270
  expect(ChefConfig.logger).to eq(ChefApply::Log)
271
271
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-apply
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-31 00:00:00.000000000 Z
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -341,6 +341,7 @@ files:
341
341
  - lib/chef_apply/errors/standard_error_resolver.rb
342
342
  - lib/chef_apply/file_fetcher.rb
343
343
  - lib/chef_apply/log.rb
344
+ - lib/chef_apply/minimum_chef_version.rb
344
345
  - lib/chef_apply/recipe_lookup.rb
345
346
  - lib/chef_apply/startup.rb
346
347
  - lib/chef_apply/status_reporter.rb
@@ -377,6 +378,7 @@ files:
377
378
  - spec/unit/file_fetcher_spec.rb
378
379
  - spec/unit/fixtures/multi-error.out
379
380
  - spec/unit/log_spec.rb
381
+ - spec/unit/minimum_chef_version_spec.rb
380
382
  - spec/unit/recipe_lookup_spec.rb
381
383
  - spec/unit/startup_spec.rb
382
384
  - spec/unit/target_host_spec.rb