chef 18.7.10-universal-mingw-ucrt → 18.8.9-universal-mingw-ucrt
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 +4 -3
- data/Rakefile +1 -0
- data/chef.gemspec +10 -2
- data/lib/chef/cookbook_version.rb +34 -0
- data/lib/chef/http/basic_client.rb +1 -0
- data/lib/chef/http.rb +1 -0
- data/lib/chef/provider/package/apt.rb +1 -1
- data/lib/chef/provider/package/bff.rb +5 -0
- data/lib/chef/provider/package/cab.rb +9 -0
- data/lib/chef/provider/package/chocolatey.rb +6 -1
- data/lib/chef/provider/package/deb.rb +1 -1
- data/lib/chef/provider/package/dnf.rb +3 -3
- data/lib/chef/provider/package/habitat.rb +9 -0
- data/lib/chef/provider/package/homebrew.rb +9 -0
- data/lib/chef/provider/package/ips.rb +5 -0
- data/lib/chef/provider/package/macports.rb +9 -0
- data/lib/chef/provider/package/msu.rb +9 -0
- data/lib/chef/provider/package/openbsd.rb +7 -2
- data/lib/chef/provider/package/pacman.rb +9 -0
- data/lib/chef/provider/package/paludis.rb +9 -0
- data/lib/chef/provider/package/portage.rb +9 -0
- data/lib/chef/provider/package/powershell.rb +6 -1
- data/lib/chef/provider/package/rpm.rb +3 -3
- data/lib/chef/provider/package/rubygems.rb +9 -0
- data/lib/chef/provider/package/smartos.rb +9 -0
- data/lib/chef/provider/package/snap.rb +6 -1
- data/lib/chef/provider/package/solaris.rb +5 -0
- data/lib/chef/provider/package/windows.rb +5 -0
- data/lib/chef/provider/package/yum.rb +3 -3
- data/lib/chef/provider/package/zypper.rb +5 -0
- data/lib/chef/recipe.rb +20 -0
- data/lib/chef/resource/apt_package.rb +5 -0
- data/lib/chef/resource/apt_repository.rb +44 -27
- data/lib/chef/resource/archive_file.rb +49 -2
- data/lib/chef/resource/dnf_package.rb +5 -0
- data/lib/chef/resource/dpkg_package.rb +5 -0
- data/lib/chef/resource/ohai.rb +10 -0
- data/lib/chef/resource/package.rb +5 -0
- data/lib/chef/resource/rpm_package.rb +5 -0
- data/lib/chef/resource/yum_package.rb +5 -0
- data/lib/chef/shell.rb +13 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/version.rb +2 -1
- data/spec/functional/resource/git_spec.rb +2 -1
- data/spec/integration/client/open_ssl_spec.rb +7 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/cookbook_version_spec.rb +39 -0
- data/spec/unit/node/attribute_spec.rb +1 -1
- data/spec/unit/provider/apt_repository_spec.rb +85 -8
- data/spec/unit/provider/package/rpm_spec.rb +10 -10
- data/spec/unit/recipe_spec.rb +51 -0
- data/spec/unit/resource/apt_package_spec.rb +5 -0
- data/spec/unit/resource/dnf_package_spec.rb +6 -0
- data/spec/unit/resource/ohai_spec.rb +73 -0
- data/spec/unit/resource/yum_package_spec.rb +9 -0
- data/spec/unit/resource_reporter_spec.rb +0 -58
- data/spec/unit/shell_spec.rb +31 -11
- data/tasks/rspec.rb +1 -1
- metadata +42 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab2cc0700322ba6f0f6da1dc9087aa567e34a256d1f6b36aa5a8238aa431fdc4
|
4
|
+
data.tar.gz: daf19fef61ca71f7fda162e234d5c2332cc5ee5f8d2b283e6a7f98c750759324
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d3b1b2023b5dfb9bf8631e93b8ca0811425f72c71942acc8696511441c449cd9216bab9b0d73c23e121c52d945838ec2b437dcb30e9712aea49a19eae596081
|
7
|
+
data.tar.gz: '0821e20a19a1905594bd7ad4bfff584c3d488480ca77d2a38332d88a275efa35dde2a9b813d4d8ce6f27c18f8b06ff47f7667ac41b0b7c4ac5c8b955ae67a304'
|
data/Gemfile
CHANGED
@@ -13,7 +13,7 @@ gem "chef-config", path: File.expand_path("chef-config", __dir__) if File.exist?
|
|
13
13
|
|
14
14
|
# required for FIPS or bundler will pick up default openssl
|
15
15
|
install_if -> { RUBY_PLATFORM !~ /darwin/ } do
|
16
|
-
gem "openssl", "= 3.
|
16
|
+
gem "openssl", "= 3.3.0"
|
17
17
|
end
|
18
18
|
|
19
19
|
if File.exist?(File.expand_path("chef-bin", __dir__))
|
@@ -29,8 +29,9 @@ gem "cheffish", ">= 17"
|
|
29
29
|
group(:omnibus_package) do
|
30
30
|
gem "appbundler"
|
31
31
|
gem "rb-readline"
|
32
|
-
gem "inspec-core-bin", ">= 5", "< 6" # need to provide the binaries for inspec
|
33
32
|
gem "chef-vault"
|
33
|
+
|
34
|
+
gem "inspec-core-bin", ">= 5", "< 6"
|
34
35
|
end
|
35
36
|
|
36
37
|
group(:omnibus_package, :pry) do
|
@@ -44,7 +45,7 @@ end
|
|
44
45
|
|
45
46
|
# Everything except AIX and Windows
|
46
47
|
group(:ruby_shadow) do
|
47
|
-
install_if -> {
|
48
|
+
install_if -> { RUBY_PLATFORM.match?(/linux|darwin|bsd|solaris/i) } do
|
48
49
|
# if ruby-shadow does a release that supports ruby-3.0 this can be removed
|
49
50
|
gem "ruby-shadow", git: "https://github.com/chef/ruby-shadow", branch: "lcg/ruby-3.0", platforms: :ruby
|
50
51
|
end
|
data/Rakefile
CHANGED
@@ -25,6 +25,7 @@ begin
|
|
25
25
|
require_relative "tasks/dependencies"
|
26
26
|
require_relative "tasks/docs"
|
27
27
|
require_relative "tasks/spellcheck"
|
28
|
+
require_relative "tasks/bundle"
|
28
29
|
require_relative "chef-utils/lib/chef-utils/dist" unless defined?(ChefUtils::Dist)
|
29
30
|
rescue LoadError => e
|
30
31
|
puts "Skipping missing rake dep: #{e}"
|
data/chef.gemspec
CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.required_ruby_version = ">= 3.1.0"
|
32
32
|
end
|
33
33
|
|
34
|
+
s.add_dependency "activesupport", ">= 4.2.7.1", "<= 7.1.3.2"
|
34
35
|
s.add_dependency "chef-config", "= #{Chef::VERSION}"
|
35
36
|
s.add_dependency "chef-utils", "= #{Chef::VERSION}"
|
36
37
|
s.add_dependency "train-core", "~> 3.10", "<= 3.12.13"
|
@@ -44,7 +45,13 @@ Gem::Specification.new do |s|
|
|
44
45
|
s.add_dependency "mixlib-shellout", ">= 3.1.1", "< 4.0"
|
45
46
|
s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
|
46
47
|
s.add_dependency "ohai", "~> 18.0"
|
47
|
-
|
48
|
+
|
49
|
+
# AIX Gemfile.aix.lock uses this, but currently a manual process
|
50
|
+
if RUBY_PLATFORM.include?("aix") || ENV["GENERATE_AIX"] == "true"
|
51
|
+
s.add_dependency "inspec-core", ">= 5", "<= 5.22.80"
|
52
|
+
else
|
53
|
+
s.add_dependency "inspec-core", ">= 5", "< 6"
|
54
|
+
end
|
48
55
|
|
49
56
|
s.add_dependency "ffi", ">= 1.15.5", "<= 1.16.3"
|
50
57
|
s.add_dependency "ffi-yajl", "~> 2.2"
|
@@ -53,7 +60,7 @@ Gem::Specification.new do |s|
|
|
53
60
|
s.add_dependency "erubis", "~> 2.7" # template resource / cookbook syntax check
|
54
61
|
s.add_dependency "diff-lcs", ">= 1.2.4", "!= 1.4.0", "< 1.6.0" # 1.4 breaks output. Used in lib/chef/util/diff
|
55
62
|
s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3" # archive_file resource
|
56
|
-
s.add_dependency "chef-zero", ">= 15.0.
|
63
|
+
s.add_dependency "chef-zero", ">= 15.0.21"
|
57
64
|
s.add_dependency "chef-vault" # chef-vault resources and helpers
|
58
65
|
|
59
66
|
s.add_dependency "plist", "~> 3.2" # launchd, dscl/mac user, macos_userdefaults, osx_profile and plist resources
|
@@ -62,6 +69,7 @@ Gem::Specification.new do |s|
|
|
62
69
|
s.add_dependency "syslog-logger", "~> 1.6"
|
63
70
|
s.add_dependency "uuidtools", ">= 2.1.5", "< 3.0" # osx_profile resource
|
64
71
|
s.add_dependency "unf_ext", "~> 0.0.8.2" # older platforms
|
72
|
+
s.add_dependency "uri", "~> 1.0.3" # This is used by net-http. We are forcing a version to get past a CVE in 1.0.2
|
65
73
|
s.add_dependency "corefoundation", "~> 0.3.4" # macos_userdefaults resource
|
66
74
|
|
67
75
|
s.add_dependency "proxifier2", "~> 1.1"
|
@@ -152,6 +152,20 @@ class Chef
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
+
def recipe_json_filenames_by_name
|
156
|
+
@recipe_json_filenames_by_name ||= begin
|
157
|
+
name_map = json_filenames_by_name(files_for("recipes"))
|
158
|
+
root_alias = cookbook_manifest.root_files.find { |record|
|
159
|
+
record[:name] == "root_files/recipe.json"
|
160
|
+
}
|
161
|
+
if root_alias
|
162
|
+
Chef::Log.error("Cookbook #{name} contains both recipe.json and recipes/default.json, ignoring recipes/default.json") if name_map["default"]
|
163
|
+
name_map["default"] = root_alias[:full_path]
|
164
|
+
end
|
165
|
+
name_map
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
155
169
|
def recipe_filenames_by_name
|
156
170
|
@recipe_filenames_by_name ||= begin
|
157
171
|
name_map = filenames_by_name(files_for("recipes"))
|
@@ -203,11 +217,26 @@ class Chef
|
|
203
217
|
load_ruby_recipe(recipe_name, run_context)
|
204
218
|
elsif recipe_yml_filenames_by_name.key?(recipe_name)
|
205
219
|
load_yml_recipe(recipe_name, run_context)
|
220
|
+
elsif recipe_json_filenames_by_name.key?(recipe_name)
|
221
|
+
load_json_recipe(recipe_name, run_context)
|
206
222
|
else
|
207
223
|
raise Chef::Exceptions::RecipeNotFound, "could not find recipe #{recipe_name} for cookbook #{name}"
|
208
224
|
end
|
209
225
|
end
|
210
226
|
|
227
|
+
def load_json_recipe(recipe_name, run_context)
|
228
|
+
Chef::Log.trace("Found recipe #{recipe_name} in cookbook #{name}")
|
229
|
+
recipe = Chef::Recipe.new(name, recipe_name, run_context)
|
230
|
+
recipe_filename = recipe_json_filenames_by_name[recipe_name]
|
231
|
+
|
232
|
+
unless recipe_filename
|
233
|
+
raise Chef::Exceptions::RecipeNotFound, "could not find #{recipe_name} files for cookbook #{name}"
|
234
|
+
end
|
235
|
+
|
236
|
+
recipe.from_json_file(recipe_filename)
|
237
|
+
recipe
|
238
|
+
end
|
239
|
+
|
211
240
|
def load_yml_recipe(recipe_name, run_context)
|
212
241
|
Chef::Log.trace("Found recipe #{recipe_name} in cookbook #{name}")
|
213
242
|
recipe = Chef::Recipe.new(name, recipe_name, run_context)
|
@@ -608,6 +637,11 @@ class Chef
|
|
608
637
|
result
|
609
638
|
end
|
610
639
|
|
640
|
+
# Filters JSON files from the superset of provided files.
|
641
|
+
def json_filenames_by_name(records)
|
642
|
+
records.select { |record| record[:name].end_with?(".json") }.inject({}) { |memo, record| memo[File.basename(record[:name], ".json")] = record[:full_path]; memo }
|
643
|
+
end
|
644
|
+
|
611
645
|
def file_vendor
|
612
646
|
@file_vendor ||= Chef::Cookbook::FileVendor.create_from_manifest(cookbook_manifest)
|
613
647
|
end
|
data/lib/chef/http.rb
CHANGED
@@ -46,7 +46,7 @@ class Chef
|
|
46
46
|
|
47
47
|
requirements.assert(:all_actions) do |a|
|
48
48
|
a.assertion { !new_resource.source }
|
49
|
-
a.failure_message
|
49
|
+
a.failure_message Chef::Exceptions::Package, "apt package provider cannot handle source property. Use dpkg provider instead"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -41,6 +41,11 @@ class Chef
|
|
41
41
|
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
|
42
42
|
a.whyrun "would assume #{new_resource.source} would be have previously been made available"
|
43
43
|
end
|
44
|
+
|
45
|
+
requirements.assert(:all_actions) do |a|
|
46
|
+
a.assertion { !new_resource.environment }
|
47
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
48
|
+
end
|
44
49
|
end
|
45
50
|
|
46
51
|
def load_current_resource
|
@@ -41,6 +41,15 @@ class Chef
|
|
41
41
|
current_resource
|
42
42
|
end
|
43
43
|
|
44
|
+
def define_resource_requirements
|
45
|
+
super
|
46
|
+
|
47
|
+
requirements.assert(:all_actions) do |a|
|
48
|
+
a.assertion { !new_resource.environment }
|
49
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
def cab_file_source
|
45
54
|
@cab_file_source ||= uri_scheme?(new_resource.source) ? download_source_file : new_resource.source
|
46
55
|
end
|
@@ -71,9 +71,14 @@ class Chef
|
|
71
71
|
# so we want to assert candidates exist for the alternate source
|
72
72
|
requirements.assert(:upgrade, :install) do |a|
|
73
73
|
a.assertion { candidates_exist_for_all_uninstalled? }
|
74
|
-
a.failure_message
|
74
|
+
a.failure_message Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}"
|
75
75
|
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
|
76
76
|
end
|
77
|
+
|
78
|
+
requirements.assert(:all_actions) do |a|
|
79
|
+
a.assertion { !new_resource.environment }
|
80
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
81
|
+
end
|
77
82
|
end
|
78
83
|
|
79
84
|
# Lazy initializer for candidate_version. A nil value means that there is no candidate
|
@@ -111,7 +111,7 @@ class Chef
|
|
111
111
|
# Runs command via shell_out with magic environment to disable
|
112
112
|
# interactive prompts.
|
113
113
|
def run_noninteractive(*command)
|
114
|
-
shell_out!(*command, env: { "DEBIAN_FRONTEND" => "noninteractive" })
|
114
|
+
shell_out!(*command, env: { "DEBIAN_FRONTEND" => "noninteractive" }.merge(new_resource.environment))
|
115
115
|
end
|
116
116
|
|
117
117
|
private
|
@@ -83,13 +83,13 @@ class Chef
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def define_resource_requirements
|
86
|
+
super
|
87
|
+
|
86
88
|
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
|
87
89
|
a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
|
88
90
|
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
|
89
91
|
a.whyrun "assuming #{new_resource.source} would have previously been created"
|
90
92
|
end
|
91
|
-
|
92
|
-
super
|
93
93
|
end
|
94
94
|
|
95
95
|
def candidate_version
|
@@ -250,7 +250,7 @@ class Chef
|
|
250
250
|
end
|
251
251
|
|
252
252
|
def dnf(*args)
|
253
|
-
shell_out!("dnf", *args)
|
253
|
+
shell_out!("dnf", *args, env: new_resource.environment)
|
254
254
|
end
|
255
255
|
|
256
256
|
def safe_version_array
|
@@ -39,6 +39,15 @@ class Chef
|
|
39
39
|
current_resource
|
40
40
|
end
|
41
41
|
|
42
|
+
def define_resource_requirements
|
43
|
+
super
|
44
|
+
|
45
|
+
requirements.assert(:all_actions) do |a|
|
46
|
+
a.assertion { !new_resource.environment }
|
47
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
42
51
|
def install_package(names, versions)
|
43
52
|
names.zip(versions).map do |n, v|
|
44
53
|
opts = ["pkg", "install", "--channel", new_resource.channel, "--url", new_resource.bldr_url]
|
@@ -41,6 +41,15 @@ class Chef
|
|
41
41
|
current_resource
|
42
42
|
end
|
43
43
|
|
44
|
+
def define_resource_requirements
|
45
|
+
super
|
46
|
+
|
47
|
+
requirements.assert(:all_actions) do |a|
|
48
|
+
a.assertion { !new_resource.environment }
|
49
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
def candidate_version
|
45
54
|
package_name_array.map do |package_name|
|
46
55
|
available_version(package_name)
|
@@ -39,6 +39,11 @@ class Chef
|
|
39
39
|
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found"
|
40
40
|
a.whyrun "Assuming package #{new_resource.package_name} would have been made available."
|
41
41
|
end
|
42
|
+
|
43
|
+
requirements.assert(:all_actions) do |a|
|
44
|
+
a.assertion { !new_resource.environment }
|
45
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
46
|
+
end
|
42
47
|
end
|
43
48
|
|
44
49
|
def get_current_version
|
@@ -22,6 +22,15 @@ class Chef
|
|
22
22
|
current_resource
|
23
23
|
end
|
24
24
|
|
25
|
+
def define_resource_requirements
|
26
|
+
super
|
27
|
+
|
28
|
+
requirements.assert(:all_actions) do |a|
|
29
|
+
a.assertion { !new_resource.environment }
|
30
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
25
34
|
def current_installed_version
|
26
35
|
command = [ "port", "installed", new_resource.package_name ]
|
27
36
|
output = get_response_from_command(command)
|
@@ -59,6 +59,15 @@ class Chef
|
|
59
59
|
current_resource
|
60
60
|
end
|
61
61
|
|
62
|
+
def define_resource_requirements
|
63
|
+
super
|
64
|
+
|
65
|
+
requirements.assert(:all_actions) do |a|
|
66
|
+
a.assertion { !new_resource.environment }
|
67
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
62
71
|
def get_current_versions
|
63
72
|
@cab_files.map do |cabfile|
|
64
73
|
cab_pkg = get_cab_package(cabfile)
|
@@ -53,7 +53,7 @@ class Chef
|
|
53
53
|
# Below are incomplete/missing features for this package provider
|
54
54
|
requirements.assert(:all_actions) do |a|
|
55
55
|
a.assertion { !new_resource.source }
|
56
|
-
a.failure_message
|
56
|
+
a.failure_message Chef::Exceptions::Package, "The openbsd package provider does not support the source property"
|
57
57
|
end
|
58
58
|
requirements.assert(:all_actions) do |a|
|
59
59
|
a.assertion do
|
@@ -63,7 +63,12 @@ class Chef
|
|
63
63
|
true
|
64
64
|
end
|
65
65
|
end
|
66
|
-
a.failure_message
|
66
|
+
a.failure_message Chef::Exceptions::Package, "The openbsd package provider does not support providing a version and flavor"
|
67
|
+
end
|
68
|
+
|
69
|
+
requirements.assert(:all_actions) do |a|
|
70
|
+
a.assertion { !new_resource.environment }
|
71
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
67
72
|
end
|
68
73
|
end
|
69
74
|
|
@@ -68,6 +68,15 @@ class Chef
|
|
68
68
|
current_resource
|
69
69
|
end
|
70
70
|
|
71
|
+
def define_resource_requirements
|
72
|
+
super
|
73
|
+
|
74
|
+
requirements.assert(:all_actions) do |a|
|
75
|
+
a.assertion { !new_resource.environment }
|
76
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
71
80
|
def candidate_version
|
72
81
|
@candidate_version
|
73
82
|
end
|
@@ -53,6 +53,15 @@ class Chef
|
|
53
53
|
current_resource
|
54
54
|
end
|
55
55
|
|
56
|
+
def define_resource_requirements
|
57
|
+
super
|
58
|
+
|
59
|
+
requirements.assert(:all_actions) do |a|
|
60
|
+
a.assertion { !new_resource.environment }
|
61
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
56
65
|
def install_package(name, version)
|
57
66
|
pkg = if version
|
58
67
|
"=#{name}-#{version}"
|
@@ -59,6 +59,15 @@ class Chef
|
|
59
59
|
current_resource
|
60
60
|
end
|
61
61
|
|
62
|
+
def define_resource_requirements
|
63
|
+
super
|
64
|
+
|
65
|
+
requirements.assert(:all_actions) do |a|
|
66
|
+
a.assertion { !new_resource.environment }
|
67
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
62
71
|
def raise_error_for_query(msg)
|
63
72
|
raise Chef::Exceptions::Package, "Query for '#{new_resource.package_name}' #{msg}"
|
64
73
|
end
|
@@ -42,9 +42,14 @@ class Chef
|
|
42
42
|
|
43
43
|
requirements.assert(:install) do |a|
|
44
44
|
a.assertion { candidates_exist_for_all_uninstalled? }
|
45
|
-
a.failure_message
|
45
|
+
a.failure_message Chef::Exceptions::Package, "No candidate version available for #{packages_missing_candidates.join(", ")}"
|
46
46
|
a.whyrun("Assuming a repository that offers #{packages_missing_candidates.join(", ")} would have been configured")
|
47
47
|
end
|
48
|
+
|
49
|
+
requirements.assert(:all_actions) do |a|
|
50
|
+
a.assertion { !new_resource.environment }
|
51
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
52
|
+
end
|
48
53
|
end
|
49
54
|
|
50
55
|
def candidate_version
|
@@ -88,12 +88,12 @@ class Chef
|
|
88
88
|
def install_package(name, version)
|
89
89
|
if current_resource.version
|
90
90
|
if allow_downgrade
|
91
|
-
shell_out!("rpm", options, "-U", "--oldpackage", new_resource.source)
|
91
|
+
shell_out!("rpm", options, "-U", "--oldpackage", new_resource.source, env: new_resource.environment)
|
92
92
|
else
|
93
|
-
shell_out!("rpm", options, "-U", new_resource.source)
|
93
|
+
shell_out!("rpm", options, "-U", new_resource.source, env: new_resource.environment)
|
94
94
|
end
|
95
95
|
else
|
96
|
-
shell_out!("rpm", options, "-i", new_resource.source)
|
96
|
+
shell_out!("rpm", options, "-i", new_resource.source, env: new_resource.environment)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -515,6 +515,15 @@ class Chef
|
|
515
515
|
current_resource
|
516
516
|
end
|
517
517
|
|
518
|
+
def define_resource_requirements
|
519
|
+
super
|
520
|
+
|
521
|
+
requirements.assert(:all_actions) do |a|
|
522
|
+
a.assertion { !new_resource.environment }
|
523
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
518
527
|
def cleanup_after_converge
|
519
528
|
if @cleanup_gem_env
|
520
529
|
logger.trace { "#{new_resource} resetting gem environment to default" }
|
@@ -40,6 +40,15 @@ class Chef
|
|
40
40
|
current_resource # modified by check_package_state
|
41
41
|
end
|
42
42
|
|
43
|
+
def define_resource_requirements
|
44
|
+
super
|
45
|
+
|
46
|
+
requirements.assert(:all_actions) do |a|
|
47
|
+
a.assertion { !new_resource.environment }
|
48
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
43
52
|
def check_package_state(name)
|
44
53
|
logger.trace("#{new_resource} checking package #{name}")
|
45
54
|
version = nil
|
@@ -41,13 +41,18 @@ class Chef
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def define_resource_requirements
|
44
|
+
super
|
45
|
+
|
44
46
|
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
|
45
47
|
a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
|
46
48
|
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
|
47
49
|
a.whyrun "assuming #{new_resource.source} would have previously been created"
|
48
50
|
end
|
49
51
|
|
50
|
-
|
52
|
+
requirements.assert(:all_actions) do |a|
|
53
|
+
a.assertion { !new_resource.environment }
|
54
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
55
|
+
end
|
51
56
|
end
|
52
57
|
|
53
58
|
def candidate_version
|
@@ -43,6 +43,11 @@ class Chef
|
|
43
43
|
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
|
44
44
|
a.whyrun "would assume #{new_resource.source} would be have previously been made available"
|
45
45
|
end
|
46
|
+
|
47
|
+
requirements.assert(:all_actions) do |a|
|
48
|
+
a.assertion { !new_resource.environment }
|
49
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
50
|
+
end
|
46
51
|
end
|
47
52
|
|
48
53
|
def load_current_resource
|
@@ -55,6 +55,11 @@ class Chef
|
|
55
55
|
a.whyrun "Assuming source file #{new_resource.source} would have been created."
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
requirements.assert(:all_actions) do |a|
|
60
|
+
a.assertion { !new_resource.environment }
|
61
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
62
|
+
end
|
58
63
|
end
|
59
64
|
|
60
65
|
def load_current_resource
|
@@ -76,13 +76,13 @@ class Chef
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def define_resource_requirements
|
79
|
+
super
|
80
|
+
|
79
81
|
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
|
80
82
|
a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
|
81
83
|
a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
|
82
84
|
a.whyrun "assuming #{new_resource.source} would have previously been created"
|
83
85
|
end
|
84
|
-
|
85
|
-
super
|
86
86
|
end
|
87
87
|
|
88
88
|
def candidate_version
|
@@ -277,7 +277,7 @@ class Chef
|
|
277
277
|
end
|
278
278
|
|
279
279
|
def yum(*args)
|
280
|
-
shell_out!(yum_binary, *args)
|
280
|
+
shell_out!(yum_binary, *args, env: new_resource.environment)
|
281
281
|
end
|
282
282
|
|
283
283
|
def safe_version_array
|
@@ -40,6 +40,11 @@ class Chef
|
|
40
40
|
a.failure_message Chef::Exceptions::Package, "#{new_resource} source file(s) do not exist: #{missing_sources}"
|
41
41
|
a.whyrun "Assuming they would have been previously created."
|
42
42
|
end
|
43
|
+
|
44
|
+
requirements.assert(:all_actions) do |a|
|
45
|
+
a.assertion { !new_resource.environment }
|
46
|
+
a.failure_message Chef::Exceptions::Package, "The environment property is not supported for package resources on this platform"
|
47
|
+
end
|
43
48
|
end
|
44
49
|
|
45
50
|
def load_current_resource
|
data/lib/chef/recipe.rb
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
autoload :YAML, "yaml"
|
21
|
+
require_relative "json_compat"
|
21
22
|
require_relative "dsl/recipe"
|
22
23
|
require_relative "mixin/from_file"
|
23
24
|
require_relative "mixin/deprecation"
|
@@ -101,6 +102,25 @@ class Chef
|
|
101
102
|
from_hash(res)
|
102
103
|
end
|
103
104
|
|
105
|
+
def from_json_file(filename)
|
106
|
+
self.source_file = filename
|
107
|
+
if File.file?(filename) && File.readable?(filename)
|
108
|
+
json_contents = IO.read(filename)
|
109
|
+
from_json(json_contents)
|
110
|
+
else
|
111
|
+
raise IOError, "Cannot open or read file '#{filename}'!"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def from_json(string)
|
116
|
+
res = JSONCompat.from_json(string)
|
117
|
+
unless res.is_a?(Hash) && res.key?("resources")
|
118
|
+
raise ArgumentError, "JSON recipe '#{source_file}' must contain a top-level 'resources' hash"
|
119
|
+
end
|
120
|
+
|
121
|
+
from_hash(res)
|
122
|
+
end
|
123
|
+
|
104
124
|
def from_hash(hash)
|
105
125
|
hash["resources"].each do |rhash|
|
106
126
|
type = rhash.delete("type").to_sym
|
@@ -94,6 +94,11 @@ class Chef
|
|
94
94
|
introduced: "18.3",
|
95
95
|
description: "A Boolean flag that indicates whether the package name, which can be a regular expression, must match the entire name of the package (true) or if the regular expression is allowed to match a subset of the name (false).",
|
96
96
|
default: false
|
97
|
+
|
98
|
+
property :environment, Hash,
|
99
|
+
introduced: "18.8",
|
100
|
+
description: "A Hash of environment variables in the form of {'ENV_VARIABLE' => 'VALUE'} to be set before running the command.",
|
101
|
+
default: {}, desired_state: false
|
97
102
|
end
|
98
103
|
end
|
99
104
|
end
|