Hi all,
I've recently started using postrun_command. It seems very useful, but I'd
really like to be able to optionally print the output from the postrun
command so the users can see any relevant messages. I patched 2.6.4 to get
this working with the new options print_prerun_output and
print_postrun_output (both defaulting to false).
My patch is included below.
~Morgan
diff --git a/configurer.rb b/configurer.rb
index 31d31c2..194acc1 100644
--- a/configurer.rb
+++ b/configurer.rb
@@ -41,11 +41,11 @@ class Puppet::Configurer
end
def execute_postrun_command
- execute_from_setting(:postrun_command)
+ execute_from_setting(:postrun_command, Puppet[:print_postrun_output])
end
def execute_prerun_command
- execute_from_setting(:prerun_command)
+ execute_from_setting(:prerun_command, Puppet[:print_prerun_output])
end
# Initialize and load storage
@@ -200,11 +200,14 @@ class Puppet::Configurer
timeout
end
- def execute_from_setting(setting)
+ def execute_from_setting(setting, print_output = false)
return if (command = Puppet[setting]) == ""
begin
- Puppet::Util.execute([command])
+ output = Puppet::Util.execute([command])
+ if print_output then
+ Puppet.info(output)
+ end
rescue => detail
raise CommandHookError, "Could not run command from #{setting}:
#{detail}"
end
diff --git a/defaults.rb b/defaults.rb
index 4521a59..e0d2cda 100644
--- a/defaults.rb
+++ b/defaults.rb
@@ -168,6 +168,12 @@ module Puppet
: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."],
+ :print_prerun_output => [false,
+ "Boolean; whether to print output from the prerun_command at the
'info' level."
+ ],
+ :print_postrun_output => [false,
+ "Boolean; whether to print output from the postrun_command at the
'info' level."
+ ],
:freeze_main => [false, "Freezes the 'main' class, disallowing any code
to be added to it. This
essentially means that you can't have any code outside of a node,
class, or definition other
than in the site manifest."]
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.