diff options
-rw-r--r-- | chef/lib/chef/application/client.rb | 6 | ||||
-rw-r--r-- | chef/lib/chef/config.rb | 3 | ||||
-rw-r--r-- | chef/lib/chef/resource_reporter.rb | 29 |
3 files changed, 27 insertions, 11 deletions
diff --git a/chef/lib/chef/application/client.rb b/chef/lib/chef/application/client.rb index e9408ce5fc..c24b9de03a 100644 --- a/chef/lib/chef/application/client.rb +++ b/chef/lib/chef/application/client.rb @@ -176,6 +176,12 @@ class Chef::Application::Client < Chef::Application :description => "Fork client", :boolean => true + option :disable_reporting, + :short => "-R", + :long => "--disable-reporting", + :description => "Disable reporting data collection for chef runs", + :boolean => true + attr_reader :chef_client_json def initialize diff --git a/chef/lib/chef/config.rb b/chef/lib/chef/config.rb index 64eab45082..741e3cb05f 100644 --- a/chef/lib/chef/config.rb +++ b/chef/lib/chef/config.rb @@ -200,7 +200,8 @@ class Chef why_run false color false client_fork false - + disable_reporting false + # Set these to enable SSL authentication / mutual-authentication # with the server ssl_client_cert nil diff --git a/chef/lib/chef/resource_reporter.rb b/chef/lib/chef/resource_reporter.rb index d2561203ea..a420cbf0b6 100644 --- a/chef/lib/chef/resource_reporter.rb +++ b/chef/lib/chef/resource_reporter.rb @@ -86,7 +86,11 @@ class Chef attr_reader :error_descriptions def initialize(rest_client) - @reporting_enabled = true + if Chef::Config[:disable_reporting] + @reporting_enabled = false + else + @reporting_enabled = true + end @updated_resources = [] @total_res_count = 0 @pending_update = nil @@ -100,15 +104,20 @@ class Chef def node_load_completed(node, expanded_run_list_with_versions, config) @node = node - resource_history_url = "reports/nodes/#{@node.name}/runs" - server_response = @rest_client.post_rest(resource_history_url, {:action => :begin}) - run_uri = URI.parse(server_response["uri"]) - @run_id = ::File.basename(run_uri.path) - Chef::Log.info("Chef server generated run history id: #{@run_id}") - rescue Net::HTTPServerException => e - raise unless e.response.code.to_s == "404" - Chef::Log.debug("Received 404 attempting to generate run history id (URL Path: #{resource_history_url}), assuming feature is not supported.") - @reporting_enabled = false + + if reporting_enabled? + begin + resource_history_url = "reports/nodes/#{@node.name}/runs" + server_response = @rest_client.post_rest(resource_history_url, {:action => :begin}) + run_uri = URI.parse(server_response["uri"]) + @run_id = ::File.basename(run_uri.path) + Chef::Log.info("Chef server generated run history id: #{@run_id}") + rescue Net::HTTPServerException => e + raise unless e.response.code.to_s == "404" + Chef::Log.debug("Received 404 attempting to generate run history id (URL Path: #{resource_history_url}), assuming feature is not supported.") + @reporting_enabled = false + end + end end def resource_current_state_loaded(new_resource, action, current_resource) |