From 422dea05e755f0026c7786b46a7e93624da1ac0a Mon Sep 17 00:00:00 2001 From: Andrew Shafer Date: Mon, 16 Jun 2008 02:05:38 -0600 Subject: issue 1183 Added environment awareness to --configprint Pulled the logic for --configprint --genconfig and --genmanifest out of puppet.rb Put the logic in lib/puppet/util/settings.rb and refactored it a bit Added specs for the behavior Reformated the whole spec file to use nested describe Added the new method to the executables The old behavior should be preserved, except for the env is now used --- bin/puppet | 5 +++-- bin/puppetca | 5 +++-- bin/puppetd | 5 +++-- bin/puppetmasterd | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/puppet b/bin/puppet index bb7308997..23b175087 100755 --- a/bin/puppet +++ b/bin/puppet @@ -141,8 +141,9 @@ if Puppet[:config] and File.exists? Puppet[:config] Puppet.settings.parse(Puppet[:config]) end -Puppet.genconfig -Puppet.genmanifest +if Puppet.settings.print_configs? + exit(Puppet.settings.print_configs ? 0 : 1) +end # If noop is set, then also enable diffs if Puppet[:noop] diff --git a/bin/puppetca b/bin/puppetca index 759b602ac..9d88a564e 100755 --- a/bin/puppetca +++ b/bin/puppetca @@ -171,8 +171,9 @@ end # Now parse the config Puppet.parse_config -Puppet.genconfig -Puppet.genmanifest +if Puppet.settings.print_configs? + exit(Puppet.settings.print_configs ? 0 : 1) +end begin ca = Puppet::SSLCertificates::CA.new() diff --git a/bin/puppetd b/bin/puppetd index 2a71c3a8d..0813745cc 100755 --- a/bin/puppetd +++ b/bin/puppetd @@ -299,8 +299,9 @@ unless options[:setdest] Puppet::Util::Log.newdestination(:syslog) end -Puppet.genconfig -Puppet.genmanifest +if Puppet.settings.print_configs? + exit(Puppet.settings.print_configs ? 0 : 1) +end # If noop is set, then also enable diffs if Puppet[:noop] diff --git a/bin/puppetmasterd b/bin/puppetmasterd index b4733e604..03bd78455 100755 --- a/bin/puppetmasterd +++ b/bin/puppetmasterd @@ -182,8 +182,9 @@ unless options[:setdest] Puppet::Util::Log.newdestination(:syslog) end -Puppet.genconfig -Puppet.genmanifest +if Puppet.settings.print_configs? + exit(Puppet.settings.print_configs ? 0 : 1) +end # A temporary solution, to at least make the master work for now. Puppet::Node::Facts.terminus_class = :yaml -- cgit From 9c1ab147b3570003bb7907d8a0cadca52869f4bd Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 17 Jun 2008 09:43:45 +1000 Subject: Fixed #1371 - Updated bin/puppet to use Node.find --- bin/puppet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/puppet b/bin/puppet index 23b175087..5e10ad460 100755 --- a/bin/puppet +++ b/bin/puppet @@ -187,7 +187,7 @@ facts = Puppet::Node::Facts.find("me") facts.name = facts.values["hostname"] # Find our Node -node = Puppet::Node.find_by_any_name(facts.name) +node = Puppet::Node.find(facts.name) # Merge in the facts. node.merge(facts.values) -- cgit From d3a81255245eec19ac21902ae3b877e00e620628 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 1 Jul 2008 22:20:55 -0500 Subject: Fixed #1006 - puppetrun --class works again. I added the class membership testing to the Ldap node terminus, and added tests, --- bin/puppetrun | 48 +++++------------------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) (limited to 'bin') 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 -- cgit