chef 12.15.19 → 12.16.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/VERSION +1 -1
- data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +3 -1
- data/acceptance/Gemfile.lock +14 -14
- data/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +3 -11
- data/distro/common/html/knife_bootstrap.html +1 -1
- data/distro/common/man/man1/README.md +2 -2
- data/distro/common/man/man1/knife-client.1 +1 -1
- data/lib/chef/application.rb +7 -15
- data/lib/chef/application/client.rb +2 -2
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_class.rb +1 -0
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +3 -7
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbook_dir.rb +1 -1
- data/lib/chef/data_collector.rb +83 -9
- data/lib/chef/data_collector/messages.rb +2 -1
- data/lib/chef/dsl/core.rb +1 -1
- data/lib/chef/dsl/declare_resource.rb +10 -4
- data/lib/chef/dsl/method_missing.rb +1 -1
- data/lib/chef/dsl/recipe.rb +1 -1
- data/lib/chef/dsl/universal.rb +1 -1
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/http.rb +3 -4
- data/lib/chef/knife.rb +20 -2
- data/lib/chef/knife/core/generic_presenter.rb +18 -4
- data/lib/chef/knife/node_show.rb +0 -5
- data/lib/chef/knife/osc_user_show.rb +0 -1
- data/lib/chef/knife/ssl_fetch.rb +9 -5
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/node.rb +1 -5
- data/lib/chef/node/attribute.rb +70 -98
- data/lib/chef/node/attribute_collections.rb +28 -19
- data/lib/chef/node/common_api.rb +0 -6
- data/lib/chef/node/immutable_collections.rb +16 -79
- data/lib/chef/node/mixin/deep_merge_cache.rb +61 -0
- data/lib/chef/node/mixin/immutablize_array.rb +67 -0
- data/lib/chef/node/mixin/immutablize_hash.rb +54 -0
- data/lib/chef/node/mixin/state_tracking.rb +93 -0
- data/lib/chef/property.rb +4 -4
- data/lib/chef/provider/cron.rb +1 -1
- data/lib/chef/provider/group/suse.rb +23 -4
- data/lib/chef/provider/package.rb +43 -5
- data/lib/chef/provider/package/apt.rb +20 -0
- data/lib/chef/provider/package/windows/exe.rb +4 -3
- data/lib/chef/provider/package/windows/msi.rb +4 -3
- data/lib/chef/provider/package/yum.rb +20 -0
- data/lib/chef/provider/package/zypper.rb +20 -0
- data/lib/chef/provider/ruby_block.rb +1 -1
- data/lib/chef/provider/service/upstart.rb +25 -9
- data/lib/chef/provider/user.rb +4 -6
- data/lib/chef/provider/user/dscl.rb +8 -3
- data/lib/chef/provider/user/solaris.rb +5 -12
- data/lib/chef/resource.rb +19 -0
- data/lib/chef/resource/file.rb +1 -1
- data/lib/chef/resource/package.rb +1 -1
- data/lib/chef/resource/scm.rb +1 -7
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/rest.rb +1 -0
- data/lib/chef/run_context.rb +12 -0
- data/lib/chef/version.rb +1 -1
- data/spec/data/trusted_certs/example_no_cn.crt +36 -0
- data/spec/functional/resource/group_spec.rb +1 -0
- data/spec/functional/resource/user/useradd_spec.rb +4 -2
- data/spec/integration/knife/data_bag_create_spec.rb +0 -3
- data/spec/integration/knife/environment_show_spec.rb +24 -4
- data/spec/integration/knife/node_environment_set_spec.rb +4 -1
- data/spec/integration/recipes/accumulator_spec.rb +232 -0
- data/spec/integration/recipes/resource_action_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/shared/context/client.rb +12 -3
- data/spec/support/shared/integration/app_server_support.rb +1 -1
- data/spec/support/shared/integration/knife_support.rb +4 -1
- data/spec/unit/data_collector/messages_spec.rb +2 -0
- data/spec/unit/data_collector_spec.rb +158 -21
- data/spec/unit/http_spec.rb +1 -1
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +10 -0
- data/spec/unit/knife/ssl_fetch_spec.rb +38 -0
- data/spec/unit/knife_spec.rb +31 -0
- data/spec/unit/mixin/powershell_out_spec.rb +25 -1
- data/spec/unit/node/attribute_spec.rb +46 -1
- data/spec/unit/node/vivid_mash_spec.rb +27 -89
- data/spec/unit/node_spec.rb +134 -3
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/group/suse_spec.rb +90 -0
- data/spec/unit/provider/package/apt_spec.rb +22 -0
- data/spec/unit/provider/package/windows/msi_spec.rb +13 -4
- data/spec/unit/provider/package/windows_spec.rb +3 -3
- data/spec/unit/provider/package/yum_spec.rb +18 -0
- data/spec/unit/provider/package/zypper_spec.rb +64 -0
- data/spec/unit/provider/package_spec.rb +58 -0
- data/spec/unit/provider/remote_file/content_spec.rb +1 -1
- data/spec/unit/provider/service/upstart_service_spec.rb +13 -6
- data/spec/unit/provider/user/solaris_spec.rb +36 -9
- data/spec/unit/provider/user_spec.rb +6 -0
- data/spec/unit/resource/apt_repository_spec.rb +1 -1
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 340c1cbda2004926c5f046f561e56586829a141c
|
4
|
+
data.tar.gz: efed35187da59fd2a49ea092312be922d11f90db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f0e9083844b5a3553acf79a476daab28277cbd3ef1f4d7da0354d88bf28afbe98e967e3470e5967ccaf5139864d11a9fffd58f3a3d733c07b81e8dbc6c7d11d
|
7
|
+
data.tar.gz: c97b133f8aa935250e57a66ef73af2288563547dcfec3cc9031531c0f2205ee52fbc8d8091e3b2d57dc9825f852cb7f7ff4e8332b1c733aae8b4ae3d0ecc7a68
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
12.
|
1
|
+
12.16.42
|
@@ -10,7 +10,9 @@ end
|
|
10
10
|
driver:
|
11
11
|
name: ec2
|
12
12
|
tags:
|
13
|
-
X-
|
13
|
+
X-Dept: Eng
|
14
|
+
X-Contact: product-team
|
15
|
+
X-Application: chef-ci-acceptance
|
14
16
|
aws_ssh_key_id: <%= ENV['AWS_SSH_KEY_ID'] || ENV['USER'] || ENV['USERNAME'] %>
|
15
17
|
# test-specific stuff
|
16
18
|
region: us-west-2
|
data/acceptance/Gemfile.lock
CHANGED
@@ -11,12 +11,12 @@ GEM
|
|
11
11
|
specs:
|
12
12
|
addressable (2.4.0)
|
13
13
|
artifactory (2.5.0)
|
14
|
-
aws-sdk (2.6.
|
15
|
-
aws-sdk-resources (= 2.6.
|
16
|
-
aws-sdk-core (2.6.
|
14
|
+
aws-sdk (2.6.14)
|
15
|
+
aws-sdk-resources (= 2.6.14)
|
16
|
+
aws-sdk-core (2.6.14)
|
17
17
|
jmespath (~> 1.0)
|
18
|
-
aws-sdk-resources (2.6.
|
19
|
-
aws-sdk-core (= 2.6.
|
18
|
+
aws-sdk-resources (2.6.14)
|
19
|
+
aws-sdk-core (= 2.6.14)
|
20
20
|
berkshelf (4.3.5)
|
21
21
|
addressable (~> 2.3, >= 2.3.4)
|
22
22
|
berkshelf-api-client (~> 2.0, >= 2.0.2)
|
@@ -53,7 +53,7 @@ GEM
|
|
53
53
|
celluloid-io (0.16.2)
|
54
54
|
celluloid (>= 0.16.0)
|
55
55
|
nio4r (>= 1.1.0)
|
56
|
-
chef-config (12.
|
56
|
+
chef-config (12.15.19)
|
57
57
|
addressable
|
58
58
|
fuzzyurl
|
59
59
|
mixlib-config (~> 2.0)
|
@@ -61,11 +61,11 @@ GEM
|
|
61
61
|
cleanroom (1.0.0)
|
62
62
|
coderay (1.1.1)
|
63
63
|
diff-lcs (1.2.5)
|
64
|
-
docker-api (1.32.
|
64
|
+
docker-api (1.32.1)
|
65
65
|
excon (>= 0.38.0)
|
66
66
|
json
|
67
67
|
erubis (2.7.0)
|
68
|
-
excon (0.
|
68
|
+
excon (0.54.0)
|
69
69
|
faraday (0.9.2)
|
70
70
|
multipart-post (>= 1.2, < 3)
|
71
71
|
ffi (1.9.14)
|
@@ -77,7 +77,7 @@ GEM
|
|
77
77
|
hashie (3.4.6)
|
78
78
|
hitimes (1.2.4)
|
79
79
|
httpclient (2.7.2)
|
80
|
-
inspec (1.
|
80
|
+
inspec (1.3.0)
|
81
81
|
hashie (~> 3.4)
|
82
82
|
json (>= 1.8, < 3.0)
|
83
83
|
method_source (~> 0.8)
|
@@ -90,7 +90,7 @@ GEM
|
|
90
90
|
rubyzip (~> 1.1)
|
91
91
|
sslshake (~> 1)
|
92
92
|
thor (~> 0.19)
|
93
|
-
train (>= 0.
|
93
|
+
train (>= 0.20.1, < 1.0)
|
94
94
|
jmespath (1.3.1)
|
95
95
|
json (2.0.2)
|
96
96
|
kitchen-ec2 (1.2.0)
|
@@ -132,7 +132,7 @@ GEM
|
|
132
132
|
net-ssh (>= 2.6.5)
|
133
133
|
nio4r (1.2.1)
|
134
134
|
nori (2.6.0)
|
135
|
-
octokit (4.
|
135
|
+
octokit (4.4.1)
|
136
136
|
sawyer (~> 0.7.0, >= 0.5.3)
|
137
137
|
parallel (1.9.0)
|
138
138
|
pry (0.10.4)
|
@@ -186,7 +186,7 @@ GEM
|
|
186
186
|
solve (2.0.3)
|
187
187
|
molinillo (~> 0.4.2)
|
188
188
|
semverse (~> 1.1)
|
189
|
-
sslshake (1.0.
|
189
|
+
sslshake (1.0.13)
|
190
190
|
test-kitchen (1.13.2)
|
191
191
|
mixlib-install (>= 1.2, < 3.0)
|
192
192
|
mixlib-shellout (>= 1.2, < 3.0)
|
@@ -198,7 +198,7 @@ GEM
|
|
198
198
|
thor (0.19.1)
|
199
199
|
timers (4.0.4)
|
200
200
|
hitimes
|
201
|
-
train (0.20.
|
201
|
+
train (0.20.1)
|
202
202
|
docker-api (~> 1.26)
|
203
203
|
json (>= 1.8, < 3.0)
|
204
204
|
mixlib-shellout (~> 2.0)
|
@@ -211,7 +211,7 @@ GEM
|
|
211
211
|
hashie (>= 2.0.2, < 4.0.0)
|
212
212
|
windows_chef_zero (2.0.0)
|
213
213
|
test-kitchen (>= 1.2.1)
|
214
|
-
winrm (2.0
|
214
|
+
winrm (2.1.0)
|
215
215
|
builder (>= 2.1.2)
|
216
216
|
erubis (~> 2.7)
|
217
217
|
gssapi (~> 1.2)
|
@@ -60,7 +60,7 @@ end
|
|
60
60
|
|
61
61
|
shared_examples_for "counter checks" do |counters_to_check|
|
62
62
|
counters_to_check.each do |counter, value|
|
63
|
-
it "counter #{counter} should equal #{value}" do
|
63
|
+
it "counter #{counter} should equal #{value.inspect}" do
|
64
64
|
counter_values = JSON.load(command("curl http://localhost:9292/counters").stdout)
|
65
65
|
expect(counter_values[counter]).to eq(value)
|
66
66
|
end
|
@@ -91,11 +91,6 @@ shared_examples_for "run_start payload check" do
|
|
91
91
|
expect(missing_fields).to eq([])
|
92
92
|
end
|
93
93
|
|
94
|
-
it "does not have any extra fields" do
|
95
|
-
payload = JSON.load(command("curl http://localhost:9292/cache/run_start").stdout)
|
96
|
-
extra_fields = payload.keys.select { |key| !required_fields.include?(key) && !optional_fields.include?(key) }
|
97
|
-
expect(extra_fields).to eq([])
|
98
|
-
end
|
99
94
|
end
|
100
95
|
end
|
101
96
|
|
@@ -121,6 +116,7 @@ shared_examples_for "run_converge.success payload check" do
|
|
121
116
|
status
|
122
117
|
total_resource_count
|
123
118
|
updated_resource_count
|
119
|
+
deprecations
|
124
120
|
}
|
125
121
|
end
|
126
122
|
let(:optional_fields) { [] }
|
@@ -131,11 +127,6 @@ shared_examples_for "run_converge.success payload check" do
|
|
131
127
|
expect(missing_fields).to eq([])
|
132
128
|
end
|
133
129
|
|
134
|
-
it "does not have any extra fields" do
|
135
|
-
payload = JSON.load(command("curl http://localhost:9292/cache/run_converge.success").stdout)
|
136
|
-
extra_fields = payload.keys.select { |key| !required_fields.include?(key) && !optional_fields.include?(key) }
|
137
|
-
expect(extra_fields).to eq([])
|
138
|
-
end
|
139
130
|
end
|
140
131
|
end
|
141
132
|
|
@@ -162,6 +153,7 @@ shared_examples_for "run_converge.failure payload check" do
|
|
162
153
|
status
|
163
154
|
total_resource_count
|
164
155
|
updated_resource_count
|
156
|
+
deprecations
|
165
157
|
}
|
166
158
|
end
|
167
159
|
let(:optional_fields) { [] }
|
@@ -173,7 +173,7 @@
|
|
173
173
|
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife bootstrap 192.168.1.100 -r <span class="s1">'role[webserver]'</span> -d ubuntu12.04-gems-mine
|
174
174
|
</pre></div>
|
175
175
|
</div>
|
176
|
-
<p>Alternatively, an example bootstrap template can be found in the git source for the chef-repo: <a class="reference external" href="https://github.com/
|
176
|
+
<p>Alternatively, an example bootstrap template can be found in the git source for the chef-repo: <a class="reference external" href="https://github.com/chef/chef/tree/master/lib/chef/knife/bootstrap">https://github.com/chef/chef/tree/master/lib/chef/knife/bootstrap</a>. Copy the template to <tt class="docutils literal"><span class="pre">~/.chef-repo/.chef/bootstrap/ubuntu12.04-apt.erb</span></tt> and modify the template appropriately.</p>
|
177
177
|
</div>
|
178
178
|
<div class="section" id="debian-and-apt">
|
179
179
|
<h3>Debian and Apt<a class="headerlink" href="#debian-and-apt" title="Permalink to this headline">¶</a></h3>
|
@@ -9,7 +9,7 @@ that are built into the chef-client are managed.
|
|
9
9
|
## Source Files
|
10
10
|
|
11
11
|
The source files are located in the chef-docs repository:
|
12
|
-
https://github.com/
|
12
|
+
https://github.com/chef/chef-docs
|
13
13
|
|
14
14
|
Each Knife subcommand has its own source folder. The folder naming
|
15
15
|
pattern begins with man_.
|
@@ -55,4 +55,4 @@ at docs.opscode.com/knife_foo.html.
|
|
55
55
|
|
56
56
|
## Questions?
|
57
57
|
|
58
|
-
Open an [Issue](https://github.com/
|
58
|
+
Open an [Issue](https://github.com/chef/chef-docs/issues) and ask.
|
@@ -37,7 +37,7 @@ However, during the first chef\-client run, this private key does not exist. Ins
|
|
37
37
|
.sp
|
38
38
|
During the initial chef\-client run, the chef\-client will register with the Chef server using the private key assigned to the chef\-validator, after which the chef\-client will obtain a \fBclient.pem\fP private key for all future authentication requests to the Chef server\&.
|
39
39
|
.sp
|
40
|
-
After the initial chef\-client run has completed successfully, the chef\-validator is no longer required and may be deleted from the node. Use the \fBdelete_validation\fP recipe found in the \fBchef\-client\fP cookbook (\fI\%https://github.com/
|
40
|
+
After the initial chef\-client run has completed successfully, the chef\-validator is no longer required and may be deleted from the node. Use the \fBdelete_validation\fP recipe found in the \fBchef\-client\fP cookbook (\fI\%https://github.com/chef\-cookbooks/chef\-client\fP) to remove the chef\-validator\&.
|
41
41
|
.sp
|
42
42
|
The \fBknife client\fP subcommand is used to manage an API client list and their associated RSA public key\-pairs. This allows authentication requests to be made to the Chef server by any entity that uses the Chef server API, such as the chef\-client and knife\&.
|
43
43
|
.SH COMMON OPTIONS
|
data/lib/chef/application.rb
CHANGED
@@ -28,7 +28,6 @@ require "mixlib/cli"
|
|
28
28
|
require "tmpdir"
|
29
29
|
require "rbconfig"
|
30
30
|
require "chef/application/exit_code"
|
31
|
-
require "yaml"
|
32
31
|
|
33
32
|
class Chef
|
34
33
|
class Application
|
@@ -111,20 +110,13 @@ class Chef
|
|
111
110
|
end
|
112
111
|
extra_config_options = config.delete(:config_option)
|
113
112
|
Chef::Config.merge!(config)
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
# Call to_sym because Chef::Config expects only symbol keys. Also
|
122
|
-
# runs a simple parse on the string for some common types.
|
123
|
-
memo[key.to_sym] = YAML.safe_load(value)
|
124
|
-
memo
|
125
|
-
end
|
126
|
-
Chef::Config.merge!(extra_parsed_options)
|
127
|
-
end
|
113
|
+
apply_extra_config_options(extra_config_options)
|
114
|
+
end
|
115
|
+
|
116
|
+
def apply_extra_config_options(extra_config_options)
|
117
|
+
Chef::Config.apply_extra_config_options(extra_config_options)
|
118
|
+
rescue ChefConfig::UnparsableConfigOption => e
|
119
|
+
Chef::Application.fatal!(e.message)
|
128
120
|
end
|
129
121
|
|
130
122
|
def set_specific_recipes
|
@@ -202,7 +202,7 @@ class Chef::Application::Client < Chef::Application
|
|
202
202
|
:short => "-o RunlistItem,RunlistItem...",
|
203
203
|
:long => "--override-runlist RunlistItem,RunlistItem...",
|
204
204
|
:description => "Replace current run list with specified items for a single run",
|
205
|
-
:proc => lambda {|items|
|
205
|
+
:proc => lambda { |items|
|
206
206
|
items = items.split(",")
|
207
207
|
items.compact.map do |item|
|
208
208
|
Chef::RunList::RunListItem.new(item)
|
@@ -213,7 +213,7 @@ class Chef::Application::Client < Chef::Application
|
|
213
213
|
:short => "-r RunlistItem,RunlistItem...",
|
214
214
|
:long => "--runlist RunlistItem,RunlistItem...",
|
215
215
|
:description => "Permanently replace current run list with specified items",
|
216
|
-
:proc => lambda {|items|
|
216
|
+
:proc => lambda { |items|
|
217
217
|
items = items.split(",")
|
218
218
|
items.compact.map do |item|
|
219
219
|
Chef::RunList::RunListItem.new(item)
|
@@ -166,7 +166,7 @@ class Chef::Application::Solo < Chef::Application
|
|
166
166
|
:short => "-o RunlistItem,RunlistItem...",
|
167
167
|
:long => "--override-runlist RunlistItem,RunlistItem...",
|
168
168
|
:description => "Replace current run list with specified items",
|
169
|
-
:proc => lambda {|items|
|
169
|
+
:proc => lambda { |items|
|
170
170
|
items = items.split(",")
|
171
171
|
items.compact.map do |item|
|
172
172
|
Chef::RunList::RunListItem.new(item)
|
data/lib/chef/chef_class.rb
CHANGED
@@ -39,17 +39,13 @@ class Chef
|
|
39
39
|
def read
|
40
40
|
begin
|
41
41
|
tmpfile = rest.streaming_request(file[:url])
|
42
|
+
File.open(tmpfile, "rb") { |f| f.read }
|
42
43
|
rescue Timeout::Error => e
|
43
44
|
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "Timeout reading #{file[:url]}: #{e}")
|
44
45
|
rescue Net::HTTPServerException => e
|
45
46
|
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:read, self, e, "#{e.message} retrieving #{file[:url]}")
|
46
|
-
|
47
|
-
|
48
|
-
begin
|
49
|
-
tmpfile.open
|
50
|
-
tmpfile.read
|
51
|
-
ensure
|
52
|
-
tmpfile.close!
|
47
|
+
rescue Errno::ENOENT
|
48
|
+
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
|
53
49
|
end
|
54
50
|
end
|
55
51
|
|
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
module ChefServer
|
25
25
|
class VersionedCookbookDir < CookbookDir
|
26
26
|
# See Erchef code
|
27
|
-
# https://github.com/
|
27
|
+
# https://github.com/chef/chef_objects/blob/968a63344d38fd507f6ace05f73d53e9cd7fb043/src/chef_regex.erl#L94
|
28
28
|
VALID_VERSIONED_COOKBOOK_NAME = /^([.a-zA-Z0-9_-]+)-(\d+\.\d+\.\d+)$/
|
29
29
|
|
30
30
|
def initialize(name, parent, options = {})
|
data/lib/chef/data_collector.rb
CHANGED
@@ -19,20 +19,66 @@
|
|
19
19
|
#
|
20
20
|
|
21
21
|
require "uri"
|
22
|
+
require "chef/server_api"
|
23
|
+
require "chef/http/simple_json"
|
22
24
|
require "chef/event_dispatch/base"
|
23
25
|
require "chef/data_collector/messages"
|
24
26
|
require "chef/data_collector/resource_report"
|
25
27
|
require "ostruct"
|
28
|
+
require "set"
|
26
29
|
|
27
30
|
class Chef
|
28
31
|
|
29
32
|
# == Chef::DataCollector
|
30
33
|
# Provides methods for determinine whether a reporter should be registered.
|
31
34
|
class DataCollector
|
35
|
+
|
36
|
+
# Whether or not to enable data collection:
|
37
|
+
# * always disabled for why run mode
|
38
|
+
# * disabled when the user sets `Chef::Config[:data_collector][:mode]` to a
|
39
|
+
# value that excludes the mode (client or solo) that we are running as
|
40
|
+
# * disabled in solo mode if the user did not configure the auth token
|
41
|
+
# * disabled if `Chef::Config[:data_collector][:server_url]` is set to a
|
42
|
+
# falsey value
|
32
43
|
def self.register_reporter?
|
33
|
-
|
34
|
-
|
35
|
-
|
44
|
+
if why_run?
|
45
|
+
Chef::Log.debug("data collector is disabled for why run mode")
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
unless reporter_enabled_for_current_mode?
|
49
|
+
Chef::Log.debug("data collector is configured to only run in " \
|
50
|
+
"#{Chef::Config[:data_collector][:mode].inspect} modes, disabling it")
|
51
|
+
return false
|
52
|
+
end
|
53
|
+
unless data_collector_url_configured?
|
54
|
+
Chef::Log.debug("data collector URL is not configured, disabling data collector")
|
55
|
+
return false
|
56
|
+
end
|
57
|
+
if solo? && !token_auth_configured?
|
58
|
+
Chef::Log.debug("Data collector token must be configured to use Chef Automate data collector with Chef Solo")
|
59
|
+
end
|
60
|
+
if !solo? && token_auth_configured?
|
61
|
+
Chef::Log.warn("Data collector token authentication is not recommended for client-server mode" \
|
62
|
+
"Please upgrade Chef Server to 12.11.0 and remove the token from your config file " \
|
63
|
+
"to use key based authentication instead")
|
64
|
+
end
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.data_collector_url_configured?
|
69
|
+
!!Chef::Config[:data_collector][:server_url]
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.why_run?
|
73
|
+
!!Chef::Config[:why_run]
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.token_auth_configured?
|
77
|
+
!!Chef::Config[:data_collector][:token]
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.solo?
|
81
|
+
!!Chef::Config[:solo] || !!Chef::Config[:local_mode]
|
36
82
|
end
|
37
83
|
|
38
84
|
def self.reporter_enabled_for_current_mode?
|
@@ -54,7 +100,7 @@ class Chef
|
|
54
100
|
class Reporter < EventDispatch::Base
|
55
101
|
attr_reader :all_resource_reports, :status, :exception, :error_descriptions,
|
56
102
|
:expanded_run_list, :run_context, :run_status, :http,
|
57
|
-
:current_resource_report, :enabled
|
103
|
+
:current_resource_report, :enabled, :deprecations
|
58
104
|
|
59
105
|
def initialize
|
60
106
|
validate_data_collector_server_url!
|
@@ -63,8 +109,10 @@ class Chef
|
|
63
109
|
@current_resource_loaded = nil
|
64
110
|
@error_descriptions = {}
|
65
111
|
@expanded_run_list = {}
|
66
|
-
@
|
112
|
+
@deprecations = Set.new
|
67
113
|
@enabled = true
|
114
|
+
|
115
|
+
@http = setup_http_client
|
68
116
|
end
|
69
117
|
|
70
118
|
# see EventDispatch::Base#run_started
|
@@ -79,7 +127,7 @@ class Chef
|
|
79
127
|
|
80
128
|
disable_reporter_on_error do
|
81
129
|
send_to_data_collector(
|
82
|
-
Chef::DataCollector::Messages.run_start_message(current_run_status)
|
130
|
+
Chef::DataCollector::Messages.run_start_message(current_run_status)
|
83
131
|
)
|
84
132
|
end
|
85
133
|
end
|
@@ -223,8 +271,27 @@ class Chef
|
|
223
271
|
)
|
224
272
|
end
|
225
273
|
|
274
|
+
# see EventDispatch::Base#deprecation
|
275
|
+
# Append a received deprecation to the list of deprecations
|
276
|
+
def deprecation(message, location = caller(2..2)[0])
|
277
|
+
add_deprecation(message, location)
|
278
|
+
end
|
279
|
+
|
226
280
|
private
|
227
281
|
|
282
|
+
# Selects the type of HTTP client to use based on whether we are using
|
283
|
+
# token-based or signed header authentication. Token authentication is
|
284
|
+
# intended to be used primarily for Chef Solo in which case no signing
|
285
|
+
# key will be available (in which case `Chef::ServerAPI.new()` would
|
286
|
+
# raise an exception.
|
287
|
+
def setup_http_client
|
288
|
+
if data_collector_token.nil?
|
289
|
+
Chef::ServerAPI.new(data_collector_server_url)
|
290
|
+
else
|
291
|
+
Chef::HTTP::SimpleJSON.new(data_collector_server_url)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
228
295
|
#
|
229
296
|
# Yields to the passed-in block (which is expected to be some interaction
|
230
297
|
# with the DataCollector endpoint). If some communication failure occurs,
|
@@ -255,7 +322,9 @@ class Chef
|
|
255
322
|
Chef::Log.error(msg)
|
256
323
|
raise
|
257
324
|
else
|
258
|
-
|
325
|
+
# Make the message non-scary for folks who don't have automate:
|
326
|
+
msg << " (This is normal if you do not have Chef Automate)"
|
327
|
+
Chef::Log.info(msg)
|
259
328
|
end
|
260
329
|
end
|
261
330
|
|
@@ -288,8 +357,9 @@ class Chef
|
|
288
357
|
expanded_run_list: expanded_run_list,
|
289
358
|
resources: all_resource_reports,
|
290
359
|
status: opts[:status],
|
291
|
-
error_descriptions: error_descriptions
|
292
|
-
|
360
|
+
error_descriptions: error_descriptions,
|
361
|
+
deprecations: deprecations.to_a
|
362
|
+
)
|
293
363
|
)
|
294
364
|
end
|
295
365
|
|
@@ -340,6 +410,10 @@ class Chef
|
|
340
410
|
@error_descriptions = discription_hash
|
341
411
|
end
|
342
412
|
|
413
|
+
def add_deprecation(message, location)
|
414
|
+
@deprecations << { message: message, location: location }
|
415
|
+
end
|
416
|
+
|
343
417
|
def create_resource_report(new_resource, action, current_resource = nil)
|
344
418
|
Chef::DataCollector::ResourceReport.new(
|
345
419
|
new_resource,
|