Puppet providers are notoriously difficult to debug. Sure, errors will be shown, and you'll get some debug output if you run puppet agent --test --debug
. However, more often than not things will fail silently or the error message won't be indicative of the actual issue. Same goes for the debug output. Not to mention that Puppet agent debug output is very verbose.
Something that I see more or less frequently is that the debug output shows an external command being executed, but no indication that the execution of the command actually failed, or why.
What you can do is add some output statements to your provider code. Unfortunately this isn't very well documented, but the Puppet
class provides several methods that can be used for this purpose (one for every log level listed here):
Puppet.debug("debug message")
Puppet.info("information message")
Puppet.notice("notice message")
Puppet.warning("warning message")
Puppet.err("error message")
Puppet.alert("alert message")
Puppet.emerg("emergency message")
Puppet.crit("critical message")
debug()
messages are only shown when running puppet agent --test --debug
, the others are displayed in the "regular" output (puppet agent --test
).
A method in your provider could for instance look somewhat like this:
def enable
begin
Puppet.debug("enable resource")
output = execute(['command', '--with', 'arguments'])
Puppet.notice(output) unless output.nil?
rescue Puppet::ExecutionFailure => e
Puppet.err("#{__method__}: #{e.inspect}")
end
end