Method: Puppet::Settings#parse_config

Defined in:
lib/puppet/settings.rb

#parse_config(text, file = "text") ⇒ Object



596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
# File 'lib/puppet/settings.rb', line 596

def parse_config(text, file = "text")
  begin
    data = @config_file_parser.parse_file(file, text, ALLOWED_SECTION_NAMES)
  rescue => detail
    Puppet.log_exception(detail, "Could not parse #{file}: #{detail}")
    return
  end

  # If we get here and don't have any data, we just return and don't muck with the current state of the world.
  return if data.nil?

  # If we get here then we have some data, so we need to clear out any
  # previous settings that may have come from config files.
  unsafe_clear(false, false)

  # Screen settings which have been deprecated and removed from puppet.conf
  # but are still valid on the command line and/or in environment.conf
  screen_non_puppet_conf_settings(data)

  # Make note of deprecated settings we will warn about later in initialization
  record_deprecations_from_puppet_conf(data)

  # And now we can repopulate with the values from our last parsing of the config files.
  @configuration_file = data

  # Determine our environment, if we have one.
  if @config[:environment]
    env = value(:environment).to_sym
  else
    env = NONE
  end

  # Call any hooks we should be calling.
  value_sets = value_sets_for(env, preferred_run_mode)
  @config.values.select(&:has_hook?).each do |setting|
    value_sets.each do |source|
      next unless source.include?(setting.name)

      # We still have to use value to retrieve the value, since
      # we want the fully interpolated value, not $vardir/lib or whatever.
      # This results in extra work, but so few of the settings
      # will have associated hooks that it ends up being less work this
      # way overall.
      if setting.call_hook_on_initialize?
        @hooks_to_call_on_application_initialization |= [setting]
      else
        setting.handle(ChainedValues.new(
          preferred_run_mode,
          env,
          value_sets,
          @config
        ).interpolate(setting.name))
      end
      break
    end
  end

  call_hooks_deferred_to_application_initialization :ignore_interpolation_dependency_errors => true
  
end