chef 17.8.25-universal-mingw32 → 17.9.46-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/README.md +1 -1
- data/lib/chef/application/exit_code.rb +7 -21
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
- data/lib/chef/compliance/input_collection.rb +1 -1
- data/lib/chef/compliance/waiver_collection.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/provider/cron.rb +2 -2
- data/lib/chef/provider/directory.rb +2 -2
- data/lib/chef/provider/ifconfig.rb +5 -5
- data/lib/chef/provider/package/yum/python_helper.rb +81 -25
- data/lib/chef/provider/package/yum.rb +39 -12
- data/lib/chef/provider/package.rb +5 -5
- data/lib/chef/provider/user/mac.rb +3 -3
- data/lib/chef/provider.rb +4 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource/apt_package.rb +2 -2
- data/lib/chef/resource/archive_file.rb +6 -6
- data/lib/chef/resource/chef_client_config.rb +2 -3
- data/lib/chef/resource/chocolatey_package.rb +3 -3
- data/lib/chef/resource/cron/cron.rb +75 -1
- data/lib/chef/resource/cron/cron_d.rb +2 -1
- data/lib/chef/resource/habitat/habitat_sup.rb +1 -1
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +1 -5
- data/lib/chef/resource/inspec_waiver_file_entry.rb +1 -1
- data/lib/chef/resource/launchd.rb +2 -2
- data/lib/chef/resource/lwrp_base.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +8 -8
- data/lib/chef/resource/remote_file.rb +1 -1
- data/lib/chef/resource/rhsm_register.rb +3 -3
- data/lib/chef/resource/windows_feature_powershell.rb +1 -2
- data/lib/chef/resource/windows_task.rb +25 -10
- data/lib/chef/resource.rb +2 -2
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/run_lock.rb +1 -1
- data/lib/chef/secret_fetcher/azure_key_vault.rb +4 -2
- data/lib/chef/secret_fetcher/hashi_vault.rb +37 -3
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/archive_file_spec.rb +3 -2
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dnf_package_spec.rb +107 -107
- data/spec/functional/resource/dsc_script_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/resource/yum_package_spec.rb +789 -129
- data/spec/integration/client/client_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -5
- data/spec/support/platform_helpers.rb +1 -1
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +2 -2
- data/spec/support/shared/functional/http.rb +9 -9
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +1 -1
- data/spec/unit/dsl/registry_helper_spec.rb +6 -6
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +2 -2
- data/spec/unit/provider/dsc_script_spec.rb +8 -8
- data/spec/unit/provider/group/usermod_spec.rb +2 -2
- data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
- data/spec/unit/provider/ifconfig/debian_spec.rb +1 -1
- data/spec/unit/provider/ifconfig/redhat_spec.rb +1 -1
- data/spec/unit/provider/ifconfig_spec.rb +3 -3
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_service_spec.rb +2 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
- data/spec/unit/provider/user/solaris_spec.rb +1 -1
- data/spec/unit/resource/archive_file_spec.rb +1 -2
- data/spec/unit/resource/conditional_spec.rb +4 -4
- data/spec/unit/resource_spec.rb +2 -2
- data/spec/unit/secret_fetcher/hashi_vault_spec.rb +46 -0
- metadata +6 -8
- data/lib/chef/provider/group/suse.rb +0 -82
- data/spec/unit/provider/group/suse_spec.rb +0 -90
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfcbcbe5a0ad79eff9aa99eb671a0fd4c707f5a92c110321523d0b538a28e2be
|
4
|
+
data.tar.gz: 4789457137f4c223ce82b8eec0ebd8cae9f3ab123abd6aac701da97cc317db3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1faf50263931d7aa589efe6f764f91d7e1f593ea00216749ecaecd4f7971c60e70f84cf4fb9f2ffaa8699f56f8869c5227b7502afb6328d4fe67b673a52e2864
|
7
|
+
data.tar.gz: 0deb78dd1339a331f3bf6770f21aca77617da19aeff8a77854cf0cd15c531fe16ffd505383a53f5e3212bf8b372fea3f83adedb93e1f639852c96e4aeab0fdac
|
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gem "chef", path: "."
|
4
4
|
|
5
|
-
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "
|
5
|
+
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "17-stable"
|
6
6
|
|
7
7
|
gem "chef-utils", path: File.expand_path("chef-utils", __dir__) if File.exist?(File.expand_path("chef-utils", __dir__))
|
8
8
|
gem "chef-config", path: File.expand_path("chef-config", __dir__) if File.exist?(File.expand_path("chef-config", __dir__))
|
@@ -15,7 +15,7 @@ else
|
|
15
15
|
gem "chef-bin" # rubocop:disable Bundler/DuplicatedGem
|
16
16
|
end
|
17
17
|
|
18
|
-
gem "cheffish", "
|
18
|
+
gem "cheffish", "~> 17.0"
|
19
19
|
|
20
20
|
group(:omnibus_package) do
|
21
21
|
gem "appbundler"
|
@@ -29,7 +29,7 @@ group(:omnibus_package, :pry) do
|
|
29
29
|
# some work is ongoing? https://github.com/deivid-rodriguez/pry-byebug/issues/343
|
30
30
|
gem "pry", "= 0.13.0"
|
31
31
|
# byebug does not install on freebsd on ruby 3.0
|
32
|
-
gem "pry-byebug" unless RUBY_PLATFORM
|
32
|
+
gem "pry-byebug" unless RUBY_PLATFORM.match?(/freebsd/i)
|
33
33
|
gem "pry-stack_explorer"
|
34
34
|
end
|
35
35
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Chef Infra
|
2
2
|
[![Code Climate](https://codeclimate.com/github/chef/chef.svg)](https://codeclimate.com/github/chef/chef)
|
3
|
-
[![Build Status](https://badge.buildkite.com/c82093430ceec7d27af05febb9dcafe3aa331fff9d74c0ab9d.svg?branch=
|
3
|
+
[![Build Status](https://badge.buildkite.com/c82093430ceec7d27af05febb9dcafe3aa331fff9d74c0ab9d.svg?branch=chef-17)](https://buildkite.com/chef-oss/chef-chef-chef-17-verify)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef)
|
5
5
|
[![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef/blob/master/docs/dev/design_documents/client_release_cadence.md)
|
6
6
|
|
@@ -90,45 +90,31 @@ class Chef
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def reboot_scheduled?(exception)
|
93
|
-
resolve_exception_array(exception).any?
|
94
|
-
e.is_a? Chef::Exceptions::Reboot
|
95
|
-
end
|
93
|
+
resolve_exception_array(exception).any?(Chef::Exceptions::Reboot)
|
96
94
|
end
|
97
95
|
|
98
96
|
def reboot_needed?(exception)
|
99
|
-
resolve_exception_array(exception).any?
|
100
|
-
e.is_a? Chef::Exceptions::RebootPending
|
101
|
-
end
|
97
|
+
resolve_exception_array(exception).any?(Chef::Exceptions::RebootPending)
|
102
98
|
end
|
103
99
|
|
104
100
|
def reboot_failed?(exception)
|
105
|
-
resolve_exception_array(exception).any?
|
106
|
-
e.is_a? Chef::Exceptions::RebootFailed
|
107
|
-
end
|
101
|
+
resolve_exception_array(exception).any?(Chef::Exceptions::RebootFailed)
|
108
102
|
end
|
109
103
|
|
110
104
|
def configuration_failure?(exception)
|
111
|
-
resolve_exception_array(exception).any?
|
112
|
-
e.is_a? Chef::Exceptions::ConfigurationError
|
113
|
-
end
|
105
|
+
resolve_exception_array(exception).any?(Chef::Exceptions::ConfigurationError)
|
114
106
|
end
|
115
107
|
|
116
108
|
def client_upgraded?(exception)
|
117
|
-
resolve_exception_array(exception).any?
|
118
|
-
e.is_a? Chef::Exceptions::ClientUpgraded
|
119
|
-
end
|
109
|
+
resolve_exception_array(exception).any?(Chef::Exceptions::ClientUpgraded)
|
120
110
|
end
|
121
111
|
|
122
112
|
def sigint_received?(exception)
|
123
|
-
resolve_exception_array(exception).any?
|
124
|
-
e.is_a? Chef::Exceptions::SigInt
|
125
|
-
end
|
113
|
+
resolve_exception_array(exception).any?(Chef::Exceptions::SigInt)
|
126
114
|
end
|
127
115
|
|
128
116
|
def sigterm_received?(exception)
|
129
|
-
resolve_exception_array(exception).any?
|
130
|
-
e.is_a? Chef::Exceptions::SigTerm
|
131
|
-
end
|
117
|
+
resolve_exception_array(exception).any?(Chef::Exceptions::SigTerm)
|
132
118
|
end
|
133
119
|
|
134
120
|
def resolve_exception_array(exception)
|
@@ -38,7 +38,7 @@ class Chef
|
|
38
38
|
|
39
39
|
def read
|
40
40
|
tmpfile = rest.streaming_request(file[:url])
|
41
|
-
File.
|
41
|
+
File.binread(tmpfile)
|
42
42
|
rescue Timeout::Error => e
|
43
43
|
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading #{file[:url]}: #{e}")
|
44
44
|
rescue Net::HTTPClientException => e
|
@@ -57,7 +57,7 @@ class Chef
|
|
57
57
|
# @return [Array<Input>] inspec inputs which are enabled in a form suitable to pass to inspec
|
58
58
|
#
|
59
59
|
def inspec_data
|
60
|
-
select(&:enabled?).each_with_object({}) { |input, hash| hash.merge(input.inspec_data) }
|
60
|
+
select(&:enabled?).each_with_object({}) { |input, hash| hash.merge!(input.inspec_data) }
|
61
61
|
end
|
62
62
|
|
63
63
|
# DSL method to enable input files. This matches on the filename of the input file.
|
@@ -57,7 +57,7 @@ class Chef
|
|
57
57
|
# @return [Array<Waiver>] inspec waivers which are enabled in a form suitable to pass to inspec
|
58
58
|
#
|
59
59
|
def inspec_data
|
60
|
-
select(&:enabled?).each_with_object({}) { |waiver, hash| hash.merge(waiver.inspec_data) }
|
60
|
+
select(&:enabled?).each_with_object({}) { |waiver, hash| hash.merge!(waiver.inspec_data) }
|
61
61
|
end
|
62
62
|
|
63
63
|
# DSL method to enable waiver files. This matches on the filename of the waiver file.
|
@@ -113,7 +113,7 @@ class Chef
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def remove_uninteresting_ruby_files(file_list)
|
116
|
-
file_list.
|
116
|
+
file_list.grep_v(%r{#{Regexp.quote(cookbook_path)}/(files|templates)/})
|
117
117
|
end
|
118
118
|
|
119
119
|
def ruby_files
|
@@ -119,7 +119,7 @@ class Chef
|
|
119
119
|
# but we need the base64 encoding for the content-md5
|
120
120
|
# header
|
121
121
|
checksum64 = Base64.encode64([checksum].pack("H*")).strip
|
122
|
-
file_contents = File.
|
122
|
+
file_contents = File.binread(file)
|
123
123
|
|
124
124
|
# Custom headers. 'content-type' disables JSON serialization of the request body.
|
125
125
|
headers = { "content-type" => "application/x-binary", "content-md5" => checksum64, "accept" => "application/json" }
|
@@ -598,7 +598,7 @@ class Chef
|
|
598
598
|
filename = record[:name]
|
599
599
|
base_dup_name = File.join(File.dirname(filename), File.basename(filename, File.extname(filename)))
|
600
600
|
yml_files.each do |other|
|
601
|
-
if
|
601
|
+
if /#{(File.extname(filename) == ".yml") ? "#{base_dup_name}.yaml" : "#{base_dup_name}.yml"}$/.match?(other[:name])
|
602
602
|
raise Chef::Exceptions::AmbiguousYAMLFile.new("Cookbook #{name}@#{version} contains ambiguous files: #{filename} and #{other[:name]}. Please update the cookbook to remove the incorrect file.")
|
603
603
|
end
|
604
604
|
end
|
data/lib/chef/provider/cron.rb
CHANGED
@@ -92,7 +92,7 @@ class Chef
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
action :create do
|
95
|
+
action :create, description: "Create an entry in a cron table file (crontab). If an entry already exists (but does not match), update that entry to match." do
|
96
96
|
crontab = ""
|
97
97
|
newcron = ""
|
98
98
|
cron_found = false
|
@@ -149,7 +149,7 @@ class Chef
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
action :delete do
|
152
|
+
action :delete, description: "Delete an entry from a cron table file (crontab)." do
|
153
153
|
if @cron_exists
|
154
154
|
crontab = ""
|
155
155
|
cron_found = false
|
@@ -121,7 +121,7 @@ class Chef
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
action :create do
|
124
|
+
action :create, description: "Create a directory. If a directory already exists (but does not match), update that directory to match." do
|
125
125
|
unless ::File.exist?(new_resource.path)
|
126
126
|
converge_by("create new directory #{new_resource.path}") do
|
127
127
|
if new_resource.recursive == true
|
@@ -137,7 +137,7 @@ class Chef
|
|
137
137
|
load_resource_attributes_from_file(new_resource) unless Chef::Config[:why_run]
|
138
138
|
end
|
139
139
|
|
140
|
-
action :delete do
|
140
|
+
action :delete, description: "Delete a directory." do
|
141
141
|
if ::File.exist?(new_resource.path)
|
142
142
|
converge_by("delete existing directory #{new_resource.path}") do
|
143
143
|
if new_resource.recursive == true
|
@@ -120,7 +120,7 @@ class Chef
|
|
120
120
|
@status = shell_out("ifconfig")
|
121
121
|
@status.stdout.each_line do |line|
|
122
122
|
addr_regex = /^((\w|-)+):?(\d*):?\ .+$/
|
123
|
-
if line
|
123
|
+
if line&.match?(addr_regex)
|
124
124
|
if line.match(addr_regex).nil?
|
125
125
|
@int_name = "nil"
|
126
126
|
elsif line.match(addr_regex)[3] == ""
|
@@ -168,7 +168,7 @@ class Chef
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
|
171
|
-
action :add do
|
171
|
+
action :add, description: "Run ifconfig to configure a network interface and (on some platforms) write a configuration file for that network interface." do
|
172
172
|
# check to see if load_current_resource found interface in ifconfig
|
173
173
|
unless current_resource.inet_addr
|
174
174
|
unless new_resource.device == loopback_device
|
@@ -183,7 +183,7 @@ class Chef
|
|
183
183
|
generate_config
|
184
184
|
end
|
185
185
|
|
186
|
-
action :enable do
|
186
|
+
action :enable, description: "Run ifconfig to enable a network interface." do
|
187
187
|
# check to see if load_current_resource found ifconfig
|
188
188
|
# enables, but does not manage config files
|
189
189
|
return if current_resource.inet_addr
|
@@ -196,7 +196,7 @@ class Chef
|
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
-
action :delete do
|
199
|
+
action :delete, description: "Run ifconfig to disable a network interface and (on some platforms) delete that network interface’s configuration file." do
|
200
200
|
# check to see if load_current_resource found the interface
|
201
201
|
if current_resource.device
|
202
202
|
command = delete_command
|
@@ -210,7 +210,7 @@ class Chef
|
|
210
210
|
delete_config
|
211
211
|
end
|
212
212
|
|
213
|
-
action :disable do
|
213
|
+
action :disable, description: "Run ifconfig to disable a network interface." do
|
214
214
|
# check to see if load_current_resource found the interface
|
215
215
|
# disables, but leaves config files in place.
|
216
216
|
if current_resource.device
|
@@ -115,10 +115,90 @@ class Chef
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def is_arch?(arch)
|
119
|
+
# cspell:disable-next
|
120
|
+
arches = %w{aarch64 alpha alphaev4 alphaev45 alphaev5 alphaev56 alphaev6 alphaev67 alphaev68 alphaev7 alphapca56 armv5tejl armv5tel armv5tl armv6l armv7l armv8l armv6hl armv7hl armv7hnl armv8hl i386 athlon geode i386 i486 i586 i686 ia64 mips mipsel mips64 mips64el noarch ppc ppc64 ppc64iseries ppc64p7 ppc64pseries ppc64le riscv32 riscv64 riscv128 s390 s390x sh3 sh4 sh4a sparc sparc64 sparc64v sparcv8 sparcv9 sparcv9v x86_64 amd64 ia32e}
|
121
|
+
arches.include?(arch)
|
122
|
+
end
|
123
|
+
|
124
|
+
# We have a provides line with an epoch in it and yum cannot parse that, so we
|
125
|
+
# need to deconstruct the args. This doesn't support splats which is why we
|
126
|
+
# only do it for this particularly narrow use case.
|
127
|
+
#
|
128
|
+
# name-epoch:version
|
129
|
+
# name-epoch:version.arch
|
130
|
+
# name-epoch:version-release
|
131
|
+
# name-epoch:version-release.arch
|
132
|
+
#
|
133
|
+
# @api private
|
134
|
+
def deconstruct_args(provides)
|
135
|
+
raise "provides must have an epoch in the version to deconstruct" unless provides =~ /^(\S+)-(\d+):(\S+)/
|
136
|
+
|
137
|
+
name = $1
|
138
|
+
epoch = $2
|
139
|
+
other = $3
|
140
|
+
ret = { "provides" => name, "epoch" => epoch }
|
141
|
+
maybe_arch = other.rpartition(".").last
|
142
|
+
arch = if is_arch?(maybe_arch)
|
143
|
+
other.delete_suffix!(".#{maybe_arch}")
|
144
|
+
maybe_arch
|
145
|
+
end
|
146
|
+
ret.merge!({ "arch" => arch }) if arch
|
147
|
+
(version, _, release) = other.rpartition("-")
|
148
|
+
if version.empty?
|
149
|
+
ret.merge!({ "version" => release }) # yeah, rpartition is just weird
|
150
|
+
else
|
151
|
+
ret.merge!({ "version" => version, "release" => release })
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# In the default case for the yum provider we now do terrible things with ruby
|
156
|
+
# to concatenate all the properties together to form a single string to feed to
|
157
|
+
# the python which favors using returnPackages/searchProvides over the
|
158
|
+
# searchNevra API. That means that these two different ways of constructing the
|
159
|
+
# resource are now perfectly identical:
|
160
|
+
#
|
161
|
+
# yum_package "zabbix-agent-4.0.15-1.fc31.x86_64"
|
162
|
+
#
|
163
|
+
# yum_package "zabbix-agent" do
|
164
|
+
# version "4.0.15-1.fc31"
|
165
|
+
# arch "x86_64"
|
166
|
+
# end
|
167
|
+
#
|
168
|
+
# This function handles turning the second form into the first form.
|
169
|
+
#
|
170
|
+
# In the case where the epoch is given in the version and we do not have any glob
|
171
|
+
# patterns that is handled by going the other way and calling deconstruct_args due
|
172
|
+
# to the yum libraries not supporting that calling pattern other than by searchNevra.
|
173
|
+
#
|
174
|
+
# NOTE: This is an ugly hack and should NOT be considered an endorsement of this approach
|
175
|
+
# towards any kind of features or bugfixes in the DNF provider. I'm doing this
|
176
|
+
# because YUM is sunsetting at this point and its very difficult to fight with the
|
177
|
+
# libraries on the python side of things.
|
178
|
+
#
|
179
|
+
# @api private
|
180
|
+
def combine_args(provides, version, arch)
|
181
|
+
provides = provides.dup
|
182
|
+
maybe_arch = provides.rpartition(".").last
|
183
|
+
if is_arch?(maybe_arch)
|
184
|
+
arch = maybe_arch
|
185
|
+
provides.delete_suffix!(".#{arch}")
|
186
|
+
end
|
187
|
+
provides = "#{provides}-#{version}" if version
|
188
|
+
provides = "#{provides}.#{arch}" if arch
|
189
|
+
# yum (on rhel7) can't handle an epoch in provides, but
|
190
|
+
# deconstructing the args can't handle dealing with globs
|
191
|
+
if provides =~ /-\d+:/ && provides !~ /[\*\?]/
|
192
|
+
deconstruct_args(provides)
|
193
|
+
else
|
194
|
+
{ "provides" => provides }
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
118
198
|
# @return Array<Version>
|
119
199
|
# NB: "options" here is the yum_package options hash and is deliberately not **opts
|
120
200
|
def package_query(action, provides, version: nil, arch: nil, options: {})
|
121
|
-
parameters =
|
201
|
+
parameters = combine_args(provides, version, arch)
|
122
202
|
repo_opts = options_params(options || {})
|
123
203
|
parameters.merge!(repo_opts)
|
124
204
|
# XXX: for now we close the rpmdb before and after every query with an enablerepo/disablerepo to clean the helpers internal state
|
@@ -137,25 +217,6 @@ class Chef
|
|
137
217
|
|
138
218
|
private
|
139
219
|
|
140
|
-
# i couldn't figure out how to decompose an evr on the python side, it seems reasonably
|
141
|
-
# painless to do it in ruby (generally massaging nevras in the ruby side is HIGHLY
|
142
|
-
# discouraged -- this is an "every rule has an exception" exception -- any additional
|
143
|
-
# functionality should probably trigger moving this regexp logic into python)
|
144
|
-
def add_version(hash, version)
|
145
|
-
epoch = nil
|
146
|
-
if version =~ /(\S+):(\S+)/
|
147
|
-
epoch = $1
|
148
|
-
version = $2
|
149
|
-
end
|
150
|
-
if version =~ /(\S+)-(\S+)/
|
151
|
-
version = $1
|
152
|
-
release = $2
|
153
|
-
end
|
154
|
-
hash["epoch"] = epoch unless epoch.nil?
|
155
|
-
hash["release"] = release unless release.nil?
|
156
|
-
hash["version"] = version
|
157
|
-
end
|
158
|
-
|
159
220
|
def query(action, parameters)
|
160
221
|
with_helper do
|
161
222
|
json = build_query(action, parameters)
|
@@ -174,11 +235,6 @@ class Chef
|
|
174
235
|
hash[param_name] = param_value unless param_value.nil?
|
175
236
|
end
|
176
237
|
|
177
|
-
# Special handling for certain action / param combos
|
178
|
-
if %i{whatinstalled whatavailable}.include?(action)
|
179
|
-
add_version(hash, parameters["version"]) unless parameters["version"].nil?
|
180
|
-
end
|
181
|
-
|
182
238
|
FFI_Yajl::Encoder.encode(hash)
|
183
239
|
end
|
184
240
|
|
@@ -36,6 +36,7 @@ class Chef
|
|
36
36
|
allow_nils
|
37
37
|
use_multipackage_api
|
38
38
|
use_package_name_for_source
|
39
|
+
use_magic_version
|
39
40
|
|
40
41
|
provides :package, platform_family: "fedora_derived"
|
41
42
|
|
@@ -64,6 +65,16 @@ class Chef
|
|
64
65
|
current_resource
|
65
66
|
end
|
66
67
|
|
68
|
+
def load_after_resource
|
69
|
+
# force the installed version array to repopulate
|
70
|
+
@current_version = []
|
71
|
+
@after_resource = Chef::Resource::YumPackage.new(new_resource.name)
|
72
|
+
after_resource.package_name(new_resource.package_name)
|
73
|
+
after_resource.version(get_current_versions)
|
74
|
+
|
75
|
+
after_resource
|
76
|
+
end
|
77
|
+
|
67
78
|
def define_resource_requirements
|
68
79
|
requirements.assert(:install, :upgrade, :remove, :purge) do |a|
|
69
80
|
a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
|
@@ -80,9 +91,15 @@ class Chef
|
|
80
91
|
end
|
81
92
|
end
|
82
93
|
|
94
|
+
def magic_version_array
|
95
|
+
package_name_array.each_with_index.map do |pkg, i|
|
96
|
+
magical_version(i).version_with_arch
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
83
100
|
def get_current_versions
|
84
101
|
package_name_array.each_with_index.map do |pkg, i|
|
85
|
-
|
102
|
+
current_version(i).version_with_arch
|
86
103
|
end
|
87
104
|
end
|
88
105
|
|
@@ -127,7 +144,7 @@ class Chef
|
|
127
144
|
alias upgrade_package install_package
|
128
145
|
|
129
146
|
def remove_package(names, versions)
|
130
|
-
resolved_names = names.each_with_index.map { |name, i|
|
147
|
+
resolved_names = names.each_with_index.map { |name, i| magical_version(i).to_s unless name.nil? }
|
131
148
|
yum(options, "-y", "remove", resolved_names)
|
132
149
|
flushcache
|
133
150
|
end
|
@@ -157,10 +174,10 @@ class Chef
|
|
157
174
|
def resolved_package_lock_names(names)
|
158
175
|
names.each_with_index.map do |name, i|
|
159
176
|
unless name.nil?
|
160
|
-
if
|
177
|
+
if magical_version(i).version.nil?
|
161
178
|
available_version(i).name
|
162
179
|
else
|
163
|
-
|
180
|
+
magical_version(i).name
|
164
181
|
end
|
165
182
|
end
|
166
183
|
end
|
@@ -226,15 +243,25 @@ class Chef
|
|
226
243
|
@available_version[index]
|
227
244
|
end
|
228
245
|
|
246
|
+
def magical_version(index)
|
247
|
+
@magical_version ||= []
|
248
|
+
@magical_version[index] ||= if new_resource.source
|
249
|
+
python_helper.package_query(:whatinstalled, available_version(index).name, version: safe_version_array[index], arch: safe_arch_array[index], options: options)
|
250
|
+
else
|
251
|
+
python_helper.package_query(:whatinstalled, package_name_array[index], version: safe_version_array[index], arch: safe_arch_array[index], options: options)
|
252
|
+
end
|
253
|
+
@magical_version[index]
|
254
|
+
end
|
255
|
+
|
229
256
|
# @return Array<Version>
|
230
|
-
def
|
231
|
-
@
|
232
|
-
@
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
@
|
257
|
+
def current_version(index)
|
258
|
+
@current_version ||= []
|
259
|
+
@current_version[index] ||= if new_resource.source
|
260
|
+
python_helper.package_query(:whatinstalled, available_version(index).name, arch: safe_arch_array[index], options: options)
|
261
|
+
else
|
262
|
+
python_helper.package_query(:whatinstalled, package_name_array[index], arch: safe_arch_array[index], options: options)
|
263
|
+
end
|
264
|
+
@current_version[index]
|
238
265
|
end
|
239
266
|
|
240
267
|
def flushcache
|
@@ -107,7 +107,7 @@ class Chef
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
action :install do
|
110
|
+
action :install, description: "Install a package. If a version is specified, install the specified version of the package." do
|
111
111
|
unless target_version_array.any?
|
112
112
|
logger.debug("#{new_resource} is already installed - nothing to do")
|
113
113
|
return
|
@@ -136,7 +136,7 @@ class Chef
|
|
136
136
|
|
137
137
|
private :install_description
|
138
138
|
|
139
|
-
action :upgrade do
|
139
|
+
action :upgrade, description: "Install a package and ensure that a package is the latest version." do
|
140
140
|
unless target_version_array.any?
|
141
141
|
logger.debug("#{new_resource} no versions to upgrade - nothing to do")
|
142
142
|
return
|
@@ -167,7 +167,7 @@ class Chef
|
|
167
167
|
|
168
168
|
private :upgrade_description
|
169
169
|
|
170
|
-
action :remove do
|
170
|
+
action :remove, description: "Remove a package." do
|
171
171
|
if removing_package?
|
172
172
|
description = new_resource.version ? "version #{new_resource.version} of " : ""
|
173
173
|
converge_by("remove #{description}package #{current_resource.package_name}") do
|
@@ -202,7 +202,7 @@ class Chef
|
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
action :purge do
|
205
|
+
action :purge, description: "Purge a package. This action typically removes the configuration files as well as the package." do
|
206
206
|
if removing_package?
|
207
207
|
description = new_resource.version ? "version #{new_resource.version} of" : ""
|
208
208
|
converge_by("purge #{description} package #{current_resource.package_name}") do
|
@@ -658,7 +658,7 @@ class Chef
|
|
658
658
|
end
|
659
659
|
|
660
660
|
def allow_downgrade
|
661
|
-
if new_resource.respond_to?(
|
661
|
+
if new_resource.respond_to?(:allow_downgrade)
|
662
662
|
new_resource.allow_downgrade
|
663
663
|
else
|
664
664
|
true
|
@@ -339,7 +339,7 @@ class Chef
|
|
339
339
|
end
|
340
340
|
|
341
341
|
def locked?
|
342
|
-
user_plist[:auth_authority].any?
|
342
|
+
user_plist[:auth_authority].any?(";DisabledUser;")
|
343
343
|
rescue
|
344
344
|
false
|
345
345
|
end
|
@@ -411,7 +411,7 @@ class Chef
|
|
411
411
|
end
|
412
412
|
|
413
413
|
def secure_token_enabled?
|
414
|
-
user_plist[:auth_authority].any?
|
414
|
+
user_plist[:auth_authority].any?(";SecureToken;")
|
415
415
|
rescue
|
416
416
|
false
|
417
417
|
end
|
@@ -505,7 +505,7 @@ class Chef
|
|
505
505
|
end
|
506
506
|
|
507
507
|
def admin_user?
|
508
|
-
admin_group_plist[:group_members].any?
|
508
|
+
admin_group_plist[:group_members].any?(user_plist[:guid][0])
|
509
509
|
rescue
|
510
510
|
false
|
511
511
|
end
|
data/lib/chef/provider.rb
CHANGED
@@ -35,7 +35,6 @@ class Chef
|
|
35
35
|
attr_accessor :after_resource
|
36
36
|
attr_accessor :run_context
|
37
37
|
|
38
|
-
attr_reader :recipe_name
|
39
38
|
attr_reader :logger
|
40
39
|
|
41
40
|
include Chef::Mixin::WhyRun
|
@@ -174,6 +173,10 @@ class Chef
|
|
174
173
|
new_resource.cookbook_name
|
175
174
|
end
|
176
175
|
|
176
|
+
def recipe_name
|
177
|
+
new_resource.recipe_name
|
178
|
+
end
|
179
|
+
|
177
180
|
# hook that subclasses can use to do lazy validation for where properties aren't flexible enough
|
178
181
|
def check_resource_semantics!; end
|
179
182
|
|
data/lib/chef/providers.rb
CHANGED
@@ -108,7 +108,6 @@ require_relative "provider/group/groupadd"
|
|
108
108
|
require_relative "provider/group/groupmod"
|
109
109
|
require_relative "provider/group/pw"
|
110
110
|
require_relative "provider/group/solaris"
|
111
|
-
require_relative "provider/group/suse"
|
112
111
|
require_relative "provider/group/usermod"
|
113
112
|
require_relative "provider/group/windows"
|
114
113
|
|
@@ -43,7 +43,7 @@ class Chef
|
|
43
43
|
**Install multiple packages at once**:
|
44
44
|
|
45
45
|
```ruby
|
46
|
-
apt_package %(package1 package2 package3)
|
46
|
+
apt_package %w(package1 package2 package3)
|
47
47
|
```
|
48
48
|
|
49
49
|
**Install without using recommend packages as a dependency**:
|
@@ -55,7 +55,7 @@ class Chef
|
|
55
55
|
```
|
56
56
|
DOC
|
57
57
|
|
58
|
-
description "Use the **apt_package** resource to manage packages on Debian and
|
58
|
+
description "Use the **apt_package** resource to manage packages on Debian, Ubuntu, and other platforms that use the APT package system."
|
59
59
|
|
60
60
|
property :default_release, String,
|
61
61
|
description: "The default release. For example: `stable`.",
|
@@ -20,6 +20,12 @@
|
|
20
20
|
|
21
21
|
require_relative "../resource"
|
22
22
|
require "fileutils" unless defined?(FileUtils)
|
23
|
+
begin
|
24
|
+
# ffi-libarchive must be eager loaded see: https://github.com/chef/chef/issues/12228
|
25
|
+
require "ffi-libarchive" unless defined?(Archive::Reader)
|
26
|
+
rescue LoadError
|
27
|
+
STDERR.puts "ffi-libarchive could not be loaded, libarchive is probably not installed on system, archive_file will not be available"
|
28
|
+
end
|
23
29
|
|
24
30
|
class Chef
|
25
31
|
class Resource
|
@@ -92,8 +98,6 @@ class Chef
|
|
92
98
|
|
93
99
|
action :extract, description: "Extract and archive file." do
|
94
100
|
|
95
|
-
require_libarchive
|
96
|
-
|
97
101
|
unless ::File.exist?(new_resource.path)
|
98
102
|
raise Errno::ENOENT, "No archive found at #{new_resource.path}! Cannot continue."
|
99
103
|
end
|
@@ -131,10 +135,6 @@ class Chef
|
|
131
135
|
end
|
132
136
|
|
133
137
|
action_class do
|
134
|
-
def require_libarchive
|
135
|
-
require "ffi-libarchive"
|
136
|
-
end
|
137
|
-
|
138
138
|
def define_resource_requirements
|
139
139
|
if new_resource.mode.is_a?(Integer)
|
140
140
|
Chef.deprecated(:archive_file_integer_file_mode, "The mode property should be passed to archive_file resources as a String and not an Integer to ensure the value is properly interpreted.")
|