lib/foreman_provision/configuration.rb
# Method to load configuration form a YAML file
# @param [String] file
# @return [Hash]
Method to load configuration form a YAML file
Method to load configuration form a YAML file
def load_config(file)
      config_merged, config = {}
      if File.file?(file)
        config_merged = YAML.load_file(file)
      elsif File.directory?(file)
        config = yaml_read_dir(file)
        config_merged = config.clone
        config.each do |filepath, data|
          if !data.instance_of?(Hash) && !data.instance_of?(Array)
            next
          end
          data.each do |k, v_new|
            if v_new.is_a?(Array)
              config_merged[k] = config_merged.fetch(k, []).concat(v_new)
            else
              config_merged[k].merge!(v_new)
            end
          end
        end
      else
        raise("Unable to load file \"#{file}\" in #{__method__}")
      end
      raise(TypeError) unless config_merged.is_a?(Hash)
      @logger.debug("Foreman_config: #{config_merged}")
      config_merged
    end
def load_config ( file ) config_merged , config = { } if File . file? ( file ) config_merged = YAML . load_file ( file ) elsif File . directory? ( file ) config = yaml_read_dir ( file ) config_merged = config . clone config . each do | filepath , data | if ! data . instance_of? ( Hash ) && ! data . instance_of? ( Array ) next end data . each do | k , v_new | if v_new . is_a? ( Array ) config_merged [ k ] = config_merged . fetch ( k , [ ] ) . concat ( v_new ) else config_merged [ k ] . merge! ( v_new ) end end end else raise ( "Unable to load file \"#{file}\" in #{__method__}" ) end raise ( TypeError ) unless config_merged . is_a? ( Hash ) @logger . debug ( "Foreman_config: #{config_merged}" ) config_merged end
Method to load configuration form a YAML file
Method to load configuration form a YAML file
None
Hash
file
<not_specific>
<not_specific>
None