diff options
| author | Luke Kanies <luke@reductivelabs.com> | 2010-01-18 17:26:06 -0800 |
|---|---|---|
| committer | Luke Kanies <luke@reductivelabs.com> | 2010-01-18 17:26:06 -0800 |
| commit | cdcbdc78bc399a60afaf36b6267688e72081fb6e (patch) | |
| tree | 1a2e3bf8bbe06631acdcf7d0f6acc0021dfaa048 /lib/puppet/application | |
| parent | 67216aa5637a0e134750103abb74b5c2e3db3eb6 (diff) | |
| download | puppet-cdcbdc78bc399a60afaf36b6267688e72081fb6e.tar.gz puppet-cdcbdc78bc399a60afaf36b6267688e72081fb6e.tar.xz puppet-cdcbdc78bc399a60afaf36b6267688e72081fb6e.zip | |
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 <luke@reductivelabs.com>
Diffstat (limited to 'lib/puppet/application')
| -rw-r--r-- | lib/puppet/application/puppet.rb | 10 |
1 files changed, 7 insertions, 3 deletions
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 |
