Module: RightScale::OhaiSetup

Defined in:
lib/chef/ohai_setup.rb

Overview

Provides details of configuring ohai for use in right_link environment

Defined Under Namespace

Classes: SetupError

Constant Summary collapse

CUSTOM_PLUGINS_DIR_PATH =
File.normalize_path(File.join(File.dirname(__FILE__), 'plugins'))

Class Method Summary collapse

Class Method Details

.configure_ohaiObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/chef/ohai_setup.rb', line 34

def configure_ohai
  unless ::Ohai::Config[:plugin_path].include?(CUSTOM_PLUGINS_DIR_PATH)
    raise SetupError, "Missing custom Ohai plugins directory: \"#{CUSTOM_PLUGINS_DIR_PATH}\"" unless File.directory?(CUSTOM_PLUGINS_DIR_PATH)
    ::Ohai::Config[:plugin_path].unshift(CUSTOM_PLUGINS_DIR_PATH)
  end

  # must set file cache path and ensure it exists otherwise evented run_command will fail
  ::Ohai::Config[:file_cache_path] = AgentConfig.cache_dir
  ::FileUtils.mkdir_p(::Ohai::Config[:file_cache_path])

  ::Ohai::Log.logger = Log
  ::Ohai::Config.log_level(Log.level_from_sym(Log.level))
end