Class: Hiera

Inherits:
Object
  • Object
show all
Defined in:
lib/hiera.rb,
lib/hiera/util.rb,
lib/hiera/backend.rb,
lib/hiera/noop_logger.rb,
lib/hiera/puppet_logger.rb,
lib/hiera/console_logger.rb,
lib/hiera/backend/json_backend.rb,
lib/hiera/backend/yaml_backend.rb

Defined Under Namespace

Modules: Backend, Console_logger, Noop_logger, Puppet_logger, Util Classes: Config

Constant Summary collapse

VERSION =
"1.1.2"

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Hiera

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



44
45
46
47
48
49
50
# File 'lib/hiera.rb', line 44

def initialize(options={})
  options[:config] ||= File.join(Util.config_dir, 'hiera.yaml')

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

  Config.load_backends
end

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/hiera.rb', line 14

def logger
  @logger
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



40
41
42
# File 'lib/hiera.rb', line 40

def config
  @config
end

#optionsObject (readonly)

Returns the value of attribute options.



40
41
42
# File 'lib/hiera.rb', line 40

def options
  @options
end

Class Method Details

.debug(msg) ⇒ Object



37
# File 'lib/hiera.rb', line 37

def debug(msg); @logger.debug(msg); end

.versionObject



16
17
18
# File 'lib/hiera.rb', line 16

def version
  VERSION
end

.warn(msg) ⇒ Object



36
# File 'lib/hiera.rb', line 36

def warn(msg); @logger.warn(msg); end

Instance Method Details

#lookup(key, default, scope, order_override = nil, resolution_type = :priority) ⇒ Object

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.



61
62
63
# File 'lib/hiera.rb', line 61

def lookup(key, default, scope, order_override=nil, resolution_type=:priority)
  Backend.lookup(key, default, scope, order_override, resolution_type)
end