summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-13 23:36:18 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-13 23:36:18 +0000
commit15da00c2366583f54e834a11faf98d1e46f172d1 (patch)
tree823540cd45a7e848e7bd26d93d60d31238f6188d /lib
parent4a5b886f453dffefba4e9be0ab9c7fc53d2438ce (diff)
downloadpuppet-15da00c2366583f54e834a11faf98d1e46f172d1.tar.gz
puppet-15da00c2366583f54e834a11faf98d1e46f172d1.tar.xz
puppet-15da00c2366583f54e834a11faf98d1e46f172d1.zip
Fixing ldap usage when ldap libs are not available
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1268 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/interpreter.rb48
1 files changed, 28 insertions, 20 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 3eadf170d..7bfb25ea4 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -119,6 +119,9 @@ module Puppet
begin
require 'ldap'
rescue LoadError
+ Puppet.notice(
+ "Could not set up LDAP Connection: Missing ruby/ldap libraries"
+ )
@ldap = nil
return
end
@@ -174,8 +177,9 @@ module Puppet
# Find the ldap node and extra the info, returning just
# the critical data.
def nodesearch_ldap(node)
- unless defined? @ldap
- ldapconnect()
+ unless defined? @ldap and @ldap
+ Puppet.info "Skipping ldap source; no ldap connection"
+ return nil, []
end
if node =~ /\./
@@ -202,27 +206,31 @@ module Puppet
classes = []
found = false
- # We're always doing a sub here; oh well.
- @ldap.search(Puppet[:ldapbase], 2, filter, sattrs) do |entry|
- found = true
- if pattr
- if values = entry.vals(pattr)
- if values.length > 1
- raise Puppet::Error,
- "Node %s has more than one parent: %s" %
- [node, values.inspect]
- end
- unless values.empty?
- parent = values.shift
+ begin
+ # We're always doing a sub here; oh well.
+ @ldap.search(Puppet[:ldapbase], 2, filter, sattrs) do |entry|
+ found = true
+ if pattr
+ if values = entry.vals(pattr)
+ if values.length > 1
+ raise Puppet::Error,
+ "Node %s has more than one parent: %s" %
+ [node, values.inspect]
+ end
+ unless values.empty?
+ parent = values.shift
+ end
end
end
- end
- attrs.each { |attr|
- if values = entry.vals(attr)
- values.each do |v| classes << v end
- end
- }
+ attrs.each { |attr|
+ if values = entry.vals(attr)
+ values.each do |v| classes << v end
+ end
+ }
+ end
+ rescue => detail
+ raise Puppet::Error, "LDAP Search failed: %s" % detail
end
classes.flatten!