chef 13.2.20-universal-mingw32 → 13.3.42-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +2 -8
- data/README.md +6 -2
- data/Rakefile +0 -11
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +1 -1
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb +34 -18
- data/acceptance/data-collector/.acceptance/data-collector-test/recipes/default.rb +6 -0
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/deprecation/warnings.rb +3 -1
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/http.rb +9 -10
- data/lib/chef/http/api_versions.rb +2 -0
- data/lib/chef/http/http_request.rb +3 -0
- data/lib/chef/knife/core/bootstrap_context.rb +1 -0
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +4 -0
- data/lib/chef/provider/apt_preference.rb +99 -0
- data/lib/chef/provider/execute.rb +3 -2
- data/lib/chef/provider/http_request.rb +14 -0
- data/lib/chef/provider/mount/aix.rb +49 -8
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +5 -5
- data/lib/chef/provider/service/systemd.rb +12 -11
- data/lib/chef/provider/support/zypper_repo.erb +17 -0
- data/lib/chef/provider/systemd_unit.rb +3 -2
- data/lib/chef/provider/windows_task.rb +92 -71
- data/lib/chef/provider/zypper_repository.rb +81 -0
- data/lib/chef/providers.rb +2 -0
- data/lib/chef/resource/apt_preference.rb +36 -0
- data/lib/chef/resource/execute.rb +12 -2
- data/lib/chef/resource/http_request.rb +1 -1
- data/lib/chef/resource/zypper_repository.rb +51 -0
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/search/query.rb +6 -1
- data/lib/chef/server_api_versions.rb +21 -2
- data/lib/chef/version.rb +3 -4
- data/lib/chef/win32/api/file.rb +1 -0
- data/lib/chef/win32/file.rb +2 -0
- data/lib/chef/win32/version.rb +6 -0
- data/spec/functional/knife/ssh_spec.rb +1 -1
- data/spec/functional/resource/execute_spec.rb +2 -2
- data/spec/spec_helper.rb +8 -1
- data/spec/unit/cookbook/metadata_spec.rb +3 -3
- data/spec/unit/http/api_versions_spec.rb +6 -3
- data/spec/unit/knife/bootstrap_spec.rb +4 -0
- data/spec/unit/knife/cookbook_show_spec.rb +3 -3
- data/spec/unit/knife/ssh_spec.rb +7 -1
- data/spec/unit/knife/status_spec.rb +2 -0
- data/spec/unit/provider/apt_preference_spec.rb +87 -0
- data/spec/unit/provider/apt_update_spec.rb +7 -7
- data/spec/unit/provider/dsc_resource_spec.rb +2 -2
- data/spec/unit/provider/execute_spec.rb +32 -14
- data/spec/unit/provider/mount/aix_spec.rb +33 -1
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb +56 -3
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/package/zypper_spec.rb +43 -0
- data/spec/unit/provider/script_spec.rb +1 -1
- data/spec/unit/provider/service/systemd_service_spec.rb +23 -21
- data/spec/unit/provider/systemd_unit_spec.rb +42 -41
- data/spec/unit/provider/windows_task_spec.rb +40 -0
- data/spec/unit/resource/apt_preference_spec.rb +41 -0
- data/spec/unit/resource/execute_spec.rb +21 -1
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource/zypper_repository_spec.rb +65 -0
- data/spec/unit/search/query_spec.rb +13 -18
- data/spec/unit/server_api_spec.rb +75 -1
- data/spec/unit/server_api_versions_spec.rb +22 -0
- data/spec/unit/win32/link_spec.rb +73 -0
- data/tasks/dependencies.rb +0 -1
- metadata +14 -81
- data/acceptance/.bundle/config +0 -2
- data/acceptance/bin/aws.rb +0 -17
- data/acceptance/bin/berks +0 -17
- data/acceptance/bin/bundler +0 -17
- data/acceptance/bin/chef-acceptance +0 -17
- data/acceptance/bin/coderay +0 -17
- data/acceptance/bin/erubis +0 -17
- data/acceptance/bin/htmldiff +0 -17
- data/acceptance/bin/httpclient +0 -17
- data/acceptance/bin/inspec +0 -17
- data/acceptance/bin/kitchen +0 -17
- data/acceptance/bin/ldiff +0 -17
- data/acceptance/bin/nokogiri +0 -17
- data/acceptance/bin/pry +0 -17
- data/acceptance/bin/rake +0 -17
- data/acceptance/bin/rspec +0 -17
- data/acceptance/bin/rwinrm +0 -17
- data/acceptance/bin/rwinrmcp +0 -17
- data/acceptance/bin/safe_yaml +0 -17
- data/acceptance/bin/thor +0 -17
- data/acceptance/fips/.kitchen/fips-unit-functional-centos-6.yml +0 -7
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/action_set_name +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/creator_uid +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/id +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/index_uuid +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/private_key +0 -27
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/synced_folders +0 -1
- data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/Vagrantfile +0 -11
- data/acceptance/fips/.kitchen/logs/fips-integration-centos-6.log +0 -0
- data/acceptance/fips/.kitchen/logs/fips-integration-windows-2012r2.log +0 -0
- data/acceptance/fips/.kitchen/logs/fips-unit-functional-centos-6.log +0 -80
- data/acceptance/fips/.kitchen/logs/kitchen.log +0 -4
- data/tasks/changelog.rb +0 -37
- data/tasks/version.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a79b6de66d2ff2fe9d70489dd9819a2ca54ccc
|
4
|
+
data.tar.gz: 44350dd32b51d346a0f60f2bde5929c08ad3b406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f1aecd61f9b6e744a17ccc97dcf043c779ac639e43ca46d2d005773144560c1dba0809a1faf5ab340e923c27067fa42243aeef36f9cc8da6f4c98b199767c50
|
7
|
+
data.tar.gz: a024d13f6e6e74b76ee751ae74e46fc639b88dbad38c5e588aa6823b4172adc561f2daa9cc5287f8cab6c081d93101f14834cadb3564163c32a8c3c6fb5ff8f5
|
data/CONTRIBUTING.md
CHANGED
@@ -90,7 +90,7 @@ The DCO requires a sign-off message in the following format appear on each commi
|
|
90
90
|
Signed-off-by: Julia Child <juliachild@chef.io>
|
91
91
|
```
|
92
92
|
|
93
|
-
The DCO text can either be manually added to your commit body, or you can add either **-s** or **--signoff** to your usual git commit commands. If you forget to add the sign-off you can also amend a previous commit with the sign-off by running **git commit
|
93
|
+
The DCO text can either be manually added to your commit body, or you can add either **-s** or **--signoff** to your usual git commit commands. If you forget to add the sign-off you can also amend a previous commit with the sign-off by running **git commit --amend -s**. If you've pushed your changes to Github already you'll need to force push your branch after this with **git push -f**.
|
94
94
|
|
95
95
|
### Chef Obvious Fix Policy
|
96
96
|
|
data/Gemfile
CHANGED
@@ -16,8 +16,6 @@ group(:omnibus_package) do
|
|
16
16
|
gem "appbundler"
|
17
17
|
gem "rb-readline"
|
18
18
|
gem "inspec"
|
19
|
-
# nokogiri has no ruby-2.4 version for windows so it cannot go into our Gemfile.lock
|
20
|
-
# gem "nokogiri", ">= 1.7.1"
|
21
19
|
end
|
22
20
|
|
23
21
|
group(:omnibus_package, :pry) do
|
@@ -31,7 +29,7 @@ group(:docgen) do
|
|
31
29
|
gem "yard"
|
32
30
|
end
|
33
31
|
|
34
|
-
group(:maintenance
|
32
|
+
group(:maintenance) do
|
35
33
|
gem "tomlrb"
|
36
34
|
|
37
35
|
# To sync maintainers with github
|
@@ -52,17 +50,13 @@ end
|
|
52
50
|
group(:development, :test) do
|
53
51
|
gem "rake"
|
54
52
|
gem "simplecov"
|
53
|
+
gem "webmock"
|
55
54
|
|
56
55
|
# for testing new chefstyle rules
|
57
56
|
# gem 'chefstyle', github: 'chef/chefstyle'
|
58
57
|
gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
|
59
58
|
end
|
60
59
|
|
61
|
-
group(:ci) do
|
62
|
-
gem "github_changelog_generator", git: "https://github.com/chef/github-changelog-generator"
|
63
|
-
gem "mixlib-install"
|
64
|
-
end
|
65
|
-
|
66
60
|
group(:travis) do
|
67
61
|
# See `bundler-audit` in .travis.yml
|
68
62
|
gem "bundler-audit", git: "https://github.com/rubysec/bundler-audit.git"
|
data/README.md
CHANGED
@@ -5,7 +5,11 @@
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef)
|
6
6
|
[![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef-rfc/blob/master/rfc086-chef-oss-project-policies.md#cadence-release)
|
7
7
|
|
8
|
-
|
8
|
+
## Getting Started
|
9
|
+
|
10
|
+
Want to try Chef?
|
11
|
+
For Chef user, please refer to [Quick Start](https://docs.chef.io/quick_start.html)
|
12
|
+
For more details, please refer to [learnchef](https://learn.chef.io)
|
9
13
|
|
10
14
|
- Documentation: <https://docs.chef.io>
|
11
15
|
- Source: <https://github.com/chef/chef/tree/master>
|
@@ -37,7 +41,7 @@ to report issues against in the Chef docs in the
|
|
37
41
|
If you can't determine the appropriate place to report an issue, then please open it
|
38
42
|
against the repository you think best fits and it will be directed to the appropriate project.
|
39
43
|
|
40
|
-
## Installing From Git
|
44
|
+
## Installing From Git for Developers
|
41
45
|
|
42
46
|
**NOTE:** As a Chef user, please download the omnibus package of [Chef](https://downloads.chef.io/chef) or [Chef-DK](https://downloads.chef.io/chef)
|
43
47
|
|
data/Rakefile
CHANGED
@@ -27,9 +27,7 @@ require_relative "tasks/rspec"
|
|
27
27
|
require_relative "tasks/maintainers"
|
28
28
|
require_relative "tasks/cbgb"
|
29
29
|
require_relative "tasks/dependencies"
|
30
|
-
require_relative "tasks/changelog"
|
31
30
|
require_relative "tasks/announce"
|
32
|
-
require_relative "tasks/version"
|
33
31
|
|
34
32
|
ChefConfig::PackageTask.new(File.expand_path("..", __FILE__), "Chef", "chef") do |package|
|
35
33
|
package.component_paths = ["chef-config"]
|
@@ -51,15 +49,6 @@ task :register_eventlog do
|
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
54
|
-
desc "Keep the Dockerfile up-to-date"
|
55
|
-
task :update_dockerfile do
|
56
|
-
require "mixlib/install"
|
57
|
-
latest_stable_version = Mixlib::Install.available_versions("chef", "stable").last
|
58
|
-
text = File.read("Dockerfile")
|
59
|
-
new_text = text.gsub(/^ARG VERSION=[\d\.]+$/, "ARG VERSION=#{latest_stable_version}")
|
60
|
-
File.open("Dockerfile", "w+") { |f| f.write(new_text) }
|
61
|
-
end
|
62
|
-
|
63
52
|
begin
|
64
53
|
require "chefstyle"
|
65
54
|
require "rubocop/rake_task"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
13.
|
1
|
+
13.3.42
|
data/acceptance/Gemfile.lock
CHANGED
@@ -17,35 +17,51 @@ module ApiHelpers
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class Counter
|
20
|
-
|
21
|
-
|
22
|
-
end
|
20
|
+
class << self
|
21
|
+
attr_accessor :counters
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def counters
|
24
|
+
@counters ||= Hash.new { |h, k| h[k] = 0 }
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset
|
28
|
+
@counters = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def increment(payload)
|
32
|
+
counter_name = ApiHelpers.payload_type(payload)
|
33
|
+
counters[counter_name] += 1
|
34
|
+
end
|
28
35
|
|
29
|
-
|
30
|
-
|
36
|
+
def to_json
|
37
|
+
counters.to_json
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
33
41
|
|
34
42
|
class MessageCache
|
35
43
|
include ApiHelpers
|
36
44
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
45
|
+
class << self
|
46
|
+
attr_accessor :message_cache
|
40
47
|
|
41
|
-
|
42
|
-
|
48
|
+
def message_cache
|
49
|
+
@message_cache ||= {}
|
50
|
+
end
|
43
51
|
|
44
|
-
|
45
|
-
|
52
|
+
def reset
|
53
|
+
@message_cache = nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def store(payload)
|
57
|
+
cache_key = ApiHelpers.payload_type(payload)
|
58
|
+
|
59
|
+
message_cache[cache_key] = payload
|
60
|
+
end
|
46
61
|
|
47
|
-
|
48
|
-
|
62
|
+
def fetch(cache_key)
|
63
|
+
message_cache[cache_key].to_json
|
64
|
+
end
|
49
65
|
end
|
50
66
|
end
|
51
67
|
|
@@ -1,3 +1,6 @@
|
|
1
|
+
|
2
|
+
embedded_path = "/opt/chef/embedded/bin:#{ENV["PATH"]}"
|
3
|
+
|
1
4
|
api_root_dir = "/var/opt/data_collector_api"
|
2
5
|
|
3
6
|
directory api_root_dir do
|
@@ -14,6 +17,7 @@ cookbook_file ::File.join(api_root_dir, "api.rb")
|
|
14
17
|
|
15
18
|
execute "bundle install --binstubs" do
|
16
19
|
cwd api_root_dir
|
20
|
+
environment({ "PATH" => embedded_path })
|
17
21
|
end
|
18
22
|
|
19
23
|
pid_file = "/var/run/api.pid"
|
@@ -21,11 +25,13 @@ running_pid = ::File.exist?(pid_file) ? ::File.read(pid_file).strip : nil
|
|
21
25
|
|
22
26
|
execute "kill existing API process" do
|
23
27
|
command "kill #{running_pid}"
|
28
|
+
environment({ "PATH" => embedded_path })
|
24
29
|
not_if { running_pid.nil? }
|
25
30
|
end
|
26
31
|
|
27
32
|
execute "start API" do
|
28
33
|
command "bin/rackup -D -P #{pid_file}"
|
34
|
+
environment({ "PATH" => embedded_path })
|
29
35
|
cwd api_root_dir
|
30
36
|
end
|
31
37
|
|
@@ -20,10 +20,12 @@ class Chef
|
|
20
20
|
module Deprecation
|
21
21
|
module Warnings
|
22
22
|
|
23
|
+
require "chef/version"
|
24
|
+
|
23
25
|
def add_deprecation_warnings_for(method_names)
|
24
26
|
method_names.each do |name|
|
25
27
|
define_method(name) do |*args|
|
26
|
-
message = "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in Chef
|
28
|
+
message = "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in Chef #{Chef::VERSION.to_i.next}."
|
27
29
|
message << " Please update your cookbooks accordingly."
|
28
30
|
Chef.deprecated(:internal_api, message)
|
29
31
|
super(*args)
|
data/lib/chef/exceptions.rb
CHANGED
@@ -515,7 +515,7 @@ This error is most often caused by network issues (proxies, etc) outside of chef
|
|
515
515
|
"Resource #{r['Name']} is a binary resource"
|
516
516
|
end
|
517
517
|
end
|
518
|
-
super "Found multiple matching
|
518
|
+
super "Found multiple resources matching #{matches_info[0]["Module"]["Name"]}:\n#{(matches_info.map { |f| f["Module"]["Version"] }).uniq.join("\n")}"
|
519
519
|
end
|
520
520
|
end
|
521
521
|
|
data/lib/chef/http.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Author:: Christopher Brown (<cb@chef.io>)
|
6
6
|
# Author:: Christopher Walters (<cw@chef.io>)
|
7
7
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
8
|
-
# Copyright:: Copyright 2009-
|
8
|
+
# Copyright:: Copyright 2009-2017, Chef Software Inc.
|
9
9
|
# License:: Apache License, Version 2.0
|
10
10
|
#
|
11
11
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -144,9 +144,9 @@ class Chef
|
|
144
144
|
def request(method, path, headers = {}, data = false)
|
145
145
|
http_attempts ||= 0
|
146
146
|
url = create_url(path)
|
147
|
-
|
147
|
+
processed_method, url, processed_headers, processed_data = apply_request_middleware(method, url, headers, data)
|
148
148
|
|
149
|
-
response, rest_request, return_value = send_http_request(
|
149
|
+
response, rest_request, return_value = send_http_request(processed_method, url, processed_headers, processed_data)
|
150
150
|
response, rest_request, return_value = apply_response_middleware(response, rest_request, return_value)
|
151
151
|
|
152
152
|
response.error! unless success_response?(response)
|
@@ -157,7 +157,6 @@ class Chef
|
|
157
157
|
response = e.response
|
158
158
|
if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
|
159
159
|
Chef::Log.debug("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
|
160
|
-
sleep(http_retry_delay)
|
161
160
|
retry
|
162
161
|
else
|
163
162
|
raise
|
@@ -176,11 +175,12 @@ class Chef
|
|
176
175
|
url = create_url(path)
|
177
176
|
response, rest_request, return_value = nil, nil, nil
|
178
177
|
tempfile = nil
|
178
|
+
data = nil
|
179
179
|
|
180
180
|
method = :GET
|
181
|
-
method, url,
|
181
|
+
method, url, processed_headers, data = apply_request_middleware(method, url, headers, data)
|
182
182
|
|
183
|
-
response, rest_request, return_value = send_http_request(method, url,
|
183
|
+
response, rest_request, return_value = send_http_request(method, url, processed_headers, data) do |http_response|
|
184
184
|
if http_response.kind_of?(Net::HTTPSuccess)
|
185
185
|
tempfile = stream_to_tempfile(url, http_response, &progress_block)
|
186
186
|
end
|
@@ -196,7 +196,6 @@ class Chef
|
|
196
196
|
response = e.response
|
197
197
|
if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
|
198
198
|
Chef::Log.debug("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
|
199
|
-
sleep(http_retry_delay)
|
200
199
|
retry
|
201
200
|
else
|
202
201
|
raise
|
@@ -223,11 +222,12 @@ class Chef
|
|
223
222
|
url = create_url(path)
|
224
223
|
response, rest_request, return_value = nil, nil, nil
|
225
224
|
tempfile = nil
|
225
|
+
data = nil
|
226
226
|
|
227
227
|
method = :GET
|
228
|
-
method, url,
|
228
|
+
method, url, processed_headers, data = apply_request_middleware(method, url, headers, data)
|
229
229
|
|
230
|
-
response, rest_request, return_value = send_http_request(method, url,
|
230
|
+
response, rest_request, return_value = send_http_request(method, url, processed_headers, data) do |http_response|
|
231
231
|
if http_response.kind_of?(Net::HTTPSuccess)
|
232
232
|
tempfile = stream_to_tempfile(url, http_response)
|
233
233
|
end
|
@@ -252,7 +252,6 @@ class Chef
|
|
252
252
|
response = e.response
|
253
253
|
if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
|
254
254
|
Chef::Log.debug("Negotiating protocol version with #{url}, retry #{http_attempts}/#{version_retries}")
|
255
|
-
sleep(http_retry_delay)
|
256
255
|
retry
|
257
256
|
else
|
258
257
|
raise
|
@@ -37,6 +37,8 @@ class Chef
|
|
37
37
|
end
|
38
38
|
if http_response.key?("x-ops-server-api-version")
|
39
39
|
ServerAPIVersions.instance.set_versions(JSONCompat.parse(http_response["x-ops-server-api-version"]))
|
40
|
+
else
|
41
|
+
ServerAPIVersions.instance.unversioned!
|
40
42
|
end
|
41
43
|
[http_response, rest_request, return_value]
|
42
44
|
end
|
@@ -49,6 +49,7 @@ class Chef
|
|
49
49
|
ENCODING_GZIP_DEFLATE = "gzip;q=1.0,deflate;q=0.6,identity;q=0.3".freeze
|
50
50
|
|
51
51
|
GET = "get".freeze
|
52
|
+
PATCH = "patch".freeze
|
52
53
|
PUT = "put".freeze
|
53
54
|
POST = "post".freeze
|
54
55
|
DELETE = "delete".freeze
|
@@ -161,6 +162,8 @@ class Chef
|
|
161
162
|
Net::HTTP::Post.new(req_path, headers)
|
162
163
|
when PUT
|
163
164
|
Net::HTTP::Put.new(req_path, headers)
|
165
|
+
when PATCH
|
166
|
+
Net::HTTP::Patch.new(req_path, headers)
|
164
167
|
when DELETE
|
165
168
|
Net::HTTP::Delete.new(req_path, headers)
|
166
169
|
when HEAD
|
@@ -223,6 +223,7 @@ validation_client_name "#{@chef_config[:validation_client_name]}"
|
|
223
223
|
attributes[:run_list] = @run_list
|
224
224
|
end
|
225
225
|
|
226
|
+
attributes.delete(:run_list) if attributes[:policy_name] && !attributes[:policy_name].empty?
|
226
227
|
attributes.merge!(:tags => @config[:tags]) if @config[:tags] && !@config[:tags].empty?
|
227
228
|
end
|
228
229
|
end
|
data/lib/chef/knife/ssh.rb
CHANGED
@@ -0,0 +1,99 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
3
|
+
# Copyright:: 2016-2017, Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require "chef/provider"
|
20
|
+
require "chef/dsl/declare_resource"
|
21
|
+
require "chef/provider/noop"
|
22
|
+
require "chef/mixin/which"
|
23
|
+
require "chef/log"
|
24
|
+
|
25
|
+
class Chef
|
26
|
+
class Provider
|
27
|
+
class AptPreference < Chef::Provider
|
28
|
+
extend Chef::Mixin::Which
|
29
|
+
|
30
|
+
provides :apt_preference do
|
31
|
+
which("apt-get")
|
32
|
+
end
|
33
|
+
|
34
|
+
APT_PREFERENCE_DIR = "/etc/apt/preferences.d".freeze
|
35
|
+
|
36
|
+
def load_current_resource
|
37
|
+
end
|
38
|
+
|
39
|
+
action :add do
|
40
|
+
preference = build_pref(
|
41
|
+
new_resource.glob || new_resource.package_name,
|
42
|
+
new_resource.pin,
|
43
|
+
new_resource.pin_priority
|
44
|
+
)
|
45
|
+
|
46
|
+
declare_resource(:directory, APT_PREFERENCE_DIR) do
|
47
|
+
mode "0755"
|
48
|
+
action :create
|
49
|
+
end
|
50
|
+
|
51
|
+
sanitized_prefname = safe_name(new_resource.package_name)
|
52
|
+
|
53
|
+
# cleanup any existing pref files w/o the sanitized name (created by old apt cookbook)
|
54
|
+
if (sanitized_prefname != new_resource.package_name) && ::File.exist?("#{APT_PREFERENCE_DIR}/#{new_resource.package_name}.pref")
|
55
|
+
Chef::Log.warn "Replacing legacy #{new_resource.package_name}.pref with #{sanitized_prefname}.pref in #{APT_PREFERENCE_DIR}"
|
56
|
+
declare_resource(:file, "#{APT_PREFERENCE_DIR}/#{new_resource.package_name}.pref") do
|
57
|
+
action :delete
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# cleanup any existing pref files without the .pref extension (created by old apt cookbook)
|
62
|
+
if ::File.exist?("#{APT_PREFERENCE_DIR}/#{new_resource.package_name}")
|
63
|
+
Chef::Log.warn "Replacing legacy #{new_resource.package_name} with #{sanitized_prefname}.pref in #{APT_PREFERENCE_DIR}"
|
64
|
+
declare_resource(:file, "#{APT_PREFERENCE_DIR}/#{new_resource.package_name}") do
|
65
|
+
action :delete
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
declare_resource(:file, "#{APT_PREFERENCE_DIR}/#{sanitized_prefname}.pref") do
|
70
|
+
mode "0644"
|
71
|
+
content preference
|
72
|
+
action :create
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
action :remove do
|
77
|
+
sanitized_prefname = safe_name(new_resource.package_name)
|
78
|
+
|
79
|
+
if ::File.exist?("#{APT_PREFERENCE_DIR}/#{sanitized_prefname}.pref")
|
80
|
+
Chef::Log.info "Un-pinning #{sanitized_prefname} from #{APT_PREFERENCE_DIR}"
|
81
|
+
declare_resource(:file, "#{APT_PREFERENCE_DIR}/#{sanitized_prefname}.pref") do
|
82
|
+
action :delete
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Build preferences.d file contents
|
88
|
+
def build_pref(package_name, pin, pin_priority)
|
89
|
+
"Package: #{package_name}\nPin: #{pin}\nPin-Priority: #{pin_priority}\n"
|
90
|
+
end
|
91
|
+
|
92
|
+
def safe_name(name)
|
93
|
+
name.tr(".", "_").gsub("*", "wildcard")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
Chef::Provider::Noop.provides :apt_preference
|