diff options
author | Markus Roberts <Markus@reality.com> | 2010-02-09 15:17:53 -0800 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-02-09 15:17:53 -0800 |
commit | 27322e5460130b854835aef56ab7076bab83a00b (patch) | |
tree | b69501ce3c7fd616880f60999ad38304a40abba2 /lib/puppet/configurer.rb | |
parent | 70c71c58c1dd038d033d5fdd3fecc8f15b11fd52 (diff) | |
parent | 71653a74d91b1e6e9845b4a41249861319c0d6b0 (diff) | |
download | puppet-27322e5460130b854835aef56ab7076bab83a00b.tar.gz puppet-27322e5460130b854835aef56ab7076bab83a00b.tar.xz puppet-27322e5460130b854835aef56ab7076bab83a00b.zip |
Merge branch '0.25.x'
Conflicts:
lib/puppet/agent.rb
lib/puppet/application/puppet.rb
lib/puppet/configurer.rb
man/man5/puppet.conf.5
spec/integration/defaults.rb
spec/unit/configurer.rb
Diffstat (limited to 'lib/puppet/configurer.rb')
-rw-r--r-- | lib/puppet/configurer.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index 350e9c34f..8179d2c4d 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' @@ -33,6 +35,19 @@ class Puppet::Configurer Puppet[:puppetdlockfile] end + def clear + @catalog.clear(true) if @catalog + @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 @@ -73,6 +88,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. @@ -91,6 +108,8 @@ class Puppet::Configurer duration = thinmark do result = catalog_class.find(name, fact_options.merge(:ignore_cache => true)) end + rescue SystemExit,NoMemoryError + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not retrieve catalog from remote server: %s" % detail @@ -134,6 +153,8 @@ class Puppet::Configurer def run(options = {}) begin prepare() + rescue SystemExit,NoMemoryError + raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Failed to prepare catalog: %s" % detail @@ -165,6 +186,7 @@ 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 + execute_postrun_command Puppet::Util::Log.close(report) @@ -198,4 +220,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 |