Puppet: System Administration Automated

Support

Ticket #1179: stack_ldap.patch

File stack_ldap.patch, 1.8 kB (added by wrobel, 9 months ago)
  • ldap.rb

    old new  
    1515        return nil unless information = super 
    1616        node = Puppet::Node.new(name) 
    1717 
     18        information[:stacked].each do |value| 
     19            param = value.split('=', 2) 
     20            information[:parameters][param[0]] = param[1] unless information[:parameters].include?(param[0]) 
     21        end 
     22 
    1823        parent_info = nil 
    1924        parent = information[:parent] 
    2025        parents = [name] 
     
    3035                raise Puppet::Error.new("Could not find parent node '%s'" % parent) 
    3136            end 
    3237            information[:classes] += parent_info[:classes] 
     38            parent_info[:stacked].each do |value| 
     39                param = value.split('=', 2) 
     40                information[:parameters][param[0]] = param[1] unless information[:parameters].include?(param[0]) 
     41            end 
    3342            parent_info[:parameters].each do |param, value| 
    3443                # Specifically test for whether it's set, so false values are handled 
    3544                # correctly. 
     
    5564        end 
    5665    end 
    5766 
     67    # The attributes that Puppet will stack as array over the full 
     68    # hierarchy. 
     69    def stacked_attributes 
     70        Puppet[:ldapstackedattrs].split(/\s*,\s*/) 
     71    end 
     72 
    5873    # Process the found entry.  We assume that we don't just want the 
    5974    # ldap object. 
    6075    def process(name, entry) 
     
    7893            end 
    7994        } 
    8095 
     96        result[:stacked] = [] 
     97        stacked_attributes.each { |attr| 
     98            if values = entry.vals(attr) 
     99                result[:stacked] = result[:stacked] + values 
     100            end 
     101        } 
     102         
     103 
    81104        result[:parameters] = entry.to_hash.inject({}) do |hash, ary| 
    82105            if ary[1].length == 1 
    83106                hash[ary[0]] = ary[1].shift