File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222require 'chef/daemon'
2323require 'chef/log'
2424require 'chef/rest'
25+ require 'chef/handler/error_report'
2526
2627
2728class Chef ::Application ::Client < Chef ::Application
@@ -150,6 +151,9 @@ def reconfigure
150151 super
151152
152153 Chef ::Config [ :chef_server_url ] = config [ :chef_server_url ] if config . has_key? :chef_server_url
154+ unless Chef ::Config [ :exception_handlers ] . any? { |h | Chef ::Handler ::ErrorReport === h }
155+ Chef ::Config [ :exception_handlers ] << Chef ::Handler ::ErrorReport . new
156+ end
153157
154158 if Chef ::Config [ :daemonize ]
155159 Chef ::Config [ :interval ] ||= 1800
Original file line number Diff line number Diff line change 1+ #
2+ # Author:: Adam Jacob (<adam@opscode.com>)
3+ # Copyright:: Copyright (c) 2010 Opscode, 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/handler'
20+ require 'chef/resource/directory'
21+
22+ class Chef
23+ class Handler
24+ class ErrorReport < ::Chef ::Handler
25+
26+ def report
27+ Chef ::Log . fatal ( "Saving node information to #{ report_path } " )
28+
29+ File . open ( report_path , "w" ) do |file |
30+ file . puts Chef ::JSONCompat . to_json_pretty ( data )
31+ end
32+ end
33+
34+ def report_path
35+ File . join ( Dir . tmpdir , "failed-run-data.json" )
36+ end
37+
38+ end
39+ end
40+ end
You can’t perform that action at this time.
0 commit comments