From 441879f7999f4724e8ab344e796015a7ffbfb21b Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 14 Jan 2010 14:14:19 +1100 Subject: Revert "Fix #2845 Cron entries using "special" parameter lose their title when changed" This reverts commit c99f394bf8c10d13f3fa7d3ab7ab43ecf454c081. The fix broke cron jobs in 0.25.3 and was reverted for the 0.25.4 release. --- lib/puppet/provider/cron/crontab.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb index 28ef05974..6dee2e515 100755 --- a/lib/puppet/provider/cron/crontab.rb +++ b/lib/puppet/provider/cron/crontab.rb @@ -27,13 +27,18 @@ Puppet::Type.type(:cron).provide(:crontab, text_line :environment, :match => %r{^\w+=} - crontab = record_line :crontab, :fields => %w{special minute hour monthday month weekday command}, - :match => %r{^\s*(?:@(\w+)|(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+))\s+(.+)$}, - :optional => %w{special minute hour weekday month monthday}, :absent => "*" + record_line :freebsd_special, :fields => %w{special command}, + :match => %r{^@(\w+)\s+(.+)$}, :pre_gen => proc { |record| + record[:special] = "@" + record[:special] + } + + crontab = record_line :crontab, :fields => %w{minute hour monthday month weekday command}, + :match => %r{^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$}, + :optional => %w{minute hour weekday month monthday}, :absent => "*" class << crontab def numeric_fields - fields - [:command, :special] + fields - [:command] end # Do some post-processing of the parsed record. Basically just # split the numeric fields on ','. -- cgit From 67216aa5637a0e134750103abb74b5c2e3db3eb6 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Fri, 15 Jan 2010 14:31:22 -0800 Subject: Fix for #3075 (sshkey host_aliases ignored) In the alias --> host_aliases conversion, I overlooked parsed file provider for sshkeys. Now with tests. --- lib/puppet/provider/sshkey/parsed.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb index 4673b5731..e84e3e5c5 100755 --- a/lib/puppet/provider/sshkey/parsed.rb +++ b/lib/puppet/provider/sshkey/parsed.rb @@ -21,14 +21,14 @@ Puppet::Type.type(:sshkey).provide(:parsed, :post_parse => proc { |hash| names = hash[:name].split(",", -1) hash[:name] = names.shift - hash[:alias] = names + hash[:host_aliases] = names }, :pre_gen => proc { |hash| - if hash[:alias] - names = [hash[:name], hash[:alias]].flatten + if hash[:host_aliases] + names = [hash[:name], hash[:host_aliases]].flatten - hash[:name] = [hash[:name], hash[:alias]].flatten.join(",") - hash.delete(:alias) + hash[:name] = [hash[:name], hash[:host_aliases]].flatten.join(",") + hash.delete(:host_aliases) end } end -- cgit From cdcbdc78bc399a60afaf36b6267688e72081fb6e Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 18 Jan 2010 17:26:06 -0800 Subject: Fixing #2914 - pre/post hooks now work for transactions This was built to be used with etckeeper to version control files in /etc, but can be used for essentially anything. This patch was built to be added to 0.25.4, so it's a least-modify approach. A better approach would be to refactor application/puppet.rb just a bit so it uses Configurer more. This is a simple patch - it just defines 'prerun_command' and 'postrun_command' settings, and runs the appropriate command around each transaction if they're set. Signed-off-by: Luke Kanies --- lib/puppet/application/puppet.rb | 10 +++++++--- lib/puppet/configurer.rb | 24 ++++++++++++++++++++++++ lib/puppet/defaults.rb | 7 ++++++- 3 files changed, 37 insertions(+), 4 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/application/puppet.rb b/lib/puppet/application/puppet.rb index 2929d54e8..273c7d0e7 100644 --- a/lib/puppet/application/puppet.rb +++ b/lib/puppet/application/puppet.rb @@ -1,5 +1,6 @@ require 'puppet' require 'puppet/application' +require 'puppet/configurer' require 'puppet/network/handler' require 'puppet/network/client' @@ -124,9 +125,14 @@ Puppet::Application.new(:puppet) do catalog.retrieval_duration = Time.now - starttime + configurer = Puppet::Configurer.new + configurer.execute_prerun_command + # And apply it transaction = catalog.apply + configurer.execute_postrun_command + status = 0 if not Puppet[:noop] and options[:detailed_exitcodes] then transaction.generate_report @@ -135,9 +141,7 @@ Puppet::Application.new(:puppet) do end exit(status) rescue => detail - if Puppet[:trace] - puts detail.backtrace - end + puts detail.backtrace if Puppet[:trace] if detail.is_a?(XMLRPC::FaultException) $stderr.puts detail.message else diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index 3e72fa574..ec61272ef 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -5,6 +5,8 @@ require 'puppet/network/http_pool' require 'puppet/util' class Puppet::Configurer + class CommandHookError < RuntimeError; end + require 'puppet/configurer/fact_handler' require 'puppet/configurer/plugin_handler' @@ -39,6 +41,14 @@ class Puppet::Configurer @catalog = nil end + def execute_postrun_command + execute_from_setting(:postrun_command) + end + + def execute_prerun_command + execute_from_setting(:prerun_command) + end + # Initialize and load storage def dostorage begin @@ -75,6 +85,8 @@ class Puppet::Configurer download_plugins() download_fact_plugins() + + execute_prerun_command end # Get the remote catalog, yo. Returns nil if no catalog can be found. @@ -160,6 +172,8 @@ class Puppet::Configurer # Now close all of our existing http connections, since there's no # reason to leave them lying open. Puppet::Network::HttpPool.clear_http_instances + ensure + execute_postrun_command end private @@ -180,4 +194,14 @@ class Puppet::Configurer return timeout end + + def execute_from_setting(setting) + return if (command = Puppet[setting]) == "" + + begin + Puppet::Util.execute([command]) + rescue => detail + raise CommandHookError, "Could not run command from #{setting}: #{detail}" + end + end end diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 6b9c43b81..21cee7a05 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -199,7 +199,12 @@ module Puppet reports, allowing you to correlate changes on your hosts to the source version on the server."], :zlib => [true, "Boolean; whether to use the zlib library", - ] + ], + :prerun_command => ["", "A command to run before every agent run. If this command returns a non-zero + return code, the entire Puppet run will fail."], + :postrun_command => ["", "A command to run after every agent run. If this command returns a non-zero + return code, the entire Puppet run will be considered to have failed, even though it might have + performed work during the normal run."] ) hostname = Facter["hostname"].value -- cgit From d4319a5418ce84ac83f9137cf1b7255210833eb4 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Tue, 19 Jan 2010 15:14:37 -0800 Subject: Minimal fix for #3001 (failing to fetch metadata on dangling symlink) FileTest.exists? returns false if the target of a symlink is missing; in such cases we still want to continue if the resource is a symlink, as we may be managing a dangling symlink. Continuing in such case either gives the desired behavior or a more specific/informative error message. --- lib/puppet/file_serving/mount/file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index 4309ef79a..197a7206c 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -25,7 +25,7 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount file = ::File.join(full_path, relative_path) - if ! FileTest.exist?(file) + if !(FileTest.exist?(file) )# or FileTest.symlink?(file)) Puppet.info("File does not exist or is not accessible: #{file}") return nil end -- cgit From 94e269cbc98e774630426aa0a0dc70c1db82502d Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Wed, 20 Jan 2010 08:00:09 -0800 Subject: Uncommeniting the fix for #3001 --- lib/puppet/file_serving/mount/file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index 197a7206c..e1eaf6052 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -25,7 +25,7 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount file = ::File.join(full_path, relative_path) - if !(FileTest.exist?(file) )# or FileTest.symlink?(file)) + if !(FileTest.exist?(file) or FileTest.symlink?(file)) Puppet.info("File does not exist or is not accessible: #{file}") return nil end -- cgit From 75634b72629c4ed308444d64341dc909d1ab497e Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Wed, 20 Jan 2010 15:33:36 -0800 Subject: Fix for #3093 (also need to be able to call pkgget_with_cat on class) Fixed to deal with scopig issues. --- lib/puppet/provider/package/blastwave.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/package/blastwave.rb b/lib/puppet/provider/package/blastwave.rb index cf2c87bfe..9b2bbf6a5 100755 --- a/lib/puppet/provider/package/blastwave.rb +++ b/lib/puppet/provider/package/blastwave.rb @@ -11,7 +11,7 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun commands :pkgget => pkgget def pkgget_with_cat(*args) - withenv(:PAGER => "/usr/bin/cat") { pkgget(*args) } + Puppet::Util::Execution::withenv(:PAGER => "/usr/bin/cat") { pkgget(*args) } end def self.extended(mod) @@ -41,7 +41,7 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun command << hash[:justme] end - output = pkgget_with_cat command + output = Puppet::Util::Execution::withenv(:PAGER => "/usr/bin/cat") { pkgget command } list = output.split("\n").collect do |line| next if line =~ /^#/ -- cgit From a91c476387887baa5920f5539a7c4acfaf8cecd9 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Thu, 21 Jan 2010 16:03:26 -0800 Subject: Fix for #3088 (catching Exception also traps SystemExit) Changing rescues from the default to Exception (to catch errors that don't descend from StandardError) had the unintended consequence of catching (and suppressing) SystemExit. This patch restores the behavior of by reraising the exception. Of the other exceptions that fall through the same crack (NoMemoryError, SignalException, LoadError, Interrupt, NotImplementedError, and ScriptError) this patch also reraises NoMemoryError, SignalException, and Interrupt in the same way and leaves the rest captured. --- lib/puppet/agent.rb | 4 ++++ lib/puppet/configurer.rb | 4 ++++ lib/puppet/configurer/fact_handler.rb | 2 ++ lib/puppet/configurer/plugin_handler.rb | 2 ++ lib/puppet/indirector/facts/facter.rb | 2 ++ lib/puppet/indirector/ldap.rb | 2 ++ lib/puppet/network/http/handler.rb | 2 ++ lib/puppet/network/xmlrpc/client.rb | 2 ++ lib/puppet/provider/augeas/augeas.rb | 4 ++++ lib/puppet/ssl/host.rb | 2 ++ lib/puppet/util/autoload.rb | 4 ++++ lib/puppet/util/feature.rb | 2 ++ 12 files changed, 32 insertions(+) (limited to 'lib/puppet') diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb index 789660585..5dbb15227 100644 --- a/lib/puppet/agent.rb +++ b/lib/puppet/agent.rb @@ -51,6 +51,8 @@ class Puppet::Agent with_client do |client| begin sync.synchronize { lock { client.run(*args) } } + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not run %s: %s" % [client_class, detail] @@ -122,6 +124,8 @@ class Puppet::Agent def with_client begin @client = client_class.new + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not create instance of %s: %s" % [client_class, detail] diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index ec61272ef..56217d658 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -105,6 +105,8 @@ class Puppet::Configurer duration = thinmark do result = catalog_class.find(name, fact_options.merge(:ignore_cache => true)) end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not retrieve catalog from remote server: %s" % detail @@ -148,6 +150,8 @@ class Puppet::Configurer def run(options = {}) begin prepare() + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Failed to prepare catalog: %s" % detail diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index 40e79b6c6..a05d89060 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -17,6 +17,8 @@ module Puppet::Configurer::FactHandler begin reload_facter() Puppet::Node::Facts.find(Puppet[:certname]) + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] raise Puppet::Error, "Could not retrieve local facts: %s" % detail diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb index e934f5877..856942176 100644 --- a/lib/puppet/configurer/plugin_handler.rb +++ b/lib/puppet/configurer/plugin_handler.rb @@ -19,6 +19,8 @@ module Puppet::Configurer::PluginHandler begin Puppet.info "Loading downloaded plugin %s" % file load file + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail Puppet.err "Could not load downloaded file %s: %s" % [file, detail] end diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index 6c6cbc6be..2caeeede2 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -29,6 +29,8 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code Timeout::timeout(self.timeout) do load file end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail Puppet.warning "Could not load fact file %s: %s" % [fqfile, detail] end diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb index 51bab0e6e..31ee0e020 100644 --- a/lib/puppet/indirector/ldap.rb +++ b/lib/puppet/indirector/ldap.rb @@ -40,6 +40,8 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus found = true yield entry end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail if count == 0 # Try reconnecting to ldap if we get an exception and we haven't yet retried. diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index 65bb0f82c..4d9634f79 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -66,6 +66,8 @@ module Puppet::Network::HTTP::Handler check_authorization(indirection_request) send("do_%s" % indirection_request.method, indirection_request, request, response) + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => e return do_exception(response, e) end diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb index ee2c008eb..805d99324 100644 --- a/lib/puppet/network/xmlrpc/client.rb +++ b/lib/puppet/network/xmlrpc/client.rb @@ -144,6 +144,8 @@ module Puppet::Network Puppet.debug "Calling %s.%s" % [namespace, method] begin call("%s.%s" % [namespace, method.to_s],*args) + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail retry if self.class.error_handler(detail).execute(self, detail, namespace, method) == :retry end diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index a645fbe8a..748c84e7d 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -254,6 +254,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do when "get"; return_value = process_get(cmd_array) when "match"; return_value = process_match(cmd_array) end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => e fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}") end @@ -335,6 +337,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do aug.insert(path, label, before) else fail("Command '#{command}' is not supported") end + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => e fail("Error sending command '#{command}' with params #{cmd_array.inspect}/#{e.message}") end diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb index 75e51e5c8..d6bbc4e5d 100644 --- a/lib/puppet/ssl/host.rb +++ b/lib/puppet/ssl/host.rb @@ -220,6 +220,8 @@ class Puppet::SSL::Host return if certificate generate return if certificate + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail Puppet.err "Could not request certificate: %s" % detail.to_s if time < 1 diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index ec2f48c7b..142ff293f 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -86,6 +86,8 @@ class Puppet::Util::Autoload name = symbolize(name) loaded name, file return true + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail # I have no idea what's going on here, but different versions # of ruby are raising different errors on missing files. @@ -123,6 +125,8 @@ class Puppet::Util::Autoload begin Kernel.require file loaded(name, file) + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception => detail if Puppet[:trace] puts detail.backtrace diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb index add1b2691..8f77a2724 100644 --- a/lib/puppet/util/feature.rb +++ b/lib/puppet/util/feature.rb @@ -83,6 +83,8 @@ class Puppet::Util::Feature begin require lib + rescue SystemExit,NoMemoryError,SignalException,Interrupt + raise rescue Exception Puppet.debug "Failed to load library '%s' for feature '%s'" % [lib, name] return false -- cgit From 0025e13792b6a8e010ce1fd1dc20a17e7ba8af53 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sun, 24 Jan 2010 18:32:25 -0800 Subject: Partial reversion of patch for #3088 to fix #3104 (Exception misreported) In my patch for #3088 I made a erroneous assumption about the ruby exception hierarchy and thus missed the fact that Timeout::error descends from both SignalError and Interrupt. This is a partial reversion of the patch for #3088 to let these through so that more useful error messages can be produced. --- lib/puppet/agent.rb | 4 ++-- lib/puppet/configurer.rb | 4 ++-- lib/puppet/configurer/fact_handler.rb | 2 +- lib/puppet/configurer/plugin_handler.rb | 2 +- lib/puppet/indirector/facts/facter.rb | 2 +- lib/puppet/indirector/ldap.rb | 2 +- lib/puppet/network/http/handler.rb | 2 +- lib/puppet/network/xmlrpc/client.rb | 2 +- lib/puppet/provider/augeas/augeas.rb | 4 ++-- lib/puppet/ssl/host.rb | 2 +- lib/puppet/util/autoload.rb | 4 ++-- lib/puppet/util/feature.rb | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb index 5dbb15227..c188719ba 100644 --- a/lib/puppet/agent.rb +++ b/lib/puppet/agent.rb @@ -51,7 +51,7 @@ class Puppet::Agent with_client do |client| begin sync.synchronize { lock { client.run(*args) } } - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] @@ -124,7 +124,7 @@ class Puppet::Agent def with_client begin @client = client_class.new - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index 56217d658..61c6f0251 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -105,7 +105,7 @@ class Puppet::Configurer duration = thinmark do result = catalog_class.find(name, fact_options.merge(:ignore_cache => true)) end - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] @@ -150,7 +150,7 @@ class Puppet::Configurer def run(options = {}) begin prepare() - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index a05d89060..72bd76e1f 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -17,7 +17,7 @@ module Puppet::Configurer::FactHandler begin reload_facter() Puppet::Node::Facts.find(Puppet[:certname]) - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb index 856942176..9e1c113f9 100644 --- a/lib/puppet/configurer/plugin_handler.rb +++ b/lib/puppet/configurer/plugin_handler.rb @@ -19,7 +19,7 @@ module Puppet::Configurer::PluginHandler begin Puppet.info "Loading downloaded plugin %s" % file load file - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail Puppet.err "Could not load downloaded file %s: %s" % [file, detail] diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index 2caeeede2..b5787ddf6 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -29,7 +29,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code Timeout::timeout(self.timeout) do load file end - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail Puppet.warning "Could not load fact file %s: %s" % [fqfile, detail] diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb index 31ee0e020..ab3c7ef54 100644 --- a/lib/puppet/indirector/ldap.rb +++ b/lib/puppet/indirector/ldap.rb @@ -40,7 +40,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus found = true yield entry end - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail if count == 0 diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index 4d9634f79..444fbf7e7 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -66,7 +66,7 @@ module Puppet::Network::HTTP::Handler check_authorization(indirection_request) send("do_%s" % indirection_request.method, indirection_request, request, response) - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => e return do_exception(response, e) diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb index 805d99324..9faa71c8b 100644 --- a/lib/puppet/network/xmlrpc/client.rb +++ b/lib/puppet/network/xmlrpc/client.rb @@ -144,7 +144,7 @@ module Puppet::Network Puppet.debug "Calling %s.%s" % [namespace, method] begin call("%s.%s" % [namespace, method.to_s],*args) - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail retry if self.class.error_handler(detail).execute(self, detail, namespace, method) == :retry diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index 748c84e7d..8dccb4e9d 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -254,7 +254,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do when "get"; return_value = process_get(cmd_array) when "match"; return_value = process_match(cmd_array) end - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => e fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}") @@ -337,7 +337,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do aug.insert(path, label, before) else fail("Command '#{command}' is not supported") end - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => e fail("Error sending command '#{command}' with params #{cmd_array.inspect}/#{e.message}") diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb index d6bbc4e5d..7d34a4fde 100644 --- a/lib/puppet/ssl/host.rb +++ b/lib/puppet/ssl/host.rb @@ -220,7 +220,7 @@ class Puppet::SSL::Host return if certificate generate return if certificate - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail Puppet.err "Could not request certificate: %s" % detail.to_s diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index 142ff293f..51fdaadad 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -86,7 +86,7 @@ class Puppet::Util::Autoload name = symbolize(name) loaded name, file return true - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail # I have no idea what's going on here, but different versions @@ -125,7 +125,7 @@ class Puppet::Util::Autoload begin Kernel.require file loaded(name, file) - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception => detail if Puppet[:trace] diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb index 8f77a2724..6218eabf4 100644 --- a/lib/puppet/util/feature.rb +++ b/lib/puppet/util/feature.rb @@ -83,7 +83,7 @@ class Puppet::Util::Feature begin require lib - rescue SystemExit,NoMemoryError,SignalException,Interrupt + rescue SystemExit,NoMemoryError raise rescue Exception Puppet.debug "Failed to load library '%s' for feature '%s'" % [lib, name] -- cgit From 1f086c28118075aa8cccc2edcdd44ae64b3a5750 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Thu, 28 Jan 2010 10:06:06 -0800 Subject: Fix for #3114 (ruby's arbitrary limit on process groups too low) In some circumstances ruby's arbitrary limit on process groups is too low (32). This patch raises the limit in the recommended manner, to a value which should suffice in all practical cases (1024). --- lib/puppet/util/monkey_patches.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/puppet') diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb index 6e438bc73..7ce1ccc1c 100644 --- a/lib/puppet/util/monkey_patches.rb +++ b/lib/puppet/util/monkey_patches.rb @@ -1,3 +1,4 @@ +Process.maxgroups = 1024 module RDoc def self.caller(skip=nil) in_gem_wrapper = false -- cgit From 49a718539c9f896d01a757e4f8b3ddb21edec0da Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Thu, 21 Jan 2010 17:13:22 -0800 Subject: Fix for #3085 (user_role_add pulls from same source as useradd) --- lib/puppet/provider/user/user_role_add.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb index 278893724..aa01f8e52 100644 --- a/lib/puppet/provider/user/user_role_add.rb +++ b/lib/puppet/provider/user/user_role_add.rb @@ -1,6 +1,6 @@ require 'puppet/util/user_attr' -Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd do +Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source => :useradd do desc "User management inherits ``useradd`` and adds logic to manage roles on Solaris using roleadd." -- cgit From 9419c2ba9553d2ed88e7435ea7becc0783024af2 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Mon, 25 Jan 2010 13:17:42 -0800 Subject: Fix for #3035 (redhat services use init for source) Redhat services generated a slew of errors because they "duplicated" the same services from the init provider on which the redhat provider is based (cf yum). Declaring the source suppresses these erroneous errors. --- lib/puppet/provider/service/redhat.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index 211b66956..45a9074e6 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -1,6 +1,6 @@ # Manage Red Hat services. Start/stop uses /sbin/service and enable/disable uses chkconfig -Puppet::Type.type(:service).provide :redhat, :parent => :init do +Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init do desc "Red Hat's (and probably many others) form of ``init``-style service management: Uses ``chkconfig`` for service enabling and disabling. -- cgit From b473264fe76f92b8eddeed7175c4283c9f8484d2 Mon Sep 17 00:00:00 2001 From: Jesse Wolfe Date: Tue, 29 Dec 2009 13:31:35 -0800 Subject: Fix #1842 Net::HTTP#enable_post_connection_check doesn't work anymore The setting enable_post_connection_check doesn't exist on very many versions of ruby, and on those systems there's no way to disable domain name checking on HTTPS. The recommended work-around is to replace certificates when they have incorrect hostnames. Signed-off-by: Jesse Wolfe --- lib/puppet/defaults.rb | 3 --- lib/puppet/network/http_pool.rb | 2 -- 2 files changed, 5 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 21cee7a05..d4a5a189d 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -159,9 +159,6 @@ module Puppet may need to use a FQDN for the server hostname when using a proxy."], :http_proxy_port => [3128, "The HTTP proxy port to use for outgoing connections"], - :http_enable_post_connection_check => [true, - "Boolean; whether or not puppetd should validate the server - SSL certificate against the request hostname."], :filetimeout => [ 15, "The minimum time to wait (in seconds) between checking for updates in configuration files. This timeout determines how quickly Puppet checks whether diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb index 6de204a80..4789d4704 100644 --- a/lib/puppet/network/http_pool.rb +++ b/lib/puppet/network/http_pool.rb @@ -94,8 +94,6 @@ module Puppet::Network::HttpPool # Use configured timeout (#1176) http.read_timeout = Puppet[:configtimeout] http.open_timeout = Puppet[:configtimeout] - # JJM Configurable fix for #896. - http.enable_post_connection_check = Puppet[:http_enable_post_connection_check] cert_setup(http) -- cgit From f9e05a8062423cf0e4dd6dca2050a8c7d4b2e85d Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Fri, 22 Jan 2010 12:55:14 -0800 Subject: Fix for #3094 (libdir should take ":" delimited path) Actually, File::PATH_SEPARATOR, which is generally, but not always, ":"). Since libdir is also the default for the plugin handler, users will need to specify it explicitly if a multipart libdir is given (and it will need to be one of the segments given in the libdir for the plugins to be found). --- lib/puppet/util/autoload.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index 51fdaadad..ceaabe46a 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -156,7 +156,7 @@ class Puppet::Util::Autoload end end - def search_directories - [module_directories, Puppet[:libdir], $:].flatten + def search_directories(dummy_argument=:work_arround_for_ruby_GC_bug) + [module_directories, Puppet[:libdir].split(File::PATH_SEPARATOR), $:].flatten end end -- cgit From 2ae7516d77c57c2c26c7afca1e8b825f307887c1 Mon Sep 17 00:00:00 2001 From: Bryan Kearney Date: Mon, 1 Feb 2010 12:24:01 -0500 Subject: 2047: Add a not_include into match --- lib/puppet/provider/augeas/augeas.rb | 4 ++++ lib/puppet/type/augeas.rb | 1 + 2 files changed, 5 insertions(+) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index 8dccb4e9d..ac11bbf28 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -39,6 +39,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do "match" => [ :path, :glob ], "size" => [:comparator, :int], "include" => [:string], + "not_include" => [:string], "==" => [:glob], "!=" => [:glob] } @@ -206,6 +207,9 @@ Puppet::Type.type(:augeas).provide(:augeas) do when "include" arg = clause_array.shift return_value = result.include?(arg) + when "not_include" + arg = clause_array.shift + return_value = !result.include?(arg) when "==" begin arg = clause_array.shift diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb index 4ae3f06e1..cfd1da55b 100644 --- a/lib/puppet/type/augeas.rb +++ b/lib/puppet/type/augeas.rb @@ -71,6 +71,7 @@ Puppet::Type.newtype(:augeas) do get [AUGEAS_PATH] [COMPARATOR] [STRING] match [MATCH_PATH] size [COMPARATOR] [INT] match [MATCH_PATH] include [STRING] + match [MATCH_PATH] not_include [STRING] match [MATCH_PATH] == [AN_ARRAY] match [MATCH_PATH] != [AN_ARRAY] -- cgit From 8a3a2056c82c7d0313a052fef00d3a8f039fe0db Mon Sep 17 00:00:00 2001 From: Bryan Kearney Date: Mon, 1 Feb 2010 15:02:24 -0500 Subject: Fix for #2327, check the return types from augeas and fail where appropriate --- lib/puppet/provider/augeas/augeas.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index ac11bbf28..d586fc1e1 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -197,6 +197,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do #Get the values from augeas result = @aug.match(path) || [] + fail("Error trying to match path '#{path}'") if (result == -1) + # Now do the work case verb when "size" @@ -321,13 +323,16 @@ Puppet::Type.type(:augeas).provide(:augeas) do case command when "set" debug("sending command '#{command}' with params #{cmd_array.inspect}") - aug.set(cmd_array[0], cmd_array[1]) + rv = aug.set(cmd_array[0], cmd_array[1]) + fail("Error sending command '#{command}' with params #{cmd_array.inspect}/#{e.message}") if (rv) when "rm", "remove" debug("sending command '#{command}' with params #{cmd_array.inspect}") - aug.rm(cmd_array[0]) + rv = aug.rm(cmd_array[0]) + fail("Error sending command '#{command}' with params #{cmd_array.inspect}/#{e.message}") if (rv) when "clear" debug("sending command '#{command}' with params #{cmd_array.inspect}") - @aug.clear(cmd_array[0]) + rv = aug.clear(cmd_array[0]) + fail("Error sending command '#{command}' with params #{cmd_array.inspect}/#{e.message}") if (rv == -1) when "insert", "ins" label = cmd_array[0] where = cmd_array[1] @@ -338,7 +343,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do else fail("Invalid value '#{where}' for where param") end debug("sending command '#{command}' with params #{[label, where, path].inspect}") - aug.insert(path, label, before) + rv = aug.insert(path, label, before) + fail("Error sending command '#{command}' with params #{cmd_array.inspect}/#{e.message}") if (rv == -1) else fail("Command '#{command}' is not supported") end rescue SystemExit,NoMemoryError -- cgit From 71653a74d91b1e6e9845b4a41249861319c0d6b0 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 9 Feb 2010 00:18:13 +1100 Subject: Fixed #3162 - tidy does not remove empty files when "size => 0" is set Thanks to Stig Sandbeck Mathisen for the fix See also http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=513309 --- lib/puppet/type/tidy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index b5ccb3fb1..3d7190c27 100755 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -139,7 +139,7 @@ Puppet::Type.newtype(:tidy) do end def tidy?(path, stat) - if stat.size > value + if stat.size >= value return true else return false -- cgit