Merge remote-tracking branch 'origin/master' into staging
[mirror/dsa-puppet.git] / spec / octocatalog / ldap / update
diff --git a/spec/octocatalog/ldap/update b/spec/octocatalog/ldap/update
new file mode 100755 (executable)
index 0000000..4eac4d7
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/ruby
+
+require 'ldap'
+
+results = {}
+ldap = LDAP::SSLConn.new('db.debian.org', 636)
+ldap.search2('ou=hosts,dc=debian,dc=org', LDAP::LDAP_SCOPE_SUBTREE, '(hostname=*)', attrs='*', false, 0, 0).each do |x|
+  results[x['hostname'][0]] = x
+end
+
+open('ldapinfo.rb', 'w') do |f|
+  f.puts <<EOF
+module Puppet::Parser::Functions
+  newfunction(:ldapinfo, :type => :rvalue) do |attributes|
+    host = attributes.shift
+    results = #{results.to_s}
+    if host == '*'
+      return(results)
+    else
+      return(results[host])
+    end
+  end
+end
+EOF
+end