class Chef::DataCollector
Chef::DataCollector¶ ↑
Provides methods for determinine whether a reporter should be registered.
Public Class Methods
data_collector_output_locations_configured?()
click to toggle source
# File lib/chef/data_collector.rb, line 72 def self.data_collector_output_locations_configured? !!Chef::Config[:data_collector][:output_locations] end
data_collector_url_configured?()
click to toggle source
# File lib/chef/data_collector.rb, line 68 def self.data_collector_url_configured? !!Chef::Config[:data_collector][:server_url] end
register_reporter?()
click to toggle source
Whether or not to enable data collection:
-
always disabled for why run mode
-
disabled when the user sets `Chef::Config[:mode]` to a value that excludes the mode (client or solo) that we are running as
-
disabled in solo mode if the user did not configure the auth token
-
disabled if `Chef::Config[:server_url]` is set to a falsey value
# File lib/chef/data_collector.rb, line 43 def self.register_reporter? if why_run? Chef::Log.trace("data collector is disabled for why run mode") return false end unless reporter_enabled_for_current_mode? Chef::Log.trace("data collector is configured to only run in " \ "#{Chef::Config[:data_collector][:mode].inspect} modes, disabling it") return false end unless data_collector_url_configured? || data_collector_output_locations_configured? Chef::Log.trace("Neither data collector URL or output locations have been configured, disabling data collector") return false end if solo? && !token_auth_configured? Chef::Log.trace("Data collector token must be configured to use Chef Automate data collector with Chef Solo") end if !solo? && token_auth_configured? Chef::Log.warn("Data collector token authentication is not recommended for client-server mode" \ "Please upgrade Chef Server to 12.11.0 and remove the token from your config file " \ "to use key based authentication instead") end true end
reporter_enabled_for_current_mode?()
click to toggle source
# File lib/chef/data_collector.rb, line 88 def self.reporter_enabled_for_current_mode? if Chef::Config[:solo] || Chef::Config[:local_mode] acceptable_modes = [:solo, :both] else acceptable_modes = [:client, :both] end acceptable_modes.include?(Chef::Config[:data_collector][:mode]) end
solo?()
click to toggle source
# File lib/chef/data_collector.rb, line 84 def self.solo? !!Chef::Config[:solo] || !!Chef::Config[:local_mode] end
token_auth_configured?()
click to toggle source
# File lib/chef/data_collector.rb, line 80 def self.token_auth_configured? !!Chef::Config[:data_collector][:token] end
why_run?()
click to toggle source
# File lib/chef/data_collector.rb, line 76 def self.why_run? !!Chef::Config[:why_run] end