Module: FPM::Cookery::Hiera::Defaults

Included in:
Instance
Defined in:
lib/fpm/cookery/hiera/defaults.rb

Class Method Summary collapse

Class Method Details

.hiera_backendsObject

Default to attempting lookups using both .yaml and .json files.



22
23
24
# File 'lib/fpm/cookery/hiera/defaults.rb', line 22

def hiera_backends
  [:yaml, :json]
end

.hiera_config(options = {}) ⇒ Object

Sets default values for the {:config => { … }} options hash passed to the Hiera constructor, merging in any options from the caller.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fpm/cookery/hiera/defaults.rb', line 33

def hiera_config(options = {})
  # Hiera accepts a path to a configuration file or a hash; short
  # circuit if it's the former.
  return options[:config] unless options[:config].is_a?(Hash)

  {
    :logger     => hiera_logger,
    :hierarchy  => hiera_hierarchy,
    :yaml       => { :datadir  => hiera_datadir },
    :json       => { :datadir  => hiera_datadir },
    :backends   => hiera_backends
  }.merge options[:config] || {}
end

.hiera_datadirObject



26
27
28
# File 'lib/fpm/cookery/hiera/defaults.rb', line 26

def hiera_datadir
  File.join(Dir.getwd, 'config')
end

.hiera_hierarchyObject

Sets the default search hierarchy. Hiera will look for files matching “#{ENV}.yaml”, etc. Note: the including class is expected to define a recipe method that responds to platform and target.



17
18
19
# File 'lib/fpm/cookery/hiera/defaults.rb', line 17

def hiera_hierarchy
  ['common']
end

.hiera_loggerObject

This will result in Hiera using the Hiera::Fpm_cookery_logger class for logging.



9
10
11
# File 'lib/fpm/cookery/hiera/defaults.rb', line 9

def hiera_logger
  'fpm_cookery'
end