diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-06-05 20:54:18 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-06-05 21:11:09 +0200 |
commit | 435b97f50bdc1c8a5e48bedf3772fcb16abb3440 (patch) | |
tree | 46fc54981fa9f752782739979f871594577202c0 /modules/base_installation | |
parent | 46fa3b9965226c805c45a0e562c963366dbae3b9 (diff) | |
download | Puppet-435b97f50bdc1c8a5e48bedf3772fcb16abb3440.tar.gz Puppet-435b97f50bdc1c8a5e48bedf3772fcb16abb3440.tar.zst Puppet-435b97f50bdc1c8a5e48bedf3772fcb16abb3440.zip |
Order ldap configuration by priority
Diffstat (limited to 'modules/base_installation')
-rw-r--r-- | modules/base_installation/lib/puppet/functions/ldap_data.rb | 16 |
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 |