Now that ldapinfo is returning an array, we don't need nodeinfo to make
[mirror/dsa-puppet.git] / files / etc / puppet / lib / puppet / parser / functions / nodeinfo.rb
index d7f3dae..e9b72fa 100644 (file)
@@ -5,8 +5,8 @@ module Puppet::Parser::Functions
     yamlfile = args[1]
     parser.watch_file(yamlfile)
 
-    require 'ldap'
     require 'yaml'
+    require '/etc/puppet/lib/puppet/parser/functions/ldapinfo.rb'
 
     $KCODE = 'utf-8'
 
@@ -44,21 +44,7 @@ module Puppet::Parser::Functions
       end
     end
 
-    ldap = LDAP::SSLConn.new('db.debian.org', 636)
-
-    results['ldap'] = []
-    filter = '(hostname=' + host +')'
-    begin
-      ldap.search2('ou=hosts,dc=debian,dc=org', LDAP::LDAP_SCOPE_SUBTREE, filter) do |x|
-        results['ldap'] << x
-      end
-    rescue LDAP::ResultError
-      raise Puppet::ParseError, "LDAP error"
-    rescue RuntimeError
-      raise Puppet::ParseError, "No data returned from search"
-    ensure
-      ldap.unbind
-    end
+    results['ldap'] = function_ldapinfo(host, '*')
     return(results)
   end
 end