Class: Hiera
- Inherits:
-
Object
- Object
- Hiera
- 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
-
.logger ⇒ Object
Returns the value of attribute logger.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Hiera
constructor
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.
-
#lookup(key, default, scope, order_override = nil, resolution_type = :priority) ⇒ Object
Calls the backends to do the actual lookup.
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(={}) [:config] ||= File.join(Util.config_dir, 'hiera.yaml') @config = Config.load([:config]) Config.load_backends end |
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/hiera.rb', line 14 def logger @logger end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
40 41 42 |
# File 'lib/hiera.rb', line 40 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
40 41 42 |
# File 'lib/hiera.rb', line 40 def @options end |
Class Method Details
.debug(msg) ⇒ Object
37 |
# File 'lib/hiera.rb', line 37 def debug(msg); @logger.debug(msg); end |
.version ⇒ Object
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 |