summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-01 22:20:55 -0500
committerLuke Kanies <luke@madstop.com>2008-07-01 22:22:36 -0500
commitd3a81255245eec19ac21902ae3b877e00e620628 (patch)
tree7e9fcbda35b2c6ac88865e80bb7e449176ec2cb0
parentc1e010fb7dfe4666b3db3d958627f70f7325cf85 (diff)
downloadpuppet-d3a81255245eec19ac21902ae3b877e00e620628.tar.gz
puppet-d3a81255245eec19ac21902ae3b877e00e620628.tar.xz
puppet-d3a81255245eec19ac21902ae3b877e00e620628.zip
Fixed #1006 - puppetrun --class works again. I added the class
membership testing to the Ldap node terminus, and added tests,
-rw-r--r--CHANGELOG4
-rwxr-xr-xbin/puppetrun48
2 files changed, 9 insertions, 43 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ae490cf8f..bdf722be5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,8 @@
0.24.?
+ Fixed #1006 - puppetrun --class works again. I added the class
+ membership testing to the Ldap node terminus, and added tests,
+ so it shouldn't break again.
+
Fixed #1114 - Facts in plugin directories should now be autoloaded,
as long as you're using Facter 1.5.
diff --git a/bin/puppetrun b/bin/puppetrun
index d0823b9c5..f1e30245b 100755
--- a/bin/puppetrun
+++ b/bin/puppetrun
@@ -139,51 +139,12 @@ begin
rescue LoadError
$stderr.puts "Failed to load ruby LDAP library. LDAP functionality will not be available"
end
+
require 'puppet'
require 'puppet/network/client'
+require 'puppet/util/ldap/connection'
require 'getoptlong'
-
-# Look up all nodes matching a given class in LDAP.
-def ldapnodes(klass, fqdn = true)
- unless defined? @ldap
- setupldap()
- end
-
- hosts = []
-
- filter = nil
- if klass == :all
- filter = "objectclass=puppetclient"
- else
- filter = "puppetclass=#{klass}"
- end
- @ldap.search(Puppet[:ldapbase], 2, filter, "cn") do |entry|
- # Skip the default host entry
- if entry.dn =~ /cn=default,/
- $stderr.puts "Skipping default host entry"
- next
- end
-
- if fqdn
- hosts << entry.dn.sub("cn=",'').sub(/ou=hosts,/i, '').gsub(",dc=",".")
- else
- hosts << entry.get_values("cn")[0]
- end
- end
-
- return hosts
-end
-
-def setupldap
- begin
- @ldap = Puppet::Parser::Interpreter.ldap()
- rescue => detail
- $stderr.puts "Could not connect to LDAP: %s" % detail
- exit(34)
- end
-end
-
flags = [
[ "--all", "-a", GetoptLong::NO_ARGUMENT ],
[ "--tag", "-t", GetoptLong::REQUIRED_ARGUMENT ],
@@ -278,11 +239,12 @@ Puppet.parse_config
if Puppet[:node_terminus] = "ldap"
if options[:all]
- hosts = ldapnodes(:all, options[:fqdn])
+ hosts = Puppet::Node.search("whatever").collect { |node| node.name }
puts "all: %s" % hosts.join(", ")
else
+ hosts = []
classes.each do |klass|
- list = ldapnodes(klass, options[:fqdn])
+ list = Puppet::Node.search("whatever", :class => klass).collect { |node| node.name }
puts "%s: %s" % [klass, list.join(", ")]
hosts += list