summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-12-17 19:58:27 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-12-20 09:15:36 +1100
commit813cb58815f1f8f987ad64f7c7bfb640fbcdfa81 (patch)
treec93b3ce57cc66d6cca3eb8e43d50e087b335b050 /lib/puppet
parente9a0cb7a28a34fd04db4bfe1db347da5d774f2e8 (diff)
downloadpuppet-813cb58815f1f8f987ad64f7c7bfb640fbcdfa81.tar.gz
puppet-813cb58815f1f8f987ad64f7c7bfb640fbcdfa81.tar.xz
puppet-813cb58815f1f8f987ad64f7c7bfb640fbcdfa81.zip
Fix for #2765 (--no-fqdn regression in puppetrun)
This is basically the fix suggested on the ticket, cleaned up and ruby-ized, with tests. The only functional modification is leaving the default on entry2hash as --no-fqdn to preserve 0.25.1 behaviour as the default. Signed- ff-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/application/puppetrun.rb4
-rw-r--r--lib/puppet/indirector/node/ldap.rb9
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/puppet/application/puppetrun.rb b/lib/puppet/application/puppetrun.rb
index 41ebf9f1a..4febcf524 100644
--- a/lib/puppet/application/puppetrun.rb
+++ b/lib/puppet/application/puppetrun.rb
@@ -167,12 +167,12 @@ Puppet::Application.new(:puppetrun) do
if Puppet[:node_terminus] == "ldap" and (options[:all] or @classes)
if options[:all]
- @hosts = Puppet::Node.search("whatever").collect { |node| node.name }
+ @hosts = Puppet::Node.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name }
puts "all: %s" % @hosts.join(", ")
else
@hosts = []
@classes.each do |klass|
- list = Puppet::Node.search("whatever", :class => klass).collect { |node| node.name }
+ list = Puppet::Node.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name }
puts "%s: %s" % [klass, list.join(", ")]
@hosts += list
diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb
index dd8cebfac..954bc8d78 100644
--- a/lib/puppet/indirector/node/ldap.rb
+++ b/lib/puppet/indirector/node/ldap.rb
@@ -55,7 +55,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
end
infos = []
- ldapsearch(filter) { |entry| infos << entry2hash(entry) }
+ ldapsearch(filter) { |entry| infos << entry2hash(entry, request.options[:fqdn]) }
return infos.collect do |info|
info2node(info[:name], info)
@@ -78,9 +78,12 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
end
# Convert the found entry into a simple hash.
- def entry2hash(entry)
+ def entry2hash(entry, fqdn = false)
result = {}
- result[:name] = entry.dn.split(',')[0].split("=")[1]
+
+ cn = entry.dn[ /cn\s*=\s*([^,\s]+)/i,1]
+ dcs = entry.dn.scan(/dc\s*=\s*([^,\s]+)/i)
+ result[:name] = fqdn ? ([cn]+dcs).join('.') : cn
result[:parent] = get_parent_from_entry(entry) if parent_attribute
result[:classes] = get_classes_from_entry(entry)
result[:stacked] = get_stacked_values_from_entry(entry)