chef 19.1.164 → 19.2.12
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 +1 -1
- data/Rakefile +10 -0
- data/chef.gemspec +1 -1
- data/lib/chef/provider/package/chocolatey.rb +78 -19
- data/lib/chef/provider/package/rubygems.rb +25 -2
- data/lib/chef/resource/chef_client_hab_ca_cert.rb +1 -1
- data/lib/chef/resource/chocolatey_installer.rb +1 -1
- data/lib/chef/resource/helpers/path_helpers.rb +5 -3
- data/lib/chef/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a348124039267c43844767273ea5e8727b35d92b641fc3e6690885947277b543
|
|
4
|
+
data.tar.gz: f85cdbe7468884cd9c80d2775a8e30ead5c2102b451bcd1d778e13b2090ceae0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 523e235dfa63d0f7ba8de9aee74606e13e9795e04ce18893c11298a1b1c2d08d23c03f7e8f3c0c30e297330740abaab6a74fac58b1d0338dec1f8abacecebedd
|
|
7
|
+
data.tar.gz: f7eb3b68c618206e5ba488e7eeca347f316e2e5098338eeaebeb06e37b4a37291190a5b98170006daf000f48c21c17aa4ed3c961bd478c6910d9f2de3e73534f
|
data/Gemfile
CHANGED
|
@@ -35,7 +35,7 @@ end
|
|
|
35
35
|
group(:omnibus_package) do
|
|
36
36
|
gem "appbundler"
|
|
37
37
|
gem "rb-readline"
|
|
38
|
-
gem "inspec-core-bin", "= 7.0.
|
|
38
|
+
gem "inspec-core-bin", "= 7.0.107" # need to provide the binaries for inspec
|
|
39
39
|
gem "chef-vault"
|
|
40
40
|
end
|
|
41
41
|
|
data/Rakefile
CHANGED
|
@@ -114,3 +114,13 @@ task :style do
|
|
|
114
114
|
rescue LoadError
|
|
115
115
|
puts "Rubocop or Cookstyle gems are not installed. bundle install first to make sure all dependencies are installed."
|
|
116
116
|
end
|
|
117
|
+
|
|
118
|
+
# begin
|
|
119
|
+
# require "chefstyle"
|
|
120
|
+
# require "rubocop/rake_task"
|
|
121
|
+
# RuboCop::RakeTask.new(:style) do |task|
|
|
122
|
+
# task.options += ["--display-cop-names", "--no-color"]
|
|
123
|
+
# end
|
|
124
|
+
# rescue LoadError
|
|
125
|
+
# puts "chefstyle/rubocop is not available. bundle install first to make sure all dependencies are installed."
|
|
126
|
+
# end
|
data/chef.gemspec
CHANGED
|
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
|
|
|
44
44
|
s.add_dependency "mixlib-shellout", "~> 3.3.8"
|
|
45
45
|
s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
|
|
46
46
|
s.add_dependency "ohai", "~> 19.0"
|
|
47
|
-
s.add_dependency "inspec-core", "~> 7.0.
|
|
47
|
+
s.add_dependency "inspec-core", "~> 7.0.107"
|
|
48
48
|
|
|
49
49
|
s.add_dependency "ffi", ">= 1.15.5", "< 1.18.0"
|
|
50
50
|
s.add_dependency "ffi-yajl", "~> 2.2"
|
|
@@ -257,7 +257,8 @@ class Chef
|
|
|
257
257
|
@choco_install_path ||= begin
|
|
258
258
|
result = powershell_exec!(PATHFINDING_POWERSHELL_COMMAND).result
|
|
259
259
|
result = "" if result.empty?
|
|
260
|
-
|
|
260
|
+
# Ensure consistent Windows path separators
|
|
261
|
+
result.empty? ? result : result.tr("/", "\\")
|
|
261
262
|
end
|
|
262
263
|
end
|
|
263
264
|
|
|
@@ -459,8 +460,10 @@ class Chef
|
|
|
459
460
|
def get_local_pkg_dirs(base_dir)
|
|
460
461
|
return [] unless Dir.exist?(base_dir)
|
|
461
462
|
|
|
462
|
-
|
|
463
|
-
|
|
463
|
+
with_file_lock_retry("reading chocolatey package directories") do
|
|
464
|
+
Dir.entries(base_dir).select do |dir|
|
|
465
|
+
::File.directory?(::File.join(base_dir, dir)) && !dir.start_with?(".")
|
|
466
|
+
end
|
|
464
467
|
end
|
|
465
468
|
end
|
|
466
469
|
|
|
@@ -496,6 +499,60 @@ class Chef
|
|
|
496
499
|
args
|
|
497
500
|
end
|
|
498
501
|
|
|
502
|
+
# Wait for chocolatey to release file locks after package operations
|
|
503
|
+
# @param names [Array<String>] package names that were just installed/upgraded
|
|
504
|
+
def wait_for_chocolatey_lock_release(names)
|
|
505
|
+
return if names.empty?
|
|
506
|
+
|
|
507
|
+
Chef::Log.debug("Waiting for chocolatey to release file locks for packages: #{names.join(", ")}")
|
|
508
|
+
|
|
509
|
+
# Check for .chocolateyPending files and wait for them to be released
|
|
510
|
+
names.each do |name|
|
|
511
|
+
pending_file = ::File.join(choco_lib_path, name.downcase, ".chocolateyPending")
|
|
512
|
+
if ::File.exist?(pending_file)
|
|
513
|
+
with_file_lock_retry("waiting for .chocolateyPending file release: #{pending_file}") do
|
|
514
|
+
# Try to open the file exclusively - this will fail if it's locked
|
|
515
|
+
::File.open(pending_file, "r") do |f|
|
|
516
|
+
f.flock(::File::LOCK_EX | ::File::LOCK_NB) or raise Errno::EAGAIN
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
# Retry file operations that might encounter chocolatey process file locks
|
|
524
|
+
# @param operation_desc [String] description of the operation for logging
|
|
525
|
+
# @param max_retries [Integer] maximum number of retry attempts
|
|
526
|
+
# @param base_delay [Float] base delay between retries in seconds
|
|
527
|
+
def with_file_lock_retry(operation_desc, max_retries: 5, base_delay: 0.5)
|
|
528
|
+
retries = 0
|
|
529
|
+
begin
|
|
530
|
+
yield
|
|
531
|
+
rescue Errno::EACCES, Errno::EBUSY, Errno::EAGAIN, Errno::ENOENT => e
|
|
532
|
+
if retries < max_retries && file_lock_error?(e)
|
|
533
|
+
retries += 1
|
|
534
|
+
delay = base_delay * (2**(retries - 1)) # exponential backoff
|
|
535
|
+
Chef::Log.debug("Chocolatey file lock detected during #{operation_desc}, retrying in #{delay}s (attempt #{retries}/#{max_retries}): #{e.message}")
|
|
536
|
+
sleep(delay)
|
|
537
|
+
retry
|
|
538
|
+
else
|
|
539
|
+
Chef::Log.warn("Failed #{operation_desc} after #{retries} retries: #{e.message}")
|
|
540
|
+
raise e
|
|
541
|
+
end
|
|
542
|
+
end
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
# Check if the error is related to file locking by chocolatey processes
|
|
546
|
+
# @param error [Exception] the exception to check
|
|
547
|
+
# @return [Boolean] true if it's a chocolatey file lock related error
|
|
548
|
+
def file_lock_error?(error)
|
|
549
|
+
error.message&.include?("being used by another process") ||
|
|
550
|
+
error.message&.include?("chocolateyPending") ||
|
|
551
|
+
error.is_a?(Errno::EACCES) ||
|
|
552
|
+
error.is_a?(Errno::EBUSY) ||
|
|
553
|
+
error.is_a?(Errno::EAGAIN)
|
|
554
|
+
end
|
|
555
|
+
|
|
499
556
|
# Fetch the local package versions from chocolatey
|
|
500
557
|
def fetch_package_versions(base_dir, target_dirs, targets)
|
|
501
558
|
pkg_versions = {}
|
|
@@ -511,25 +568,27 @@ class Chef
|
|
|
511
568
|
# Grab the locally installed packages from the nupkg list
|
|
512
569
|
# rather than shelling out to chocolatey
|
|
513
570
|
def get_pkg_data(path)
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
571
|
+
with_file_lock_retry("get package data for #{path}") do
|
|
572
|
+
t = ::File.join(path, "*.nupkg")
|
|
573
|
+
targets = Dir.glob(t)
|
|
574
|
+
|
|
575
|
+
# Extract package version from the first nuspec file in this nupkg
|
|
576
|
+
targets.each do |target|
|
|
577
|
+
Zip::File.open(target) do |zip_file|
|
|
578
|
+
zip_file.each do |entry|
|
|
579
|
+
next unless entry.name.end_with?(".nuspec")
|
|
580
|
+
|
|
581
|
+
f = entry.get_input_stream
|
|
582
|
+
doc = REXML::Document.new(f.read.to_s)
|
|
583
|
+
f.close
|
|
584
|
+
id = doc.elements["package/metadata/id"]
|
|
585
|
+
version = doc.elements["package/metadata/version"]
|
|
586
|
+
return { id.text.to_s.downcase => version.text } if id && version
|
|
587
|
+
end
|
|
529
588
|
end
|
|
530
589
|
end
|
|
590
|
+
{}
|
|
531
591
|
end
|
|
532
|
-
{}
|
|
533
592
|
rescue StandardError => e
|
|
534
593
|
Chef::Log.warn("Failed to get package info for #{path}: #{e}")
|
|
535
594
|
{}
|
|
@@ -391,6 +391,8 @@ class Chef
|
|
|
391
391
|
cmd = "#{@gem_binary_location} list #{gem_dependency.name} --remote --all #{source_args}"
|
|
392
392
|
result = shell_out!(cmd)
|
|
393
393
|
|
|
394
|
+
target_platforms = nil
|
|
395
|
+
|
|
394
396
|
versions = []
|
|
395
397
|
result.stdout.each_line do |line|
|
|
396
398
|
next unless line.start_with?("#{gem_dependency.name} (")
|
|
@@ -399,10 +401,31 @@ class Chef
|
|
|
399
401
|
next unless version_string
|
|
400
402
|
|
|
401
403
|
version_string.split(/,\s*/).each do |v|
|
|
402
|
-
|
|
404
|
+
# `gem list --remote --all` emits entries like "1.6.0 x86_64-linux".
|
|
405
|
+
# Accept platform-specific tokens only when the platform is compatible
|
|
406
|
+
# with the target gem environment; pure-Ruby tokens have no suffix and
|
|
407
|
+
# are always accepted.
|
|
408
|
+
version_token, *platform_tokens = v.strip.split(/\s+/)
|
|
409
|
+
|
|
410
|
+
if platform_tokens.any?
|
|
411
|
+
target_platforms ||= gem_platforms
|
|
412
|
+
# Each comma-separated entry from `gem list --remote --all` can list
|
|
413
|
+
# multiple platforms for one version: "1.5.9 ruby x86_64-linux aarch64-linux ...".
|
|
414
|
+
# Accept if any listed platform is "ruby" (pure-Ruby) or matches the target env.
|
|
415
|
+
compatible = platform_tokens.any? do |pt|
|
|
416
|
+
pt == "ruby" || target_platforms.any? do |p|
|
|
417
|
+
Gem::Platform.new(p) === Gem::Platform.new(pt)
|
|
418
|
+
rescue ArgumentError
|
|
419
|
+
false
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
next unless compatible
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
version = Gem::Version.new(version_token)
|
|
403
426
|
versions << version if gem_dependency.requirement.satisfied_by?(version)
|
|
404
427
|
rescue ArgumentError
|
|
405
|
-
# Skip invalid
|
|
428
|
+
# Skip tokens with invalid version strings.
|
|
406
429
|
end
|
|
407
430
|
end
|
|
408
431
|
|
|
@@ -23,9 +23,11 @@ class Chef
|
|
|
23
23
|
bin = File.basename(path)
|
|
24
24
|
|
|
25
25
|
# On Windows, temporarily use the c:\\hab\\bin\\*.bat binstubs
|
|
26
|
-
bat_path = "C:\\hab\\bin\\#{
|
|
26
|
+
bat_path = "C:\\hab\\bin\\#{ChefUtils::Dist::Infra::CLIENT}.bat"
|
|
27
27
|
return bat_path if File.exist?(bat_path) && ChefUtils.windows?
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
# return path for any bin/chef-* names
|
|
30
|
+
return path.sub(bin, ChefUtils::Dist::Infra::CLIENT) if bin =~ /^chef-[a-z-]+$/
|
|
29
31
|
|
|
30
32
|
# Return empty string if no valid path is found
|
|
31
33
|
""
|
|
@@ -37,7 +39,7 @@ class Chef
|
|
|
37
39
|
path = File.realpath($PROGRAM_NAME)
|
|
38
40
|
bin = File.basename(path)
|
|
39
41
|
|
|
40
|
-
return path
|
|
42
|
+
return path.sub(bin, ChefUtils::Dist::Infra::CLIENT) if bin =~ /^chef-[a-z-]+$/
|
|
41
43
|
|
|
42
44
|
# Return empty string if no valid path is found
|
|
43
45
|
""
|
data/lib/chef/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chef
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 19.
|
|
4
|
+
version: 19.2.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Jacob
|
|
@@ -15,28 +15,28 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 19.
|
|
18
|
+
version: 19.2.12
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 19.
|
|
25
|
+
version: 19.2.12
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: chef-utils
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - '='
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 19.
|
|
32
|
+
version: 19.2.12
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - '='
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 19.
|
|
39
|
+
version: 19.2.12
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: train-core
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -219,14 +219,14 @@ dependencies:
|
|
|
219
219
|
requirements:
|
|
220
220
|
- - "~>"
|
|
221
221
|
- !ruby/object:Gem::Version
|
|
222
|
-
version: 7.0.
|
|
222
|
+
version: 7.0.107
|
|
223
223
|
type: :runtime
|
|
224
224
|
prerelease: false
|
|
225
225
|
version_requirements: !ruby/object:Gem::Requirement
|
|
226
226
|
requirements:
|
|
227
227
|
- - "~>"
|
|
228
228
|
- !ruby/object:Gem::Version
|
|
229
|
-
version: 7.0.
|
|
229
|
+
version: 7.0.107
|
|
230
230
|
- !ruby/object:Gem::Dependency
|
|
231
231
|
name: ffi
|
|
232
232
|
requirement: !ruby/object:Gem::Requirement
|