aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/base_installation/lib/puppet/functions/ldap_data.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/modules/base_installation/lib/puppet/functions/ldap_data.rb b/modules/base_installation/lib/puppet/functions/ldap_data.rb
index 0c92d89..0a6d935 100644
--- a/modules/base_installation/lib/puppet/functions/ldap_data.rb
+++ b/modules/base_installation/lib/puppet/functions/ldap_data.rb
@@ -30,9 +30,19 @@ Puppet::Functions.create_function(:ldap_data) do
30 filter = "(objectclass=*)" 30 filter = "(objectclass=*)"
31 31
32 data = {} 32 data = {}
33 connection.search(base, scope, filter) do |entry| 33 data_array = connection.search2(base, scope, filter, attrs=["immaePuppetJson", "dn"]).map do |entry|
34 data_ = entry.to_hash 34 [entry["dn"].first, entry["immaePuppetJson"] || []]
35 jsons = data_["immaePuppetJson"] || [] 35 end.sort_by do |dn, json|
36 if dn == "ou=roles,ou=hosts,dc=immae,dc=eu"
37 [0, dn]
38 elsif dn.end_with?("ou=roles,ou=hosts,dc=immae,dc=eu")
39 [1, dn]
40 else
41 [2, dn]
42 end
43 end.to_h
44
45 data_array.each do |dn, jsons|
36 jsons.each do |json| 46 jsons.each do |json|
37 data.merge!(JSON.parse(json)) 47 data.merge!(JSON.parse(json))
38 end 48 end