Sha256: bf52172faf0f6bb3c6541ba0e5d4540d3a8cc3ab71ed8e61c730c54f2dab4050
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 KB
Contents
# # module_param.rb # # This function performs a lookup for a variable value in various locations # following this order # - Hiera backend, if present (modulename prefix) # - ::corl::default::{modulename}::{varname} (configurable!!) # - ::{modulename}::default::{varname} # - {default parameter} # module Puppet::Parser::Functions newfunction(:module_param, :type => :rvalue, :doc => <<-EOS This function performs a lookup for a variable value in various locations following this order: - Hiera backend, if present (modulename prefix) - ::data::default::{modulename}_{varname} (configurable!!) - ::{modulename}::default::{varname} - {default parameter} If no value is found in the defined sources, it returns an empty string ('') EOS ) do |args| value = nil CORL.run do raise(Puppet::ParseError, "module_param(): Define at least the variable name " + "given (#{args.size} for 1)") if args.size < 1 var_name = args[0] default = ( args.size > 1 ? args[1] : '' ) options = ( args.size > 2 ? args[2] : {} ) module_name = self.source.module_name module_var_name = "#{module_name}::#{var_name}" default_var_name = "#{module_name}::default::#{var_name}" config = CORL::Config.init(options, [ :param, :module_param ], module_name, { :hiera_scope => self, :puppet_scope => self, :search => 'core::default', :search_name => false, :init_fact => 'hiera_ready', :force => true, :merge => true }) value = CORL::Config.lookup([ module_var_name, default_var_name ], default, config) end return value end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
corl-0.4.2 | lib/puppet/parser/functions/module_param.rb |
corl-0.4.1 | lib/puppet/parser/functions/module_param.rb |
corl-0.4.0 | lib/puppet/parser/functions/module_param.rb |