Parent

Hiera

Constants

VERSION

Attributes

logger[R]
config[R]
options[R]

Public Class Methods

debug(msg) click to toggle source
# File lib/hiera.rb, line 39
def debug(msg); @logger.debug(msg); end
logger=(logger) click to toggle source

Loggers are pluggable, just provide a class called Hiera::Foo_logger and respond to :warn and :debug

See hiera-puppet for an example that uses the Puppet loging system instead of our own

# File lib/hiera.rb, line 27
def logger=(logger)
  require "hiera/#{logger}_logger"

  @logger = Hiera::FallbackLogger.new(
    Hiera.const_get("#{logger.capitalize}_logger"),
    Hiera::Console_logger)
rescue Exception => e
  @logger = Hiera::Console_logger
  warn("Failed to load #{logger} logger: #{e.class}: #{e}")
end
new(options={}) click to toggle source

If the config option is a string its assumed to be a filename, else a hash of what would have been in the YAML config file

# File lib/hiera.rb, line 46
def initialize(options={})
  options[:config] ||= File.join(Util.config_dir, 'hiera.yaml')

  @config = Config.load(options[:config])

  Config.load_backends
end
version() click to toggle source
# File lib/hiera.rb, line 18
def version
  VERSION
end
warn(msg) click to toggle source
# File lib/hiera.rb, line 38
def warn(msg); @logger.warn(msg); end

Public Instance Methods

lookup(key, default, scope, order_override=nil, resolution_type=:priority) click to toggle source

Calls the backends to do the actual lookup.

The scope can be anything that responds to [], if you have input data like a Puppet Scope that does not you can wrap that data in a class that has a [] method that fetches the data from your source. See hiera-puppet for an example of this.

The order-override will insert as first in the hierarchy a data source of your choice.

# File lib/hiera.rb, line 63
def lookup(key, default, scope, order_override=nil, resolution_type=:priority)
  Backend.lookup(key, default, scope, order_override, resolution_type)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.