summaryrefslogtreecommitdiff
blob: cca2583494ffb1bb0dd8ade9fe13000648b3b2e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--- lib/puppet/defaults.rb.orig     2008-03-16 15:43:05.000000000 +0100
+++ lib/puppet/defaults.rb      2008-04-07 16:49:25.772991000 +0200
@@ -617,6 +617,10 @@
         :ldapclassattrs => ["puppetclass",
             "The LDAP attributes to use to define Puppet classes.  Values
             should be comma-separated."],
+        :ldapstackedattrs => ["puppetvar",
+            "The LDAP attributes that should be stacked to arrays by adding
+            the values in all hierarchy elements of the tree.  Values
+            should be comma-separated."],
         :ldapattrs => ["all",
             "The LDAP attributes to include when querying LDAP for nodes.  All
             returned attributes are set as variables in the top-level scope.
--- lib/puppet/indirector/node/ldap.rb.orig	2008-04-07 16:34:43.314125000 +0200
+++ lib/puppet/indirector/node/ldap.rb	2008-04-07 17:34:18.645503750 +0200
@@ -15,6 +15,11 @@
         return nil unless information = super
         node = Puppet::Node.new(name)
 
+        information[:stacked].each do |value|
+            param = value.split('=', 2)
+            information[:parameters][param[0]] = param[1] unless information[:parameters].include?(param[0])
+        end
+
         parent_info = nil
         parent = information[:parent]
         parents = [name]
@@ -30,6 +35,10 @@
                 raise Puppet::Error.new("Could not find parent node '%s'" % parent)
             end
             information[:classes] += parent_info[:classes]
+            parent_info[:stacked].each do |value|
+                param = value.split('=', 2)
+                information[:parameters][param[0]] = param[1] unless information[:parameters].include?(param[0])
+            end
             parent_info[:parameters].each do |param, value|
                 # Specifically test for whether it's set, so false values are handled
                 # correctly.
@@ -55,6 +64,12 @@
         end
     end
 
+    # The attributes that Puppet will stack as array over the full
+    # hierarchy.
+    def stacked_attributes
+        Puppet[:ldapstackedattrs].split(/\s*,\s*/)
+    end
+
     # Process the found entry.  We assume that we don't just want the
     # ldap object.
     def process(name, entry)
@@ -78,6 +93,14 @@
             end
         }
 
+        result[:stacked] = []
+        stacked_attributes.each { |attr|
+            if values = entry.vals(attr)
+                result[:stacked] = result[:stacked] + values
+            end
+        }
+        
+
         result[:parameters] = entry.to_hash.inject({}) do |hash, ary|
             if ary[1].length == 1
                 hash[ary[0]] = ary[1].shift