Method: Puppet::Util::Settings#set_value

Defined in:
lib/vendor/puppet/util/settings.rb

#set_value(param, value, type, options = {}) ⇒ Object



472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/vendor/puppet/util/settings.rb', line 472

def set_value(param, value, type, options = {})
  param = param.to_sym
  unless setting = @config[param]
    if options[:ignore_bad_settings]
      return
    else
      raise ArgumentError,
        "Attempt to assign a value to unknown configuration parameter #{param.inspect}"
    end
  end
  value = setting.munge(value) if setting.respond_to?(:munge)
  setting.handle(value) if setting.respond_to?(:handle) and not options[:dont_trigger_handles]
  if ReadOnly.include? param and type != :mutable_defaults
    raise ArgumentError,
      "You're attempting to set configuration parameter $#{param}, which is read-only."
  end
  type = legacy_to_mode(type, param)
  @sync.synchronize do # yay, thread-safe
    # Allow later inspection to determine if the setting was set on the
    # command line, or through some other code path.  Used for the
    # `dns_alt_names` option during cert generate. --daniel 2011-10-18
    setting.setbycli = true if type == :cli

    @values[type][param] = value
    @cache.clear

    clearused

    # Clear the list of environments, because they cache, at least, the module path.
    # We *could* preferentially just clear them if the modulepath is changed,
    # but we don't really know if, say, the vardir is changed and the modulepath
    # is defined relative to it. We need the defined?(stuff) because of loading
    # order issues.
    Puppet::Node::Environment.clear if defined?(Puppet::Node) and defined?(Puppet::Node::Environment)
  end

  value
end